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 05f028b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ pub fn run(mut args: Opt) -> Result<()> {
)));
}
}
if args.output.is_some() && args.prepend.is_some() {
return Err(Error::ArgumentError(String::from(
"'-o' and '-p' cannot be used together",
)));
}
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
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 05f028b

Please sign in to comment.