Recently I created a PR on GitHub, but some tests were failing. And locally even more tests didn't pass. So I tried to figure out what's the issue.
And the thing I found out is that Travis was testing the repo being at other commit I don't have. The ref is refs/pull/81/merge. So, somebody supposedly merged my branch into the master and created corresponding ref. Was it GitHub or Travis?
And the other question, can I list all the refs GitHub repo has?
I do not know anything about Travis itself, but GitHub does in fact create these refs/pull/number/merge
refs. In particular, based on observation—the documentation seems a bit skimpy and I am only a somewhat casual user of GitHub—when you click on "new pull request" in GitHub, GitHub:
refs/pull/number/head
to save the ID of the commit you are asking someone else to merge for you;git merge
), and if that succeeds, creates a second reference named refs/pull/number/merge
.Note that this automatically-created merge commit is not on any branch, it merely has the same pull-request number assigned, and a reference whose name is obvious from the pull-request itself (simply replace head
with merge
). I believe—but have not tested manually—that the first parent of this merge is the tip commit of the branch you are requesting someone be "on" when they do the same merge, i.e., the code behind the scenes that creates this refs/pull/number/merge
reference is (or is close enough to):
commithash=... # the commit ID for the pull-request
mergeinto=$(git rev-parse $branchname) # the branch we are to merge into
prnum=... # get next pull request number
# create the pull request itself
git update-ref refs/pull/$prnum/pull $commithash
# create the merge ref, if the merge succeeds
git checkout $mergeinto
if git merge -m "..." refs/pull/$prnum/pull; then
# merge succeeded: create the merge ref
git update-ref refs/pull/$prnum/merge HEAD
else
# automatic merge failed, discard it
git merge --abort
fi
(this particular code sequence messes about with the index, and leaves HEAD
detached, so it has to be done with the repository locked and post-work cleanup, or using a temporary work-tree; the actual code sequence is probably different for any number of reasons).
Hence:
So, somebody supposedly merged my branch into the master and created corresponding ref. Was it GitHub or Travis?
Given that GitHub will, William of Ockham would suggest there is no need to invoke Travis. :-)
And the other question, can I list all the refs GitHub repo has?
As long as you have access:
$ git ls-remote
(assuming the remote is a GitHub URL) will show all the exposed references. I have not seen a Web interface way to do this, nor found one in my (light) perusal of the GitHub API documentation.