Conventional Commits
conventionalcommits.org
conventionalcommits.org
Just stick to squash-before-merge-to-master, thanks.
Then you can do whatever you want in your feature branch, and then when the feature is ready, create the squashed commit with the proper commit formatting.
Now a larger change set is hidden behind a squash merge, and why was line 50 in foobar.py updated? Who knows, it was part of this giant merge request which no longer provides context why the developer changed line 50 in foobar.py.
Commit messages should explain why the change was made to the code. The amount of times that I go diving into a codebase only to find that the change was introduced in a larger commit that just says "fix bug" with no further information is maddening.
The right use is to allow me to make crappy, random commits on my own feature branch, clean them up those commits when I'm ready to release the change.
And the commit description will describe what's going on.
The key is that my feature branch is not long-lived - only a day or two, long enough for me to make a step forward before merging it back into mainline and then starting on the next step.
- Commit and push naturally as you work
- Reviewers to look at individual commits separately after having already reviewed previous commits
- Squash-and-merge with one click (usually, e.g. GitHub) instead of messing around with git resets and branch history.
The problem you describe is a problem because people are not prioritizing or valuing the commit history as a resource. If you fix that, then people will think about these things differently.
Squash and merge is not the only way to get things into master. You can rebase and squash commits as needed on your branch and then bring multiple commits from your branch onto master. That takes more advanced usage of git, but learning that makes sense once you start really valuing the history.
I like to push all my commits up so I can pull them back on a different machine or get early feedback. I'll typically rebase at the end with a proper commit message and explanation for each logical change.
chore: injecting logger
I've been working on a project for months that uses this exact setup (commits are rejected if they are not formatted correctly) and the problem you describe just isn't that big of a deal. The benefits to the projects far outweigh the mild inconvenience.I'm the original co-author of the "Conventional Commits" spec. Although, I should give credit where credit is due, and say that it evolves directly from Angular commit conventions.
I started adopting these conventions with the goal of automating releases, both on my open-source and on the services I was working on at npm (I've since brought the practice to my team at Google).
I very much did not want to introduce road blocks to folks committing to their own branches -- which is what the "rewrite the message when you squash" advice grows from.
Here's a post I wrote on how my team uses Conventional Commits in our release process:
> refactor!: drop support for Node 6
From Wikipedia's Code Refactoring:
> In computer programming and software design, code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior.
So if a code change is just a refactor, then its external behavior is unchanged, therefore it is not a breaking change. These two commit labels are incompatible.
In this specific case, it is both a refactor and a breaking change.
> refactor: A code change that neither fixes a bug nor adds a feature
But yeah I'm with you in saying that this particular example is not well choosen