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

force default branch name for tests #2393

Merged
merged 1 commit into from May 15, 2022

Conversation

gaige
Copy link
Contributor

@gaige gaige commented May 14, 2022

Fixes #2391

More modern git versions have the ability to set the default branch name, and recent documentation warns against expecting the branch name to be stable. As such, added an explicit set to master (as that was the minimal change and is backwards compatible with older versions of git.

Call is made in a try/except block checking for errors and stepping back to the previous version without initial-branch

@gaige gaige changed the title force default branch name Draft: force default branch name May 14, 2022
@gaige gaige changed the title Draft: force default branch name force default branch name May 14, 2022
try:
cmd_output('git', 'init', '--initial-branch=master', path)
except CalledProcessError: # pragma: no cover (pre 2.28 git)
cmd_output('git', 'init', path)
Copy link
Member

Choose a reason for hiding this comment

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

without needing special version-specific coverage:

git -c init.defaultBranch=master init path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, didn't realize that worked. I'll fix that when I'm back from running a few errands. Thanks!

@@ -0,0 +1,8 @@
import sys
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shoot. I thought I'd fixed that.... Will do.

@gaige gaige force-pushed the set-default-branch-for-tests-2391 branch 3 times, most recently from 75be086 to d132c51 Compare May 14, 2022 18:01
@gaige gaige marked this pull request as draft May 14, 2022 18:11
@gaige gaige force-pushed the set-default-branch-for-tests-2391 branch from d132c51 to 0d55dff Compare May 14, 2022 18:27
@gaige gaige marked this pull request as ready for review May 14, 2022 18:56
@gaige
Copy link
Contributor Author

gaige commented May 14, 2022

basically a one-line patch at this point.

@asottile asottile force-pushed the set-default-branch-for-tests-2391 branch from 0d55dff to 34e9702 Compare May 15, 2022 01:40
@asottile asottile changed the title force default branch name force default branch name for tests May 15, 2022
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.

@asottile asottile merged commit e93c1c6 into pre-commit:main May 15, 2022
2 checks passed
ljmf00 pushed a commit to ljmf00/before-commit that referenced this pull request May 26, 2022
(cherry picked from commit 34e9702)

Reference: pre-commit/pre-commit@34e9702
Reference: pre-commit/pre-commit#2393
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
ljmf00 pushed a commit to before-commit/before-commit that referenced this pull request May 27, 2022
(cherry picked from commit 34e9702)

Reference: pre-commit/pre-commit@34e9702
Reference: pre-commit/pre-commit#2393
Signed-off-by: Luís Ferreira <contact@lsferreira.net>
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.

Tests fail on systems configured for default branch other than master
2 participants