Skip to content

Commit

Permalink
fix(args): prepend and output only compatible if paths are different
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Engelhardt <antoncengelhardt@icloud.com>
  • Loading branch information
antonengelhardt committed May 26, 2024
1 parent d250816 commit 3b81a56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,13 @@ pub fn run(mut args: Opt) -> Result<()> {
)));
}
}
if args.output.is_some() && args.prepend.is_some() {
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' cannot be used together",
"'-o' and '-p' can only be used together if they point to different \
files",
)));
}
if args.body.is_some() {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/usage/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +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)
# 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 3b81a56

Please sign in to comment.