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

Add Template for handling commits with Conventional Commits format #217

Merged
merged 6 commits into from
Sep 11, 2024

Conversation

IllusionVK
Copy link
Contributor

This template will organise commits into their own headings for each version using the Conventional Commits/Angular format as explained here https://www.conventionalcommits.org/en/v1.0.0/

Comments have been deliberately left in the template to

  • Help explain the logic of the template, including which commit types are supported
  • Provide some extra support for new users who may want to customise things.
  • Include the Regex code for package.json to allow users to instantly start using the template
  • I'd request that these comments are not stripped out as they are obviously not included in the final change log and don't really hurt anyone.
  • This template also deliberately does not include a link to the individual commits to reduce the file size (due to limitation on some platforms that only allow - for example - 5000 characters in a change log submitted with a build). Users can easily add this back in using the other 3 templates of the repo as inspiration if needed.

@aladdin-add
Copy link

aladdin-add commented Oct 15, 2021

@IllusionVK I've copied the template to one of my repos. the result is here: https://github.com/weiran-zsd/dts-cli/blob/82c351cb0062f4d5faa644f98bd87eeb39dac55d/CHANGELOG.md

the only problem is the user cannot be clicked to github profile. is there a way to use github id(not name)?

@karfau
Copy link

karfau commented Dec 22, 2021

I just tried to use this in a project, but it didn't detect the breaking changes properly,
since they were written as BREAKING CHANGE:.

Could it make sense to simplify the regular expressions by applying them case insensitive?

Oh and for some reason I still had brackets around the scopes inside the changelog, is that intended?

@cookpete
Copy link
Owner

cookpete commented Feb 3, 2022

@IllusionVK Any thoughts on the comments here?

@IllusionVK
Copy link
Contributor Author

Hi @cookpete thanks for the tag.

So @aladdin-add about your comment. I have looked in the readme for this repo and the open issues and i haven't been able to find anywhere that helps to add in the URL for the author.. so maybe this is not supported for now, but perhaps @cookpete can confirm, in case I missed it. I also just added the {{author}} tag to the readme to help users know it is there (because its only mentioned on 1x closed issue before this PR). And I just added commented out hash links in case that is any help as well.

and @karfau you are welcome to download the template and edit it to support how you enter things in to your commits,
As you can see i spent time to add regex so that it supports both capitalised and uncapitalised types like Fix: and fix: but I didn't cater for every scenario in the world, but of course you have the power to adjust this to you needs. If we removed the regex and 1x developer in a team did not always put things in upper case then all of their commits would be ignored and put into the general section, which is not ideal. So the regex is trying to support humans being humans. About the brackets around the scope yes we deliberately left these in to help make them visually stand out. You can customise as you like.

Cheers.

@karfau
Copy link

karfau commented Feb 11, 2022

@IllusionVK thx for the clarifications. If I remember correctly in hindsight it was my error that the breaking changes were not detected:
The PRs had the text, but squashed commit that landed on the default branch didn't have it.

@simonecorsi
Copy link

This feature would be useful to me! Is there something I can do to help move this forward?

@IllusionVK
Copy link
Contributor Author

Hey @simonecorsi you can actually just download the template and use it on your computer right now... it doesn't need to be merged. I'm sure that Pete will get to it when he has time, but until then just download the file and use it like all other templates 👍

@cookpete
Copy link
Owner

Can we rename the template to just conventional (I'm a sucker for brevity) and then I’ll get this published.

@simonecorsi
Copy link

simonecorsi commented Feb 23, 2022

Hey @simonecorsi you can actually just download the template and use it on your computer right now... it doesn't need to be merged. I'm sure that Pete will get to it when he has time, but until then just download the file and use it like all other templates 👍

Oh my bad, I missed that --template flag could also resolve urls/files 🤦
Thank you for the tip!

@IllusionVK
Copy link
Contributor Author

Can we rename the template to just conventional (I'm a sucker for brevity) and then I’ll get this published.

Hi @cookpete, template has been renamed as requested.

@vigohe
Copy link
Contributor

vigohe commented Mar 7, 2022

@IllusionVK nice feature!! I hope it will be soon merged

@adrien-berchet
Copy link

Hi
I was looking for something close to this, but there is still something that bothers me: would it be possible to organize the merges and fixes by subjects? In our case we work with PRs on Github so all commits are merge commits and are thus listed as merges, so the subjects are just useless in our case :-/
I guess we would need a #merge-list helper :-)

--}}


{{!-- In package.json need to add this to remove label text from the change log output (becuase the markdown headers are now used to group them).

Choose a reason for hiding this comment

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

Suggested change
{{!-- In package.json need to add this to remove label text from the change log output (becuase the markdown headers are now used to group them).
{{!-- In package.json need to add this to remove label text from the change log output (because the markdown headers are now used to group them).

@IllusionVK
Copy link
Contributor Author

@adrien-berchet I guess anything is possible. I think you would need to identify how each merge/pr can be recognised. ie what is the pattern etc that regex would need to use to organise things. Because I assume that your objective is to get merges and PRs to also be listed under the headings like 'feature', 'fix' etc ?

@itayo
Copy link
Contributor

itayo commented Mar 22, 2022 via email

@adrien-berchet
Copy link

Yes @IllusionVK that's exactly my objective. Unfortunately, as far as I know, it is not possible to get the ID of the PR from the commits listed by #commit-list and thus I can not add a link to the PR as I usually do for merge commits when I use each merges and group these merge commits under headings. And I think they this would be really nice 🙂

@IllusionVK
Copy link
Contributor Author

@adrien-berchet yeah so for me a merge looks like this Merge branch 'feature/photo-annotation' of github.com:IllusionV… so I guess that

  • if you labelled your branches correctly/in a standardised way, you could write regex to match them.
  • for example regex could do pattern matching from ' to /
  • for example:
    • Merge branch 'feature/photo-annotation' of github.com:IllusionV… = feature = gets added to new features heading
    • Merge branch 'fix/photo-annotation' of github.com:IllusionV… = fix = gets added to bug fixes heading.

I'm probably not going to be able to spend the time on this to add that functionality, but using something like https://regexr.com/ could help you to get it all working in 2-3 hours I reckon. the original work I undertook probably took 5-6 hours of fiddling around, looping over and over to get everything working well. It would be cool if you can spend the time and then you can commit a PR on this also to help improve it 👍

@adrien-berchet
Copy link

Hi @IllusionVK , thanks for your tips and sorry for the late answer.
I finally found what I was missing: it is possible to list the merge commits with something like:

{{#commit-list merges heading='### Heading' message='regex'}}
    - <message format>
{{/commit-list}}

(note the merges instead of commits after #commit-list)
So I copied what you did here for merge commits (and updated to use the merge attributes) and it almost works as expected. The only remaining issue for me is that I get a given heading twice: once for regular commits and once for merge commits. It would be super nice to be able to merge these 2 categories but I guess this can not be fixed with the current implementation, but if you think about a solution I would love it. For example, to be more clear, let's say I have 2 regular commits and 2 merge commits, the changelog looks like this:

# Changelog

## [Unreleased](https://github.com/MyOrganization/MyProject/compare/1.2.3..HEAD)

> 6 April 2022

### New Features

- Merge commit A (The Author - [#1](https://github.com/MyOrganization/MyProject/pull/1))
- Merge commit B (The Author - [#2](https://github.com/MyOrganization/MyProject/pull/2))

### New Features

- Regular commit A (The Author - [#3](https://github.com/MyOrganization/MyProject/commit/<hashC>))
- Regular commit B (The Author - [#4](https://github.com/MyOrganization/MyProject/commit/<hashD>))

@IllusionVK
Copy link
Contributor Author

Hey @adrien-berchet did you notice that in #### General Changes I excluded many other things ? this removes all things that have already been shown above, and allows me to include anything else. Maybe you could try that ?

@IllusionVK
Copy link
Contributor Author

Hey @cookpete I think this one is good to merge in now, if you are happy with it ?

@cookpete
Copy link
Owner

Three years late but… here we are.

@cookpete cookpete merged commit e1f4045 into cookpete:master Sep 11, 2024
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.

8 participants