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

CI: Set git default branch to "main" in CircleCI. #18572

Merged
merged 1 commit into from
Mar 7, 2021

Conversation

seberg
Copy link
Member

@seberg seberg commented Mar 7, 2021

Should fix the current failure that "master" does not exist.
I am a bit curious why master does not exist, maybe the CircleCI
git is set up to use some other default?


I am starting to get confused, I just hope the branch name was actually at the core of the issue :) (although the error message does indicate so).

@seberg seberg force-pushed the ci-devdoc-branch branch 2 times, most recently from 84d965b to 555f452 Compare March 7, 2021 21:19
@seberg
Copy link
Member Author

seberg commented Mar 7, 2021

OK, I noticed that locally git branch shows nothing before the first commit, so maybe on the older git version the git branch -m doesn't work at all before the first commit, so moved it to the end. Hopefully that cuts it...

@@ -45,7 +45,6 @@ def run(cmd, stdout=True):
os.chdir(workdir)

run(['git', 'init'])
run(['git', 'branch', '-m', 'master', 'main'])
Copy link
Member

Choose a reason for hiding this comment

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

git checkout -b main seems to work after the init.

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we try that first? I am surprised that the "initial" branch would not be named master though, so I was wondering if the git version mismatch means that renaming branches doesn't really work at all at that time (mainly because at that time my git has git branch show nothing). Do you have an older git version to confirm?

Copy link
Member

Choose a reason for hiding this comment

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

Do you have an older git version to confirm?

No, I have git version 2.29.2 and git init -b main also worked for me, but without the specification there were no branches at all. Creating the branch by checking out should be pretty definite. Oddly, a simple git branch main fails for lack of a master branch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, sorry, I misread. git checkout -b main sounds good, let me do that!

Copy link
Member Author

Choose a reason for hiding this comment

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

Lets try that. Changed it (and mofidied the comment a bit).

Copy link
Member

Choose a reason for hiding this comment

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

Since git version 2.28.0 the git init command now takes a --initial-branch (or -b for short) parameter.

So that isn't an option, but the checkout way seems valid, see https://tinyurl.com/y7v7brcl.

Should fix the current failure that "master" does not exist.
I am a bit curious why master does not exist, maybe the CircleCI
git is set up to use some other default.
Move the branch rename to after the commit, to make sure that
the fact that the branch is empty (and `git branch` also)
cannot influence the result.

[ci-skip]
@charris charris merged commit 0cea1d9 into numpy:main Mar 7, 2021
@charris
Copy link
Member

charris commented Mar 7, 2021

And away we go. Thanks Sebastian.

@charris
Copy link
Member

charris commented Mar 7, 2021

It works!

@charris charris changed the title CI: Do not pass original branch name to git branch -m main CI: Set git default branch to "main" in CircleCI. Mar 7, 2021
@seberg seberg deleted the ci-devdoc-branch branch March 7, 2021 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants