Travis provides
(Pdb) rich.inspect(build['commit'])
│ │ { │ │
│ │ │ '@type': 'commit', │ │
│ │ │ '@representation': 'minimal', │ │
│ │ │ 'id': 556084708, │ │
│ │ │ 'sha': '03f35ebbd696894fe61c2fff46217bff60019db8', │ │
│ │ │ 'ref': 'refs/pull/68/merge', │ │
│ │ │ 'message': 'Fill in `{commit}` for Travis PR builds by querying GitHub', │ │
│ │ │ 'compare_url': 'https://github.com/con/tinuous/pull/68', │ │
│ │ │ 'committed_at': '2021-06-01T16:23:50Z' │ │
│ │ }
and to deduce the HEAD commit we have
pr = self.ghrepo.get_pull(build["pull_request_number"])
if pr.merge_commit_sha == build["commit"]["sha"]:
return pr.head.sha
but for a now merged merged PR #68 we have now b7ab0f3 in the master as pr.merge_commit_sha not the (build["commit"]["sha"]) 03f35eb as it was the merge commit whenever PR was not yet merged.
There is a ticket @jwodder filed with Travis to have HEAD {commit} to be also be part of the Travis API record, but it is still unresolved. So the question is either there is another way , and it seems to be via query to github about parents of the PR merge head commit as known to Travis:
$> curl --silent https://api.github.com/repos/con/tinuous/commits/03f35ebbd696894fe61c2fff46217bff60019db8 | jq '.parents'
[
{
"sha": "52c92e0b0cc683e53ebde25f7ec32cd98434e2ba",
"url": "https://api.github.com/repos/con/tinuous/commits/52c92e0b0cc683e53ebde25f7ec32cd98434e2ba",
"html_url": "https://github.com/con/tinuous/commit/52c92e0b0cc683e53ebde25f7ec32cd98434e2ba"
},
{
"sha": "c30b87e74a47cd360306f0674f793b14c79843da",
"url": "https://api.github.com/repos/con/tinuous/commits/c30b87e74a47cd360306f0674f793b14c79843da",
"html_url": "https://github.com/con/tinuous/commit/c30b87e74a47cd360306f0674f793b14c79843da"
}
]
so I guess we could take those and if any matches the pr.head.sha - we have unambigous winner. Otherwise -- could we rely on the fact that first commit would be from the target branch or do some other check or it would not even be needed?
Travis provides
and to deduce the HEAD commit we have
but for a now merged merged PR #68 we have now b7ab0f3 in the master as
pr.merge_commit_shanot the (build["commit"]["sha"]) 03f35eb as it was the merge commit whenever PR was not yet merged.There is a ticket @jwodder filed with Travis to have HEAD
{commit}to be also be part of the Travis API record, but it is still unresolved. So the question is either there is another way , and it seems to be via query to github about parents of the PR merge head commit as known to Travis:so I guess we could take those and if any matches the
pr.head.sha- we have unambigous winner. Otherwise -- could we rely on the fact that first commit would be from the target branch or do some other check or it would not even be needed?