From 972962431ecc30e066e38f9993bea2b8bab0bb44 Mon Sep 17 00:00:00 2001 From: Anton Engelhardt Date: Fri, 24 May 2024 19:47:30 +0200 Subject: [PATCH 1/3] fix(args): -o and -p are not allowed together setting prepend and output together will ignore the prepend flag Signed-off-by: Anton Engelhardt --- git-cliff/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index 3f69c25165..a56c05817d 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -386,6 +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.body.is_some() { config.changelog.body.clone_from(&args.body); } From d250816386fa4650fafe826cf1f7018e2f2abfc2 Mon Sep 17 00:00:00 2001 From: Anton Engelhardt Date: Fri, 24 May 2024 20:03:01 +0200 Subject: [PATCH 2/3] docs(examples): add note about incompatibility with output to prepend arg Signed-off-by: Anton Engelhardt --- website/docs/usage/examples.md | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/usage/examples.md b/website/docs/usage/examples.md index a070e4a3f0..f83d2cfeca 100644 --- a/website/docs/usage/examples.md +++ b/website/docs/usage/examples.md @@ -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) git cliff --unreleased --tag 1.0.0 --prepend CHANGELOG.md ``` From 3b81a56a5be7e40f5aa72ef32ac1ffd69cb0a31f Mon Sep 17 00:00:00 2001 From: Anton Engelhardt Date: Sun, 26 May 2024 22:17:25 +0200 Subject: [PATCH 3/3] fix(args): prepend and output only compatible if paths are different Signed-off-by: Anton Engelhardt --- git-cliff/src/lib.rs | 8 ++++++-- website/docs/usage/examples.md | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index a56c05817d..fa597cda44 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -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() { 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 ```