Skip to content

Commit

Permalink
feat(changelog): add skip empty flag
Browse files Browse the repository at this point in the history
If a release contains no sections to display `--skip-empty` can be used to not show the release in the changelog.
This is useful if old commits were not conventional or if you configured to hide some types and the release contains no sections.

Refs: #30
  • Loading branch information
hdevalke committed Oct 2, 2021
1 parent 261da7e commit c3f4972
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub struct ChangelogCommand {
pub prefix: String,
#[structopt(default_value = "HEAD")]
pub rev: String,
#[structopt(short, long)]
pub skip_empty: bool,
}

#[derive(Debug, StructOpt)]
Expand Down
8 changes: 6 additions & 2 deletions src/cmd/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,16 @@ impl Command for ChangelogCommand {
let from = &w[0];
let to = &w[1];
let context = transformer.transform(from, to)?;
writer.write_template(&context)?;
if !self.skip_empty || !context.context.commit_groups.is_empty() {
writer.write_template(&context)?;
}
}
}
None => {
let context = transformer.transform(&Rev("HEAD", None), &Rev("", None))?;
writer.write_template(&context)?;
if !self.skip_empty || !context.context.commit_groups.is_empty() {
writer.write_template(&context)?;
}
}
}
Ok(())
Expand Down

0 comments on commit c3f4972

Please sign in to comment.