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: Support generating change files from conventional commits #513

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

asmundg
Copy link
Member

@asmundg asmundg commented Apr 13, 2021

This adds optional support for parsing changefile properties from structured conventional commit messages. When --useConventionalCommits is set, and at least one commit message from the current branch adheres to the structured commits standard, the last conforming commit message is used to populate the change files' type and description.

@kenotron
Copy link
Member

This is a nice thought - one that could potentially be expounded upon. Say, the flow could even be "at the time of a git commit, if it has a certain format, generate the change file along with the commit." This way, you're even skipping the "beachball change" step!

@kenotron
Copy link
Member

more scenarios to consider:

  1. one might want to configure additional types of conventions in the commits - so they would need a way to map the conventions to the semver changes
  2. after this is in, another neat thing to do is to then allow for a changelog generator that follows conventional-changelog: https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog/README.md
  3. there is yet another neat tool called: https://github.com/tunnckoCoreLabs/parse-commit-message that can give you a headstart on being able to parse commit messages

@Aaron-Pool
Copy link

@asmundg @kenotron Did this get any traction? I'm trying to find a good automated release/version handler as I migrate a library to monorepo structure, but I'm also a pretty big fan of conventional commits. So I'd prefer not to give that up, if possible.

@asmundg
Copy link
Member Author

asmundg commented Jun 9, 2021

@Aaron-Pool landing this on my backlog, but has kept getting pushed down. I am hoping to find some time this month.

@Aaron-Pool
Copy link

@asmundg How much work is still outstanding? Is it in a state that I could play around with it? Or is it not usable at all?

@asmundg
Copy link
Member Author

asmundg commented Jun 9, 2021

@Aaron-Pool I use it daily. :) The outstanding work is mostly around cleaning up and looking at integrating into git hooks. As such, this change is self-contained, but we wanted to think some more about usage patterns before we just added it.

@Aaron-Pool
Copy link

@asmundg, cool, I think I'll install your PR and play around with it. Also, small tidbit of initial feedback--shouldn't chore map to None, rather than patch? I was under the impression that chore mapped to things like documentation and file reorganization, things that shouldn't actually produce a new version?


switch (d.type) {
case 'fix':
case 'chore':
Copy link
Member

@tido64 tido64 Jun 17, 2021

Choose a reason for hiding this comment

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

Why would chore map to patch here? When I think of chore commits, I usually think of things like bumping a dev dependency or other changes that do not affect the published package.

Also, can you add support docs and test as well?

Choose a reason for hiding this comment

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

@tido64 I've been doing some hacking locally to get it "just right" and I think what would be best would be to let the user provide a dictionary of allowed types and the change type (major/minor/patch/none) it should map to. That has worked well for me.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that makes sense. Also, I just saw your comment now, asking the exact same question 🤣


function map(d: ConventionalCommit): Change | undefined {
if (d.breaking) {
return { type: 'major', message: d.message };
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a special case here, for semver 0.x.y packages. In that scheme breaking changes are a minor bump, and fixes/feats are a patch bump.

npm, dependabot, are aware of that scheme, it it's used in some common packages like react-native.

case 'fix':
return { type: 'patch', message: d.message };
case 'feat':
return { type: 'minor', message: d.message };
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this intersect with prerelease packages?

}

export function parseConventionalCommit(commitMessage: string): Change | undefined {
const match = commitMessage.match(COMMIT_RE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: consider doing case insensitive match

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

5 participants