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

no-commit-to-branch: Add 'main' to branches blocked by default #565

Merged
merged 1 commit into from
Mar 4, 2021

Conversation

ndevenish
Copy link
Contributor

@ndevenish ndevenish commented Mar 4, 2021

It's becoming more common to have the primary git branch be called main instead of master now. With GitHub now making it the default and making it easier to transition across, we've started noticing it more in other repositories, and started transferring our repositories over to it.

However, a stage that we missed in several cases was updating the pre-commit hook for no-commit-to-branch to block the new name, as we had relied on the default behaviour before.

This patch updates the default behaviour so both master and main are blocked by default.

Along with this, I found that all of the tests for this hook failed by default on my machine - as part of moving my muscle memory I had set git's global init.defaultBranch=main. This only seems to exist from 2.28, while pre-commit lists 2.24 as a requirement for tests - but git seems to ignore (or set but not use) unrecognised configurations, so this should be safe for all targets.

Side note: I couldn't find any guidelines for what formatting you want in this repo, and flake8 complained about the now-longer git call in the test configuration, so I wrote it in black-style.

tests/conftest.py Outdated Show resolved Hide resolved
@ndevenish
Copy link
Contributor Author

I've removed the change to the test configuration that caused all of the no-commit-to-branch tests to fail on my machine.

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

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

if you want to make another PR which makes these tests work independent of the default configured branch that'd be cool

@asottile asottile merged commit 2618198 into pre-commit:master Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants