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(version): add flag to include changelog commit author, close #248 #253

Merged
merged 11 commits into from Jul 20, 2022

Conversation

ghiscoding
Copy link
Member

@ghiscoding ghiscoding commented Jul 13, 2022

Description

Add a flag --changelog-include-commit-author to optionally include every commit author name in the changelog when using conventional-commits, this in terms is allowing us to see all PR contributors.

Supersede previous PR #249 to fix issue #248

Motivation and Context

new feature related to the issue #248, please note that this implementation is not exactly pretty code but at this time conventional-changelog lib doesn't provide any easy way to add the commit's author name directly (as requested in this issue), this PR will do that (even if it's a bit hacky). The hacky part is that conventional-changelog lib does provide the format argument (which is supposed to git log pretty format) but it then calls its own template parser which interfere with the git log format and that plays with the actual string output, basically any of the format argument(s) provided will end up being part of the commit url because of that said template parser, so we then have to pull any extra string argument (like the author that we add in the format) and move them outside of the commit url to avoid breaking the commit url.

Let's take this code example, the commit url in changelog will end up looking like this (with defined tokens or our own)
[e123b32](http://github/..../e123b32<<author=Reno Bot>>))
we will then extract the author and move it outside the commit url, then transform it into something readable like this:
[e123b32](http://github/..../e123b32)) (@Reno-Bot)

For a final live example, executing a new version of Lerna-Lite in dry-run mode, we get the following with/without commits authors

without commit's author (before new feature or when new flag isn't provided)

## [1.6.1](https://github.com/ghiscoding/lerna-lite/compare/v1.6.0...v1.6.1) (2022-07-08)

### Bug Fixes

* **deps:** update all non-major dependencies ([ed1db35](https://github.com/ghiscoding/lerna-lite/commit/ed1db352cd0853dd338bb4a7ebf7998b99eb9f36))
* **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/ghiscoding/lerna-lite/commit/978bf3666c0d0cdc78e133066b3caf69d127213c))
* **run:** add double quotes around script target containing colon ([18da175](https://github.com/ghiscoding/lerna-lite/commit/18da175f3b4525c51800affe78b57e151448c643))
* **version:** rollback previous patch on pnpm lockfile update ([d9f933c](https://github.com/ghiscoding/lerna-lite/commit/d9f933c7c9c118727cb5108b3ef3b0527d0d3f2c))

with commit's author (enabled opt-in feature --changelog-include-commit-author)
scroll to the right to see the difference -->>

## [1.6.1](https://github.com/ghiscoding/lerna-lite/compare/v1.6.0...v1.6.1) (2022-07-08)

### Bug Fixes

* **deps:** update all non-major dependencies ([ed1db35](https://github.com/ghiscoding/lerna-lite/commit/ed1db352cd0853dd338bb4a7ebf7998b99eb9f36)) (@Renovate-Bot)
* **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/ghiscoding/lerna-lite/commit/978bf3666c0d0cdc78e133066b3caf69d127213c)) (@Renovate-Bot)
* **run:** add double quotes around script target containing colon ([18da175](https://github.com/ghiscoding/lerna-lite/commit/18da175f3b4525c51800affe78b57e151448c643)) (@ghiscoding)
* **version:** rollback previous patch on pnpm lockfile update ([d9f933c](https://github.com/ghiscoding/lerna-lite/commit/d9f933c7c9c118727cb5108b3ef3b0527d0d3f2c)) (@ghiscoding)

How Has This Been Tested?

unit tests were added for the new feature

Types of changes

  • Chore (change that has absolutely no effect on users)
  • 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)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented Jul 13, 2022

Codecov Report

Merging #253 (db553fb) into main (9c5c792) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #253      +/-   ##
==========================================
+ Coverage   93.79%   93.80%   +0.02%     
==========================================
  Files         142      142              
  Lines        4071     4079       +8     
  Branches      905      833      -72     
==========================================
+ Hits         3818     3826       +8     
  Misses        253      253              
Impacted Files Coverage Δ
...kages/cli/src/cli-commands/cli-version-commands.ts 100.00% <ø> (ø)
packages/version/src/version-command.ts 100.00% <ø> (ø)
.../core/src/conventional-commits/update-changelog.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9c5c792...db553fb. Read the comment docs.

@ghiscoding ghiscoding changed the title Feat/conventional commits author to changelog feat(version): add flag to include changelog commit author, close #248 Jul 13, 2022
@ghiscoding ghiscoding merged commit 7fd8db1 into main Jul 20, 2022
@ghiscoding ghiscoding deleted the feat/conventional-commits-author-to-changelog branch July 20, 2022 16:03
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

1 participant