Skip to content
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

.pre-commit-config.yaml: disallow commiting to version branches #4494

Conversation

Swiftb0y
Copy link
Member

before this commit, it was possible to accidentally commit to
the stable version branches (such as 2.3). If this was done
by a member with push access, they could push untested commits
into production on accident. If this was done by a git newbie,
they would mess up their local branch and deal with conflicts
when pulling their branch later. If commiting to the branch
is justified, the check can be bypassed by
SKIP=no-commit-to-branch git commit

@@ -51,6 +51,8 @@ repos:
- commit
- manual
- id: no-commit-to-branch
# protect main and any branch that has a semver-like name
args: [-b, main, -p, '^\d+.\d+(?:.\d)*$']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot needs to be escaped to not match any character.
We also don't have more than three versions
Can we just:

Suggested change
args: [-b, main, -p, '^\d+.\d+(?:.\d)*$']
args: [-b, main, -p, '^\d+\.\d+(?:\.\d+)?$']

for 2.4 / 244.35235 / 2.4.1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I forgot the dot was a special character too.
The regex you proposed was exactly what I intended, I just wrote it down incorrectly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amended the commit

before this commit, it was possible to accidentally commit to
the stable version branches (such as 2.3). If this was done
by a member with push access, they could push untested commits
into production on accident. If this was done by a git newbie,
they would mess up their local branch and deal with conflicts
when pulling their branch later. If commiting to the branch
is justified, the check can be bypassed by
`SKIP=no-commit-to-branch git commit`
@Swiftb0y Swiftb0y force-pushed the pre-commit-disallow-committing-to-version-branches branch from bb54189 to 769ba03 Compare October 31, 2021 11:36
@daschuer
Copy link
Member

Thank you.

@daschuer daschuer merged commit 5577f36 into mixxxdj:2.3 Oct 31, 2021
@Swiftb0y Swiftb0y deleted the pre-commit-disallow-committing-to-version-branches branch October 31, 2021 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants