From 05f028b43387462483fe336eed62655f2ec47738 Mon Sep 17 00:00:00 2001 From: Anton Engelhardt Date: Sun, 26 May 2024 22:17:25 +0200 Subject: [PATCH] fix(args): prepend and output only compatible if paths are different Signed-off-by: Anton Engelhardt --- git-cliff/src/lib.rs | 10 +++++----- website/docs/usage/examples.md | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index a56c05817d..4042ccfc3c 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -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); } diff --git a/website/docs/usage/examples.md b/website/docs/usage/examples.md index f83d2cfeca..d57cc4ea62 100644 --- a/website/docs/usage/examples.md +++ b/website/docs/usage/examples.md @@ -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 ```