Skip to content

CI builds: Checkout main branch in a robust way #9793

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

Merged
merged 1 commit into from
Dec 12, 2022

Conversation

benjaoming
Copy link
Contributor

@benjaoming benjaoming commented Dec 8, 2022

Adds an -f switch to force resetting the branch in cases where Circle CI had already fetched it.

I'm still not sure about the exact mechanisms of the built-in Circle CI checkout step. At first I introduced this in a PR where main wasn't found as a reference - and it worked, the branch was added and pre-commit could compare changes in the PR to main.

But then in a later PR after this change, I got errors when main already exists.

git branch --track main origin/main

fatal: a branch named 'main' already exists

https://app.circleci.com/pipelines/github/readthedocs/readthedocs.org/6345/workflows/892de4a3-b7de-4f65-80c2-d7f4643d81f3/jobs/15361

I think the -f switch should do the work:

       -f, --force
           Reset <branchname> to <startpoint>, even if <branchname> exists already. Without -f, git branch refuses to change an existing
           branch. In combination with -d (or --delete), allow deleting the branch irrespective of its merged status. In combination with
           -m (or --move), allow renaming the branch even if the new branch name already exists, the same applies for -c (or --copy).

@benjaoming benjaoming marked this pull request as ready for review December 8, 2022 21:35
@benjaoming benjaoming requested a review from a team as a code owner December 8, 2022 21:35
@benjaoming benjaoming requested a review from humitos December 8, 2022 21:35
@benjaoming
Copy link
Contributor Author

I believe this can be merged given that a reasonable follow-up is discussed here: #9795

@benjaoming benjaoming merged commit 5591120 into readthedocs:main Dec 12, 2022
@benjaoming benjaoming deleted the fix-circle-ci-bug branch December 12, 2022 11:13
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