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

Configure default branch name #60

Closed
wants to merge 17 commits into from

Conversation

mdpiper
Copy link
Member

@mdpiper mdpiper commented Sep 14, 2021

Currently in the babelizer, the default git branch name of the babelized library is set to "master", and there isn't a way to change it. This PR updates the babelizer to allow a user to set a name for the default branch. If no name is set, the name "main" is used as a default.

This fixes #58.

@mdpiper
Copy link
Member Author

mdpiper commented Sep 16, 2021

I refactored the tests calling babelize init for the Python example to include tests with/without the new github_branch attribute.

@mcflugen
Copy link
Member

@mdpiper Thanks for doing this! I combined the branch checks into one parametrized test for the Python tests.

One thing I noticed is that it appears the --initial-branch option isn't available for some versions of git, including the system git on my Mac. I don't know if it's the version (2.24.3) or the Apple version.

@mcflugen
Copy link
Member

@mdpiper I removed the dependency of the tests being run in a particular order (i.e. babelize init is run once to produce a shared package that subsequent tests then use). I'm not certain we can always count on them being ordered in a specific way. I've added test dependencies so tests that require babelize init to work will be skipped if the babelize init test fails. Although this means babelize init will be rerun for some tests, I think it makes it more clean about what's happening. What do you think? Maybe it's not super efficient but I like the idea of having each test be self-contained.

@mdpiper
Copy link
Member Author

mdpiper commented Oct 18, 2021

@mcflugen Thank you for improving the tests in this PR. I like the way you parameterized the branches (I need to do a better job reading the pytest docs), and I agree that the tests should be independent, even if it's a little inefficient.

The --initial-branch option to git init was added in git 2.28 (https://stackoverflow.com/a/42871621) from July 2020. This is kinda new--the git I use through conda is 2.23. Should I add code to check for this?

@mcflugen
Copy link
Member

Should I add code to check for this?

I don't know. I think I would rather check for functionality rather than a particular version. So maybe something along these lines,

try:
    git.Repo.init(".", initial_branch="main")
except git.exc.CommandError as err:
    if "unknown option" in str(err) and "initial-branch" in str(err):
        warnings.warn("old version of git, --initial-branch is not available")
    git.Repo.init(".")

although that's not great.

What do we want to happen if the user has an older version? I guess the options are to either exit the program with an error or ignore a provided github_branch value.

Of course the longer we delay this, the less of an issue it becomes so there is also a case to be made for procrastination.

@mdpiper
Copy link
Member Author

mdpiper commented Mar 15, 2024

Solved by recent versions of git, which use "main" as the default branch name.

@mdpiper mdpiper closed this Mar 15, 2024
This pull request was closed.
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.

Set the default branch of rendered repository to "main"
2 participants