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): support using stdout via dash (-o -) #644

Merged
merged 1 commit into from May 18, 2024

Conversation

orhun
Copy link
Owner

@orhun orhun commented May 11, 2024

Description

Using - for stdout is a common convention between CLI tools and this PR simply adds this support to git-cliff.

Motivation and Context

This makes it possible to use git-cliff as follows:

$ git-cliff -o -

(instead of git-cliff -o /dev/stdout or git-cliff -o)

Also you can combine it with -p as mentioned in #643

How Has This Been Tested?

Locally

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 41.90%. Comparing base (d5acda1) to head (dd154ac).
Report is 1 commits behind head on main.

Files Patch % Lines
git-cliff/src/lib.rs 0.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
+ Coverage   41.88%   41.90%   +0.02%     
==========================================
  Files          15       15              
  Lines        1077     1079       +2     
==========================================
+ Hits          451      452       +1     
- Misses        626      627       +1     
Flag Coverage Δ
unit-tests 41.90% <0.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@favna
Copy link
Contributor

favna commented May 12, 2024

This very nearly works perfectly. The current command I run through cliff-jumper is:

F:\favware\git-cliff\target\x86_64-pc-windows-msvc\release\git-cliff.exe --tag @favware/cliff-jumper@3.0.3 --prepend ./CHANGELOG.md --unreleased --config ./cliff.toml --output - --github-repo favware/cliff-jumper --github-token "ghp_NOPE"

And when I set execa stdio to pipe I get this under the stdout property:

# Changelog

All notable changes to this project will be documented in this file.

# [@favware/cliff-jumper@3.0.3](https://github.com/favware/cliff-jumper/compare/@favware/cliff-jumper@3.0.2...@favware/cliff-jumper@3.0.3) - (2024-05-12)

## 🏠 Refactor

- **deps:** Update dependency conventional-recommended-bump to v10 ([aab0368](https://github.com/favware/cliff-jumper/commit/aab0368c3501792a64566a0d82fc0e3f935b3ed7)) ([#171](https://github.com/favware/cliff-jumper/pull/171))
  - 💥 **BREAKING CHANGE:** Node 18 is now required as per the new version of `conventional-recommended-bump`
  - 💥 **BREAKING CHANGE:** The base `conventional-changelog-angular` is now used instead of a customization of it. This should not affect the semver resolution, but if it does please create a GitHub issue
  - 💥 **Co-authored-by:** renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

## 🐛 Bug Fixes

- **deps:** Update dependency execa to v9 ([07e39ae](https://github.com/favware/cliff-jumper/commit/07e39ae3a94ae50326ba3d250f4c16a23d665c84)) ([#175](https://github.com/favware/cliff-jumper/pull/175))

## 🚀 Features

- Test3 ([fdc7833](https://github.com/favware/cliff-jumper/commit/fdc7833fa37f90d619b134ceaff57e8681db575e))
- Test2 ([1e51302](https://github.com/favware/cliff-jumper/commit/1e5130224e323bf9886414e27cb08b33c621f16a))
- Test1 ([8aa2776](https://github.com/favware/cliff-jumper/commit/8aa27769eb37d6fa6d561ca616a30f2291061509))

This includes the header configured in cliff.toml. I'm not sure what the best approach here is. I don't want it to be included in the GitHub releases. I see 2 paths:

  1. I add a TOML parser to my lib, check if there is a header property and if so use string replace to remove it
  2. git-cliff somehow removes it but only from --output because ofc we wouldn't want to remove it from the file output. Not sure if this is feasible.

(sidenote, ignore that there are breaking changes in a supposedly patch, that's just because I'm debugging and I do have actual breaking changes pending release)

@orhun
Copy link
Owner Author

orhun commented May 13, 2024

I'm guessing if using the --strip header option is feasible, but then the header won't be prepended to the file.

git-cliff somehow removes it but only from --output because ofc we wouldn't want to remove it from the file output. Not sure if this is feasible.

I thought of doing the same but I'm not sure. I'm not sure how people are using prepend and it might have some side effects.

Can you simply fetch it from cliff.toml and replace/remove it? I think that'd be the best.

Copy link
Contributor

@favna favna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I should be able to do that. I'll work that in then in the coming days. Putting an approval here because as far as git-cliff changes go this LGTM then.

@orhun
Copy link
Owner Author

orhun commented May 13, 2024

Sounds perfect. Just LMK then!

@favna
Copy link
Contributor

favna commented May 17, 2024

Parsing TOML on my side is working perfectly (using smol-toml). Looking forward to this getting merged and released so I can then subsequently update cliff-jumper.

@orhun orhun merged commit df81f63 into main May 18, 2024
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants