Add --no-git
flag to gen all
The flag skips steps whichr require a git checkout, currently only the changelog generator. type: added
This commit is contained in:
parent
6f4f8e7595
commit
047b36639d
|
@ -7,7 +7,9 @@ pub(crate) struct Changelog {
|
||||||
impl Changelog {
|
impl Changelog {
|
||||||
#[throws]
|
#[throws]
|
||||||
pub(crate) fn new(project: &Project) -> Self {
|
pub(crate) fn new(project: &Project) -> Self {
|
||||||
let mut current = project.repo.head()?.peel_to_commit()?;
|
let repo = project.repo()?;
|
||||||
|
|
||||||
|
let mut current = repo.head()?.peel_to_commit()?;
|
||||||
|
|
||||||
let mut entries = Vec::new();
|
let mut entries = Vec::new();
|
||||||
|
|
||||||
|
@ -24,7 +26,7 @@ impl Changelog {
|
||||||
let manifest_bytes = current
|
let manifest_bytes = current
|
||||||
.tree()?
|
.tree()?
|
||||||
.get_path("Cargo.toml".as_ref())?
|
.get_path("Cargo.toml".as_ref())?
|
||||||
.to_object(&project.repo)?
|
.to_object(&repo)?
|
||||||
.as_blob()
|
.as_blob()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.content()
|
.content()
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub(crate) enum Error {
|
||||||
Git { source: git2::Error },
|
Git { source: git2::Error },
|
||||||
#[snafu(display("Regex compilation error: {}", source))]
|
#[snafu(display("Regex compilation error: {}", source))]
|
||||||
Regex { source: regex::Error },
|
Regex { source: regex::Error },
|
||||||
#[snafu(display("Failed to find repository from `{}`: {}", start_dir.display(), source))]
|
#[snafu(display("Failed to find Git repository from `{}`: {}", start_dir.display(), source))]
|
||||||
RepositoryDiscover {
|
RepositoryDiscover {
|
||||||
start_dir: PathBuf,
|
start_dir: PathBuf,
|
||||||
source: git2::Error,
|
source: git2::Error,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
|
|
||||||
pub(crate) struct Project {
|
pub(crate) struct Project {
|
||||||
pub(crate) repo: Repository,
|
|
||||||
pub(crate) root: PathBuf,
|
pub(crate) root: PathBuf,
|
||||||
pub(crate) config: Config,
|
pub(crate) config: Config,
|
||||||
pub(crate) bin: Bin,
|
pub(crate) bin: Bin,
|
||||||
|
@ -11,16 +10,7 @@ pub(crate) struct Project {
|
||||||
impl Project {
|
impl Project {
|
||||||
#[throws]
|
#[throws]
|
||||||
pub(crate) fn load(options: &Options) -> Self {
|
pub(crate) fn load(options: &Options) -> Self {
|
||||||
let start_dir = env::current_dir().context(error::CurrentDir)?;
|
let root = env::current_dir().context(error::CurrentDir)?;
|
||||||
|
|
||||||
let repo = Repository::discover(&start_dir).context(error::RepositoryDiscover { start_dir })?;
|
|
||||||
|
|
||||||
let root = repo
|
|
||||||
.workdir()
|
|
||||||
.ok_or_else(|| Error::Workdir {
|
|
||||||
repo: repo.path().to_owned(),
|
|
||||||
})?
|
|
||||||
.to_owned();
|
|
||||||
|
|
||||||
let config = Config::load(&root)?;
|
let config = Config::load(&root)?;
|
||||||
|
|
||||||
|
@ -49,7 +39,6 @@ impl Project {
|
||||||
executable: options.bin.clone(),
|
executable: options.bin.clone(),
|
||||||
bin,
|
bin,
|
||||||
config,
|
config,
|
||||||
repo,
|
|
||||||
root,
|
root,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,4 +53,11 @@ impl Project {
|
||||||
|
|
||||||
gen
|
gen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[throws]
|
||||||
|
pub(crate) fn repo(&self) -> Repository {
|
||||||
|
Repository::discover(&self.root).context(error::RepositoryDiscover {
|
||||||
|
start_dir: &self.root,
|
||||||
|
})?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,14 @@ use crate::common::*;
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
pub(crate) enum Subcommand {
|
pub(crate) enum Subcommand {
|
||||||
#[structopt(about("Update all generated docs"))]
|
#[structopt(about("Update all generated docs"))]
|
||||||
All,
|
All {
|
||||||
|
#[structopt(
|
||||||
|
long = "no-git",
|
||||||
|
help = "Skip generated outputs that require a Git repository. Currently this only includes \
|
||||||
|
the changelog."
|
||||||
|
)]
|
||||||
|
no_git: bool,
|
||||||
|
},
|
||||||
#[structopt(about("Generate book"))]
|
#[structopt(about("Generate book"))]
|
||||||
Book,
|
Book,
|
||||||
#[structopt(about("Generate the changelog"))]
|
#[structopt(about("Generate the changelog"))]
|
||||||
|
@ -73,13 +80,15 @@ impl Subcommand {
|
||||||
Self::Book => Self::book(&project)?,
|
Self::Book => Self::book(&project)?,
|
||||||
Self::Man => Self::man(&project)?,
|
Self::Man => Self::man(&project)?,
|
||||||
Self::Diff => Self::diff(&project)?,
|
Self::Diff => Self::diff(&project)?,
|
||||||
Self::All => Self::all(&project)?,
|
Self::All { no_git } => Self::all(&project, no_git)?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[throws]
|
#[throws]
|
||||||
pub(crate) fn all(project: &Project) {
|
pub(crate) fn all(project: &Project, no_git: bool) {
|
||||||
|
if !no_git {
|
||||||
Self::changelog(&project)?;
|
Self::changelog(&project)?;
|
||||||
|
}
|
||||||
Self::completion_scripts(&project)?;
|
Self::completion_scripts(&project)?;
|
||||||
Self::readme(&project)?;
|
Self::readme(&project)?;
|
||||||
Self::book(&project)?;
|
Self::book(&project)?;
|
||||||
|
@ -131,7 +140,9 @@ impl Subcommand {
|
||||||
|
|
||||||
gen(HEAD)?;
|
gen(HEAD)?;
|
||||||
|
|
||||||
let head = project.repo.head()?;
|
let repo = project.repo()?;
|
||||||
|
|
||||||
|
let head = repo.head()?;
|
||||||
|
|
||||||
let head_commit = head.peel_to_commit()?;
|
let head_commit = head.peel_to_commit()?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user