Skip to content

feat: output generated changelog blurb to both stdout and file for further processing #643

@favna

Description

@favna

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Currently when --prepend is provided git-cliff will output the generated CHANGELOG section for the desired release to the file that is provided through --prepend. It would be nice if it could also be send to the STDOUT through a flag so it can be picked up for further processing. It should be noted that if --prepend is not provided then git-cliff does print to stdout.

The motivation for this feature is that I could then use it for @favware/cliff-jumper to capture it and send it to the body of a GitHub release when calling the Create Release API endpoint. Currently, my CLI stops after updating the changelog and creating the Git tag locally, but if I can capture the release body I can make it possible to push the Git tag to the remote repository and create a release from that tag so a full release flow can be automated.

Desired solution

  1. The least breaking way to achieve this would be a flag such as --stdout, which when paired with --prepend ./CHANGELOG.md will write to both the CHANGELOG.md to print to stdout. Documentation would be able to clarify what the behaviour is of combining these 2 options.
  2. A breaking way to achieve this would be to make it so the output always has to be provided, i.e. --output /dev/stdout/ --output ./CHANGELOG.md. The equivalent of only --prepend ./CHANGELOG.md would then be --prepend ./CHANGELOG.md --output ./CHANGELOG.md
    1. Alternatively a way to do this non-breaking would be that if --output is not provided the current behaviour is retained, however in my opinion this becomes confusing because then what is going to happen if the user provides options like --prepend ./CHANGELOG.md --output ./CHANGELOG.md
    2. What also concerns me with this solution is cross-platform compatibility. While Linux and MacOS will work with /dev/stdout/, I do not know for sure if this will work for Windows users. I would prefer if I do not have to do OS checking in @favware/cliff-jumper to account for this. With the former solution of --stdout the advantage is that as a user of git-cliff I do not need to think about how exactly I can write to stdout for my operating system as git-cliff will automatically do that.

Alternatives considered

Running git-cliff twice, first to print to stdout without --prepend and then to CHANGELOG.md file with --prepend. This is less ideal because of the "run twice" factor.

Additional context

Also discussed on Discord here: https://discord.com/channels/1093977388892819553/1093978266135707668/1237529889113112607

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions