auto-changelog icon indicating copy to clipboard operation
auto-changelog copied to clipboard

Add Template for handling commits with Conventional Commits format

Open IllusionVK opened this issue 4 years ago • 19 comments

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.

IllusionVK avatar Sep 01 '21 17:09 IllusionVK

@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)?

aladdin-add avatar Oct 15 '21 08:10 aladdin-add

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?

karfau avatar Dec 22 '21 18:12 karfau

@IllusionVK Any thoughts on the comments here?

cookpete avatar Feb 03 '22 22:02 cookpete

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.

IllusionVK avatar Feb 09 '22 09:02 IllusionVK

@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.

karfau avatar Feb 11 '22 19:02 karfau

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

simonecorsi avatar Feb 17 '22 15:02 simonecorsi

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 👍

IllusionVK avatar Feb 23 '22 12:02 IllusionVK

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

cookpete avatar Feb 23 '22 12:02 cookpete

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!

simonecorsi avatar Feb 23 '22 12:02 simonecorsi

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.

IllusionVK avatar Mar 03 '22 13:03 IllusionVK

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

vigohe avatar Mar 07 '22 15:03 vigohe

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 :-)

adrien-berchet avatar Mar 21 '22 11:03 adrien-berchet

@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 ?

IllusionVK avatar Mar 22 '22 13:03 IllusionVK

Yes and same for me

Den tis 22 mars 2022 14:40Charlie Blundell @.***> skrev:

@adrien-berchet https://github.com/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 ?

— Reply to this email directly, view it on GitHub https://github.com/cookpete/auto-changelog/pull/217#issuecomment-1075193786, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL4BEZN7SIYDC45IEJD663VBHET5ANCNFSM5DG6G5OA . You are receiving this because you commented.Message ID: @.***>

itayo avatar Mar 22 '22 13:03 itayo

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 🙂

adrien-berchet avatar Mar 22 '22 18:03 adrien-berchet

@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 👍

IllusionVK avatar Mar 23 '22 05:03 IllusionVK

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>))

adrien-berchet avatar Apr 06 '22 17:04 adrien-berchet

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 avatar Apr 25 '22 07:04 IllusionVK

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

IllusionVK avatar Jun 05 '22 14:06 IllusionVK