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
build: disallow squash
commits and ensure fixup
commits match an earlier commit
#32023
Conversation
Mainly making the tests more closely follow the order of checks in the function implementation, so that it is easier to follow.
This sets the ground for adding stricter rules for fixup commits in a follow-up PR.
Wouldn't the postcommit run of check-commit-message consider a fixup commit invalid, before it got a chance to be rebased into the correct location? Also, at least for me it's quite common to push fixup commits without rebasing at all. Although this may results in conflicts when reordering the commits during merge, quite often it's known that certain commits won't cause any conflicts when their changes are reordered. |
7b54b10
to
0edf4bd
Compare
We don't have a
Me too 😁 This is still supported 😅 I also just realized that squash commits might be useful during local development, so I will change the script to allow them in the Thx for the feedback 😃 |
While `fixup! ` is fine, `squash! ` means that the commit message needs tweaking, which cannot be done automatically during merging (i.e. it should be done by the PR author). Previously, `validate-commit-message` would always allow `squash! `-prefixed commits, which would cause problems during merging. This commit changes `validate-commit-message` to make it configurable whether such commits are allowed and configures the `gulp validate-commit-message` task, which is run as part of the `lint` job on CI, to not allow them. NOTE: This new check is disabled in the pre-commit git hook that is used to validate commit messages, because these commits might still be useful during development.
0edf4bd
to
d62851d
Compare
Previously, `validate-commit-message` would treat `fixup! `-prefixed commits like this: - It would strip the `fixup! ` prefix. - It would validate the rest of the commit message header as any other commit. However, fixup commits are special in that they need to exactly match an earlier commit message header (sans the `fixup! ` prefix) in order for git to treat them correctly. Otherwise, they will not be squashed into the original commits and will be merged as is. Fixup commits can end up not matching their original commit for several reasons (e.g. accidental typo, changing the original commit message, etc.). This commit prevents invalid fixup commits to pass validation by ensuring that they match an earlier (unmerged) commit (i.e. a commit between the current HEAD and the BASE commit). NOTE: This new behavior is currently not activated in the pre-commit git hook, that is used to validate commit messages (because the preceding, unmerged commits are not available there). It _is_ activated in `gulp validate-commit-message`, which is run as part of the `lint` job on CI and thus will detect invalid commits, before their getting merged.
d62851d
to
598ab1f
Compare
squash
commits and ensure fixup
commits match a preceding commitsquash
commits and ensure fixup
commits match an earlier commit
Mainly making the tests more closely follow the order of checks in the function implementation, so that it is easier to follow. PR Close #32023
This sets the ground for adding stricter rules for fixup commits in a follow-up PR. PR Close #32023
While `fixup! ` is fine, `squash! ` means that the commit message needs tweaking, which cannot be done automatically during merging (i.e. it should be done by the PR author). Previously, `validate-commit-message` would always allow `squash! `-prefixed commits, which would cause problems during merging. This commit changes `validate-commit-message` to make it configurable whether such commits are allowed and configures the `gulp validate-commit-message` task, which is run as part of the `lint` job on CI, to not allow them. NOTE: This new check is disabled in the pre-commit git hook that is used to validate commit messages, because these commits might still be useful during development. PR Close #32023
Previously, `validate-commit-message` would treat `fixup! `-prefixed commits like this: - It would strip the `fixup! ` prefix. - It would validate the rest of the commit message header as any other commit. However, fixup commits are special in that they need to exactly match an earlier commit message header (sans the `fixup! ` prefix) in order for git to treat them correctly. Otherwise, they will not be squashed into the original commits and will be merged as is. Fixup commits can end up not matching their original commit for several reasons (e.g. accidental typo, changing the original commit message, etc.). This commit prevents invalid fixup commits to pass validation by ensuring that they match an earlier (unmerged) commit (i.e. a commit between the current HEAD and the BASE commit). NOTE: This new behavior is currently not activated in the pre-commit git hook, that is used to validate commit messages (because the preceding, unmerged commits are not available there). It _is_ activated in `gulp validate-commit-message`, which is run as part of the `lint` job on CI and thus will detect invalid commits, before their getting merged. PR Close #32023
This sets the ground for adding stricter rules for fixup commits in a follow-up PR. PR Close #32023
While `fixup! ` is fine, `squash! ` means that the commit message needs tweaking, which cannot be done automatically during merging (i.e. it should be done by the PR author). Previously, `validate-commit-message` would always allow `squash! `-prefixed commits, which would cause problems during merging. This commit changes `validate-commit-message` to make it configurable whether such commits are allowed and configures the `gulp validate-commit-message` task, which is run as part of the `lint` job on CI, to not allow them. NOTE: This new check is disabled in the pre-commit git hook that is used to validate commit messages, because these commits might still be useful during development. PR Close #32023
Previously, `validate-commit-message` would treat `fixup! `-prefixed commits like this: - It would strip the `fixup! ` prefix. - It would validate the rest of the commit message header as any other commit. However, fixup commits are special in that they need to exactly match an earlier commit message header (sans the `fixup! ` prefix) in order for git to treat them correctly. Otherwise, they will not be squashed into the original commits and will be merged as is. Fixup commits can end up not matching their original commit for several reasons (e.g. accidental typo, changing the original commit message, etc.). This commit prevents invalid fixup commits to pass validation by ensuring that they match an earlier (unmerged) commit (i.e. a commit between the current HEAD and the BASE commit). NOTE: This new behavior is currently not activated in the pre-commit git hook, that is used to validate commit messages (because the preceding, unmerged commits are not available there). It _is_ activated in `gulp validate-commit-message`, which is run as part of the `lint` job on CI and thus will detect invalid commits, before their getting merged. PR Close #32023
…ar#32023) Mainly making the tests more closely follow the order of checks in the function implementation, so that it is easier to follow. PR Close angular#32023
This sets the ground for adding stricter rules for fixup commits in a follow-up PR. PR Close angular#32023
While `fixup! ` is fine, `squash! ` means that the commit message needs tweaking, which cannot be done automatically during merging (i.e. it should be done by the PR author). Previously, `validate-commit-message` would always allow `squash! `-prefixed commits, which would cause problems during merging. This commit changes `validate-commit-message` to make it configurable whether such commits are allowed and configures the `gulp validate-commit-message` task, which is run as part of the `lint` job on CI, to not allow them. NOTE: This new check is disabled in the pre-commit git hook that is used to validate commit messages, because these commits might still be useful during development. PR Close angular#32023
…r#32023) Previously, `validate-commit-message` would treat `fixup! `-prefixed commits like this: - It would strip the `fixup! ` prefix. - It would validate the rest of the commit message header as any other commit. However, fixup commits are special in that they need to exactly match an earlier commit message header (sans the `fixup! ` prefix) in order for git to treat them correctly. Otherwise, they will not be squashed into the original commits and will be merged as is. Fixup commits can end up not matching their original commit for several reasons (e.g. accidental typo, changing the original commit message, etc.). This commit prevents invalid fixup commits to pass validation by ensuring that they match an earlier (unmerged) commit (i.e. a commit between the current HEAD and the BASE commit). NOTE: This new behavior is currently not activated in the pre-commit git hook, that is used to validate commit messages (because the preceding, unmerged commits are not available there). It _is_ activated in `gulp validate-commit-message`, which is run as part of the `lint` job on CI and thus will detect invalid commits, before their getting merged. PR Close angular#32023
…ar#32023) Mainly making the tests more closely follow the order of checks in the function implementation, so that it is easier to follow. PR Close angular#32023
This sets the ground for adding stricter rules for fixup commits in a follow-up PR. PR Close angular#32023
While `fixup! ` is fine, `squash! ` means that the commit message needs tweaking, which cannot be done automatically during merging (i.e. it should be done by the PR author). Previously, `validate-commit-message` would always allow `squash! `-prefixed commits, which would cause problems during merging. This commit changes `validate-commit-message` to make it configurable whether such commits are allowed and configures the `gulp validate-commit-message` task, which is run as part of the `lint` job on CI, to not allow them. NOTE: This new check is disabled in the pre-commit git hook that is used to validate commit messages, because these commits might still be useful during development. PR Close angular#32023
…r#32023) Previously, `validate-commit-message` would treat `fixup! `-prefixed commits like this: - It would strip the `fixup! ` prefix. - It would validate the rest of the commit message header as any other commit. However, fixup commits are special in that they need to exactly match an earlier commit message header (sans the `fixup! ` prefix) in order for git to treat them correctly. Otherwise, they will not be squashed into the original commits and will be merged as is. Fixup commits can end up not matching their original commit for several reasons (e.g. accidental typo, changing the original commit message, etc.). This commit prevents invalid fixup commits to pass validation by ensuring that they match an earlier (unmerged) commit (i.e. a commit between the current HEAD and the BASE commit). NOTE: This new behavior is currently not activated in the pre-commit git hook, that is used to validate commit messages (because the preceding, unmerged commits are not available there). It _is_ activated in `gulp validate-commit-message`, which is run as part of the `lint` job on CI and thus will detect invalid commits, before their getting merged. PR Close angular#32023
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR cleans up the
validate-commit-message
script and tests and introduces the following changes:squash!
commits invalidate-commit-message
on CIThis mainly ensures that we don't accidentally merge a fixup/squash commit into master.
See the individual commit messages for details.