-
Notifications
You must be signed in to change notification settings - Fork 13
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
Don't require formatting for commit titles, these cause more problems than they solve. #15
base: main
Are you sure you want to change the base?
Conversation
… than they solve. Adding the type/scope to the commit title is a bad idea for the following reasons: Encoding data in the title indicates a problem in the tooling. If you need to clearly tag commits with information, then PR tags should probably be used. These are much more easily filtered in a UI. Categories, while familiar to people, are generally a bad way of labelling data. You can fit the majority of cases into categories but there will always be cases where no category fits (which means either using no category, a general category or adding many infrequently used categories). Data also often falls into multiple categories. This can be handled by listing multiple categories for the data (i.e. treating as tags) or having to decide a threshold when a category is met. Due to these reasons picking categories is time consuming task without always a clear solution. Having a code change, title and type/scope means you now have three things that need to be consistent. The risk of them not matching is increased over just having two. A good analogy for this is code comments. The general modern consensus on comments is they should be used sparingly, and only in cases where the intention of the code can't be easily determined. If you have a comment that just literally states what the code does it is useless (this is the same for a PR title where the words match the type/scope). If you have to use a comment it is an indication that you should consider how your code is written. Rewriting the code often makes the comment redundant (the same for PR titles - if you need to add the type/scope then perhaps the title is not appropriately descriptive for the change). With all the above issues there are likely to be many errors setting the type/scope which quickly undermines confidence in them. I have experienced this in many projects that use them.
This PR is to give feedback (issues can't be opened), not intended to be merged as-is. If we did accept this change the document should probably have a section on how to write good PR titles. |
I agree that theis a big risk of wrong categorisation, which is one of the reason I excluded chore for instance, to have more specific ones. Forcing the merge request having a story-like title is still a good thing, but the prefix undermines a little bit that effort. |
A few thoughts from me:
My vote is to try using conventional commits (or similar) where it makes sense and see how we get on at the end of the cycle. Either way, looking forward to further refining our process! |
My personal opinion is that we should follow conventional commits ( Instead, I think PR titles/merge commits could follow something similar to snapd where the title prefix isn't For example, in this PR: canonical/steam-snap#290 I didn't follow any set standard. Following what I've described, the PR title could be changed to something like
Then, the merge commit title could match the PR title + the PR number: I think this helps scope commits and PRs, and encourages committing often. Plus, it makes scanning through PR titles and commit titles much easier, while also providing additional ways to search for commits or PRs. |
I guess the issue with your example is what you put in the title itself. I would rephrase this particular case to Same for
Here, you are describing the what and not the why. It’s basically a tautology of the diff that I can directly open up. Those kinds of content is better in the long commit message by itself. Arguably in this example, how is "Remove comments" a There are multiple existing writeup on this, like https://www.gitkraken.com/learn/git/best-practices/git-commit-message. The idea is that you care about the story, the story is the merge commit, this is what you try to present at the higher level of abstraction. One PR is also one idea (but not necessarily one commit). If you can’t summarize one PR under a single umbrella, it means that your PR is too large and should be broken down. The smaller units are how you got to that story, they don’t not necessarily pass existing tests. Also, the longer commit description helps when doing Basically, you end up with something like:
I don’t think that adding I hope that makes sense. |
Adding the type/scope to the commit title is a bad idea for the following reasons:
Encoding data in the title indicates a problem in the tooling. If you need to clearly tag commits with information, then PR tags should probably be used. These are much more easily filtered in a UI.
Categories, while familiar to people, are generally a bad way of labelling data. You can fit the majority of cases into categories but there will always be cases where no category fits (which means either using no category, a general category or adding many infrequently used categories). Data also often falls into multiple categories. This can be handled by listing multiple categories for the data (i.e. treating as tags) or having to decide a threshold when a category is met. Due to these reasons picking categories is time consuming task without always a clear solution.
Having a code change, title and type/scope means you now have three things that need to be consistent. The risk of them not matching is increased over just having two.
A good analogy for this is code comments. The general modern consensus on comments is they should be used sparingly, and only in cases where the intention of the code can't be easily determined. If you have a comment that just literally states what the code does it is useless (this is the same for a PR title where the words match the type/scope). If you have to use a comment it is an indication that you should consider how your code is written. Rewriting the code often makes the comment redundant (the same for PR titles - if you need to add the type/scope then perhaps the title is not appropriately descriptive for the change).
With all the above issues there are likely to be many errors setting the type/scope which quickly undermines confidence in them. I have experienced this in many projects that use them.