question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to allow `fixup!` and `squash!` in commit messages

See original GitHub issue

Description

It would be nice if cz check didn’t fail for fixup and squash commits, e.g., git commit --fixup <rev> or git commit --squash <rev> if the commit messages are otherwise acceptable. In git worflows that use rebase and --autosquash, the offending commit message portion (squash! or fixup! ) will be removed. This is especially annoying when commitizen is used with pre-commit, because every time you do a squash or fixup commit you have to SKIP=commitizen git commit --fixup ....

Possible Solution

Add a CLI option to cz check for this such as --autosquash or some better name which, if true, prepends the commit message check regex pattern with something like r"((fixup|squash)\!\s)?"

I haven’t thought through all of the use cases, but a CLI option may be preferable to a config setting in e.g., toml because you may want the behavior to be different when you are committing (allow) versus pushing or in your CI pipeline (deny). So having something that can be changed a bit more easily than a config option may be desirable. But I hold this opinion lightly.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:7
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
woilecommented, Mar 29, 2022

fine by me as well 👍

1reaction
yajocommented, Mar 28, 2022

I don’t think this is related to git itself. It’s just a matter of allowing fixup commits in the regexp.

For example, having the commit-msg pre-commit hook installed, there should be a way to let this not fail:

> git commit -a --fixup 57a2044f1290cba0ca6530e6e77cd5da243e74b1
commitizen check.........................................................Failed
- hook id: commitizen
- exit code: 14

commit validation: failed!
please enter a commit message in the commitizen format.
commit "": "fixup! feat: allow easy working"
pattern: (build|ci|docs|feat|fix|perf|refactor|style|test|chore|revert|bump)(\(\S+\))?!?:(\s.*)
Read more comments on GitHub >

github_iconTop Results From Across the Web

git commit: fixup and squash automatically - code-comments
Construct a commit message for use with rebase —autosquash. The commit message subject line is taken from the specified commit with a prefix...
Read more >
fixup and git rebase --autosquash | Jordan Elver
Standard procedure for this is - 1) Make the code change; 2) Commit the change; 3) Start an interactive rebase; 4) Identify the...
Read more >
Auto-squashing Git Commits - Thoughtbot
During an interactive rebase there are two ways to combine commits— fixup and squash —and there are two corresponding options for the git-commit...
Read more >
How to squash git commits - by Srebalaji Thirumalai - Git Better
You can also use the fixup option to squash commits. Fixup is the same as squash but it won't allow you to edit...
Read more >
What's the difference between "squash" and "fixup" in Git/Git ...
I do not know what Git Extensions does with it specifically, but git rebase has an option to automatically squash or fixup commits...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found