Skip to content

Commit

Permalink
feat(changelog): allow running with --prepend and --output (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Dec 16, 2022
1 parent 53c1c50 commit 7325be8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions git-cliff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit 7325be8

Please sign in to comment.