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

Docs: issues inferring branch (e.g. in Travis build) #136

Open
OliverJAsh opened this issue Feb 20, 2020 · 1 comment
Open

Docs: issues inferring branch (e.g. in Travis build) #136

OliverJAsh opened this issue Feb 20, 2020 · 1 comment

Comments

@OliverJAsh
Copy link
Collaborator

OliverJAsh commented Feb 20, 2020

I just noticed that all of my builds are uploading with their branch set to HEAD. IIUC, this is because of the way Travis builds work—they clone the repository then checkout a specific commit (e.g. abc) rather than a branch name (e.g. master):

$ git clone  --branch=master https://github.com/unsplash/unsplash-web.git unsplash/unsplash-web
Cloning into 'unsplash/unsplash-web'...
$ cd unsplash/unsplash-web
$ git checkout -qf 67babfc8143aab900f9660c2c933388e0b9e7125

This means that when the build tracker CLI tries to infer the branch name via git rev-parse --abbrev-ref HEAD, we will get HEAD instead of the actual branch name.

You can see this for yourself by running these commands locally:

$ git checkout master
$ git rev-parse --abbrev-ref HEAD
master
$ git checkout `git rev-parse master`
$ git rev-parse --abbrev-ref HEAD
HEAD

I understand this is why the --branch flag is useful. Perhaps we could have some docs on the site to outline the problem and the recommended solution, as otherwise it might not be obvious why this happens nor how to fix it?

For future reference, I managed to specify the branch name using the environment variables provided by Travis: TRAVIS_PULL_REQUEST_BRANCH and TRAVIS_BRANCH (https://docs.travis-ci.com/user/environment-variables/#default-environment-variables).

@paularmstrong
Copy link
Owner

I would love to have an entire page or example setup available for Travis & CircleCI!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Low priority
Development

No branches or pull requests

2 participants