doctr icon indicating copy to clipboard operation
doctr copied to clipboard

git checkout master failed

Open abitrolly opened this issue 4 years ago • 6 comments

Looks like doctr is unable to detect that the default branch for the repo is not master and fails.

Happens here https://app.travis-ci.com/github/jonmatthis/freemocap/builds/236410519 where the default branch is main.

abitrolly avatar Aug 30 '21 11:08 abitrolly

The solution is probably https://drdoctr.github.io/recipes.html#deploy-docs-from-a-non-master-branch and it would be nice if the error message was referring to that. Right now the message is a bit confusing. If docs are only pushed from master and the current branch is not master, why do the checkout?

The docs are only pushed to gh-pages from master. To allow pushing from a non-master branch, use the --no-require-master flag
This is the feature/refresh_buttons branch
ERROR: The doctr command '/home/travis/virtualenv/python3.7.1/bin/doctr deploy --built-docs docs/build/html .' failed: SystemExit('\x1b[31mgit checkout master failed: 1\x1b[0m')
git checkout master failed: 1

There might be something else going there. In addition, if doctr is supposed to fail when run from PR, it should be covered in example given in the README.

abitrolly avatar Aug 30 '21 11:08 abitrolly

Documented --branch-whitelist develop didn't help - the process took a bit further, but then again failed with git checkout master failed: 1 in the end.

https://app.travis-ci.com/github/jonmatthis/freemocap/builds/236495223

abitrolly avatar Aug 30 '21 16:08 abitrolly

I believe that's the code that is failing https://github.com/drdoctr/doctr/blob/7e757118a1807aed5b7e95c5404bd47c6dbdccd0/doctr/travis.py#L354-L355

I am not sure what should happen here - the PR that fails CI proposes to merge jonmatthis:develop from abitrolly:patch-1 and doesn't touch non-existing master or default main.

abitrolly avatar Aug 30 '21 16:08 abitrolly

I thought we had code that used the API to check what the default branch was, but I guess not. Clearly we need to do that now that main is becoming more common. Actually you can probably figure it out without the API (maybe Travis has an environment variable for it, or you can just guess from the branches are present in the clone).

asmeurer avatar Aug 30 '21 21:08 asmeurer

Asked here https://travis-ci.community/t/get-the-name-of-default-branch/12039

abitrolly avatar Aug 31 '21 06:08 abitrolly

The guys pointed to https://stackoverflow.com/questions/28666357/git-how-to-get-default-branch

abitrolly avatar Sep 01 '21 05:09 abitrolly