Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ISSUE-265:- make default branch configurable #316

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghost
Copy link

@ghost ghost commented Aug 23, 2022

@ghost
Copy link
Author

ghost commented Aug 23, 2022

make default branch configurable

@effigies
Copy link
Contributor

Thanks! Thinking about this, I think we need to consider these use cases:

  1. New repository with no remote. Probably want the current branch, as you're unlikely to be branching yet.
  2. Self-owned repository where you work with just one remote (typically origin)
  3. Contributing repository where you refer to a canonical fork (generally upstream or origin, depending on local convention)

I would probably use the following preference order:

  1. git rev-parse --abbrev-ref upstream/HEAD
  2. git rev-parse --abbrev-ref origin/HEAD
  3. git rev-parse --abbrev-ref HEAD
  4. git config init.defaultBranch
  5. "master" (git too old to have init.defaultBranch)

This value should be computed on installation, not git_pieces_from_vcs(), and set in the configuration. We do VCS-specific installation steps in https://github.com/python-versioneer/python-versioneer/blob/master/src/git/install.py.

In git_pieces_from_vcs() we should use the configuration variable in place of hard-coded "master".

Now, this is just to get the default branch, which only needs to be done once at installation. When we actually use it, we should use the config variable, since that will be more reliable than each user of the repository naming their remotes the same thing.

SAMPLE_CONFIG = """
# See the docstring in versioneer.py for instructions. Note that you must
# re-run 'versioneer.py setup' after changing this section, and commit the
# resulting files.
[versioneer]
#VCS = git
#style = pep440
#versionfile_source =
#versionfile_build =
#tag_prefix =
#parentdir_prefix =
"""

We could consider making it default_branch = {default_branch}, which would make it easy to detect whether it has been set before or if we should run the inference above.

@ghost
Copy link
Author

ghost commented Sep 5, 2022

cool, will work on the above comment.

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.

2 participants