Conversation

ndevenish

It's becoming more common to have the primary git branch be called main instead of master now. With 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 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.

@ndevenishndevenish force-pushed the no_commit_main_default branch from 7df68cf to 3abbd47 Compare March 4, 2021 15:59
@ndevenish

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

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

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

Successfully merging this pull request may close these issues.