Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
favna opened this issue May 10, 2024 · 4 comments
Closed
1 task done
Assignees
Labels
feature/request New feature or request

Comments

@favna
Copy link
Contributor

favna commented May 10, 2024

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

@favna favna added the feature/request New feature or request label May 10, 2024
@orhun
Copy link
Owner

orhun commented May 11, 2024

Thanks for the issue! The following command works if you want to both prepend and save it to a file:

$ git-cliff -p CHANGELOG.md -l -o OTHER.md

I am guessing if we support - for stdout then it will be even more convenient, e.g. git-cliff -p 1.md -l -o - > 2.md

What do you think of this?

@favna
Copy link
Contributor Author

favna commented May 11, 2024

Hm that might work but I'd like to try it from a WIP branch to be sure because I'm not sure how execa from Node handles trailing - to send it to stdout.

@orhun
Copy link
Owner

orhun commented May 11, 2024

Sure, I can implement it soon and you can probably check it out from the PR!

@orhun
Copy link
Owner

orhun commented May 11, 2024

Boop boop #644

@orhun orhun closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants