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

ENH: Handle default branch #1232

Merged
merged 6 commits into from
Jan 2, 2023

Conversation

HaoZeke
Copy link
Member

@HaoZeke HaoZeke commented Jan 2, 2023

Closes #1231. The general implementation is essentially EAFP and is a little clunky, but hopefully at some point the entire git.py plugin will go away in favor of say, pygit2.

Some implementation details are highlighted in the comments.

@HaoZeke HaoZeke force-pushed the handleDefaultBranch branch from 02d1c1c to a734887 Compare January 2, 2023 18:40
try:
self._default_branch = self._run_git(['config',
'init.defaultBranch',
], display_error=False,
Copy link
Member Author

@HaoZeke HaoZeke Jan 2, 2023

Choose a reason for hiding this comment

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

Without display_error=False, tests which capture stderr and stdout to test against reference strings fail.

@mattip mattip merged commit 7c8ef78 into airspeed-velocity:master Jan 2, 2023
@rgommers
Copy link

rgommers commented Mar 3, 2023

A late comment now that I'm seeing this: conceptually this isn't quite right. git config reads first repo-local and then global config. Repo-local config is usually empty, so it falls back to global. I just tried in a repo which still uses master, and am (as expected) getting main as the answer from git config init.defaultBranch. To fix it, .git/config needs to have:

[init]
	defaultBranch = main

I'd think it would be a lot easier to just add the config value to asv.conf.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: git testsuite fails with init.defaultBranch
3 participants