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 {
|
||||
#[throws]
|
||||
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();
|
||||
|
||||
|
@ -24,7 +26,7 @@ impl Changelog {
|
|||
let manifest_bytes = current
|
||||
.tree()?
|
||||
.get_path("Cargo.toml".as_ref())?
|
||||
.to_object(&project.repo)?
|
||||
.to_object(&repo)?
|
||||
.as_blob()
|
||||
.unwrap()
|
||||
.content()
|
||||
|
|
|
@ -68,7 +68,7 @@ pub(crate) enum Error {
|
|||
Git { source: git2::Error },
|
||||
#[snafu(display("Regex compilation error: {}", source))]
|
||||
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 {
|
||||
start_dir: PathBuf,
|
||||
source: git2::Error,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::common::*;
|
||||
|
||||
pub(crate) struct Project {
|
||||
pub(crate) repo: Repository,
|
||||
pub(crate) root: PathBuf,
|
||||
pub(crate) config: Config,
|
||||
pub(crate) bin: Bin,
|
||||
|
@ -11,16 +10,7 @@ pub(crate) struct Project {
|
|||
impl Project {
|
||||
#[throws]
|
||||
pub(crate) fn load(options: &Options) -> Self {
|
||||
let start_dir = 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 root = env::current_dir().context(error::CurrentDir)?;
|
||||
|
||||
let config = Config::load(&root)?;
|
||||
|
||||
|
@ -49,7 +39,6 @@ impl Project {
|
|||
executable: options.bin.clone(),
|
||||
bin,
|
||||
config,
|
||||
repo,
|
||||
root,
|
||||
}
|
||||
}
|
||||
|
@ -64,4 +53,11 @@ impl Project {
|
|||
|
||||
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)]
|
||||
pub(crate) enum Subcommand {
|
||||
#[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"))]
|
||||
Book,
|
||||
#[structopt(about("Generate the changelog"))]
|
||||
|
@ -73,13 +80,15 @@ impl Subcommand {
|
|||
Self::Book => Self::book(&project)?,
|
||||
Self::Man => Self::man(&project)?,
|
||||
Self::Diff => Self::diff(&project)?,
|
||||
Self::All => Self::all(&project)?,
|
||||
Self::All { no_git } => Self::all(&project, no_git)?,
|
||||
}
|
||||
}
|
||||
|
||||
#[throws]
|
||||
pub(crate) fn all(project: &Project) {
|
||||
Self::changelog(&project)?;
|
||||
pub(crate) fn all(project: &Project, no_git: bool) {
|
||||
if !no_git {
|
||||
Self::changelog(&project)?;
|
||||
}
|
||||
Self::completion_scripts(&project)?;
|
||||
Self::readme(&project)?;
|
||||
Self::book(&project)?;
|
||||
|
@ -131,7 +140,9 @@ impl Subcommand {
|
|||
|
||||
gen(HEAD)?;
|
||||
|
||||
let head = project.repo.head()?;
|
||||
let repo = project.repo()?;
|
||||
|
||||
let head = repo.head()?;
|
||||
|
||||
let head_commit = head.peel_to_commit()?;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user