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(changelog): support parsing commits by footer #569

Merged
merged 2 commits into from
Jun 16, 2024
Merged

feat(changelog): support parsing commits by footer #569

merged 2 commits into from
Jun 16, 2024

Conversation

jan-ferdinand
Copy link
Contributor

@jan-ferdinand jan-ferdinand commented Mar 22, 2024

Description

Enable footer-based commit parsing. The idea is to add functionality like

commit_parsers = [
  { footer = "Hello: world", skip = true },
]

I would appreciate some guidance – is this useful, desired, worth it, …?

Motivation and Context

In order to keep my changelogs concise, I would like to ignore certain commits. I would like to specify whether a commit should be ignored in the commit message. A somewhat elegant way to achieve this (I think) would be to include a footer like changelog: ignore.
(If you have a better way to approach this, I'm happy to learn of it.)

How Has This Been Tested?

Append existing tests that create sample changelogs.

The test changelog_generator_split_commits is failing. It appears that a footer's value (but not the key) makes its way into the changelog. This might be because the footer's key is interpreted as a conventional commit type. I would appreciate some guidance here.

Possible Limitations

The conventional commits' specification and the reference implementation of its parser are currently out of sync. This might mean that the commit parser {footer = "Hello: world"} does not work (even though it should), whereas the commit parser {footer = "Hello:world"} does work (even though omitting the space goes against the specification).

Some relevant issues concerning footer parsing are:

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.

Copy link

welcome bot commented Mar 22, 2024

Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️

@orhun
Copy link
Owner

orhun commented Mar 23, 2024

Thanks for the PR!

I would appreciate some guidance – is this useful, desired, worth it, …?
A somewhat elegant way to achieve this (I think) would be to include a footer like changelog: ignore.

I'm wondering if the same can be achieved with body which git-cliff already supports filtering.

I'm also wondering if this is useful for #382. But I'm guessing "This commit reverts" is not a part of the footer.

The test changelog_generator_split_commits is failing. It appears that a footer's value (but not the key) makes its way into the changelog. This might be because the footer's key is interpreted as a conventional commit type. I would appreciate some guidance here.

That is the expected behavior so I recommend you to either add a new CommitParser to changelog_generator_split_commits to skip that commit or update the expected result accordingly to include that commit in the changelog.

Overall, I think this might be useful. Can you update the documentation about the existence of footer filter and also add a test fixture to verify it's behavior?

@orhun
Copy link
Owner

orhun commented Apr 10, 2024

ping @jan-ferdinand 🙂

@jan-ferdinand
Copy link
Contributor Author

Other things have come up and are more pressing right now; I'll come back to this. Apologies if that creates inconveniencies.

@orhun
Copy link
Owner

orhun commented Apr 16, 2024

No worries!

@orhun
Copy link
Owner

orhun commented Jun 2, 2024

ping

@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.44%. Comparing base (dabe716) to head (ae51fc0).

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #569      +/-   ##
==========================================
+ Coverage   36.29%   36.44%   +0.15%     
==========================================
  Files          19       19              
  Lines        1455     1460       +5     
==========================================
+ Hits          528      532       +4     
- Misses        927      928       +1     
Flag Coverage Δ
unit-tests 36.44% <100.00%> (+0.15%) ⬆️

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.

@jan-ferdinand
Copy link
Contributor Author

jan-ferdinand commented Jun 14, 2024

Thanks for ping & patience. I have made the following changes, most of which were requested or guided towards:

  • rebase onto current main
  • fix test changelog_generator_split_commits
  • add fixture
  • add some documentation

I would like to have some additional guidance on the following points:

  • Is the amount of documentation enough? It seems to be very little, but I couldn't readily identify more places where it makes sense to add additional documentation.
  • The conventional commit reference parser being out of sync with the specification is annoying for this PR. It requires users that want to use the suggested feature to write parsers of the form { footer = "^key:value } (which goes against the spec), or, to be a bit more future proof { footer = ^key: ?value } (which is confusing). Does it still make sense to go ahead with the suggested feature despite the possible confusion?
  • I have left comments briefly discussing the out-of-syncedness of spec & parser in two places, one in the fixture and one in the spec. Does this make sense, or would you rather I remove or merge these? The random : ? in the footer parser seems like the kind of regex-odditiy that future devs (including us) will trip over, but I'm not sure it's worth the current verbosity.

@orhun
Copy link
Owner

orhun commented Jun 15, 2024

Thanks for picking up on this!

Is the amount of documentation enough? It seems to be very little, but I couldn't readily identify more places where it makes sense to add additional documentation.

I think it is good enough! I will mention this feature in the news so it should be visible enough.

Does it still make sense to go ahead with the suggested feature despite the possible confusion?

Yes, we can go ahead with it. Alternatively, I'm not sure if there are any actions needed but, you can report this to git-conventional (which git-cliff uses for parsing the commits) FWIW.

I have left comments briefly discussing the out-of-syncedness of spec & parser in two places, one in the fixture and one in the spec. Does this make sense, or would you rather I remove or merge these?

I would rather have them as comment like they are now. Good to have the references 👍🏼

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

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

LGTM, there is only one conflict that needs to be resolved then we are good to go!

@jan-ferdinand
Copy link
Contributor Author

jan-ferdinand commented Jun 15, 2024

Thanks for picking up on this!

Took me long enough. 🤷 Thanks for your patience!

I think it is good enough! I will mention this feature in the news so it should be visible enough.

👌

Yes, we can go ahead with it. Alternatively, I'm not sure if there are any actions needed but, you can report this to git-conventional (which git-cliff uses for parsing the commits) FWIW.

I had opened a PR in trying to resolve this issue. The maintainer chose to stay consistent with the reference implemenation rather than deviating from it, a decision I can understand.

I would rather have them as comment like they are now. Good to have the references 👍🏼

👍

Thanks for your guidance. 😊 I'm going to rebase & force-push in hopes of removing the blocking conflict.

Edit: I have also squashed all commits and changed the commit message. Let me know if any of that goes against this project's guidelines. 😌

jan-ferdinand and others added 2 commits June 16, 2024 00:40
Enable defining parsers for a commit's footer, similar to the already-
present commit parsers for a commit's message or body.

For example:

```toml
commit_parsers = [
  { footer = "changelog: ignore", skip = true },
]
```

Due to an inconsistency between the conventional commits specification
and its reference parser, footers are currently interpreted as
`key:value` instead of the (correct) `key: value`. See
conventional-commits/parser#47 for details.
As a future-proof workaround, you can use `key: ?value` in the regex.
@orhun orhun changed the title feat: filter footers feat(changelog): support parsing commits by footer Jun 16, 2024
@orhun orhun merged commit 50c240c into orhun:main Jun 16, 2024
50 checks passed
Copy link

welcome bot commented Jun 16, 2024

Congrats on merging your first pull request! ⛰️

@jan-ferdinand jan-ferdinand deleted the footer_filter branch June 16, 2024 20:51
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.

3 participants