From 7325be84045ad376e0989a111ed3c44a3e1400ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Fri, 16 Dec 2022 20:59:32 +0300 Subject: [PATCH] feat(changelog): allow running with `--prepend` and `--output` (#120) --- git-cliff/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index b9339086f9..3073da441e 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -292,19 +292,21 @@ pub fn run(mut args: Opt) -> Result<()> { } } - // Generate changelog. + // Generate output. let changelog = Changelog::new(releases, &config)?; + if args.context { + return changelog.write_context(&mut io::stdout()); + } if let Some(path) = args.prepend { - changelog.prepend(fs::read_to_string(&path)?, &mut File::create(path)?) - } else if let Some(path) = args.output { + changelog.prepend(fs::read_to_string(&path)?, &mut File::create(path)?)?; + } + if let Some(path) = args.output { let mut output = File::create(path)?; if args.context { changelog.write_context(&mut output) } else { changelog.generate(&mut output) } - } else if args.context { - changelog.write_context(&mut io::stdout()) } else { changelog.generate(&mut io::stdout()) }