drdoctr / doctr

A tool for automatically deploying docs from Travis CI to GitHub pages.
https://drdoctr.github.io
MIT License
107 stars 30 forks source link

git checkout master failed #376

Open abitrolly opened 3 years ago

abitrolly commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.

asmeurer commented 3 years ago

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).

abitrolly commented 3 years ago

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

abitrolly commented 3 years ago

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