From 8ee0da1f74a0f2cae699ce19accc073434f5b538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 2 Mar 2024 17:47:32 +0300 Subject: [PATCH] refactor(changelog): do not output to stdout when prepend is used --- git-cliff/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index f3355bedd8..d6181d6355 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -484,7 +484,7 @@ pub fn run(mut args: Opt) -> Result<()> { changelog.write_context(&mut io::stdout()) }; } - if let Some(path) = args.prepend { + if let Some(ref path) = args.prepend { changelog.prepend(fs::read_to_string(&path)?, &mut File::create(path)?)?; } if let Some(path) = args.output { @@ -494,7 +494,9 @@ pub fn run(mut args: Opt) -> Result<()> { } else { changelog.generate(&mut output) } - } else { + } else if args.prepend.is_none() { changelog.generate(&mut io::stdout()) + } else { + Ok(()) } }