Skip to content

Commit

Permalink
fix(args): allow -o and -p together if they point to different files (#…
Browse files Browse the repository at this point in the history
…653)

* fix(args): -o and -p are not allowed together

setting prepend and output together will ignore the prepend flag

Signed-off-by: Anton Engelhardt <[email protected]>

* docs(examples): add note about incompatibility with output to prepend arg

Signed-off-by: Anton Engelhardt <[email protected]>

* fix(args): prepend and output only compatible if paths are different

Signed-off-by: Anton Engelhardt <[email protected]>

---------

Signed-off-by: Anton Engelhardt <[email protected]>
  • Loading branch information
antonengelhardt committed May 26, 2024
1 parent b490f2a commit 076f859
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 397,15 @@ pub fn run(mut args: Opt) -> Result<()> {
)));
}
}
if args.output.is_some() &&
args.prepend.is_some() &&
args.output.as_ref() == args.prepend.as_ref()
{
return Err(Error::ArgumentError(String::from(
"'-o' and '-p' can only be used together if they point to different \
files",
)));
}
if args.body.is_some() {
config.changelog.body.clone_from(&args.body);
}
Expand Down
1 change: 1 addition & 0 deletions website/docs/usage/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 72,7 @@ Prepend new changes to an existing changelog file:
```bash
# 1- changelog header is removed from CHANGELOG.md
# 2- new entries are prepended to CHANGELOG.md without footer part
# the --prepend option is incompatible with -o (output) if the file paths are equal
git cliff --unreleased --tag 1.0.0 --prepend CHANGELOG.md
```

Expand Down

0 comments on commit 076f859

Please sign in to comment.