Skip to content
Permalink
Browse files

`git show --pretty=%P` sometimes prints a diff. Use `git cat-file` in…

…stead.
  • Loading branch information...
SimonSapin authored and jdm committed May 23, 2019
1 parent 0ed6cdb commit 3d0be552d82f11c5358c3e35298eda18223688ad
Showing with 12 additions and 8 deletions.
  1. +1 −3 .taskcluster.yml
  2. +11 −5 etc/taskcluster/decisionlib.py
@@ -30,12 +30,10 @@ tasks:
- '--login'
- '-e'
- '-c'
# A depth of 25 is used to work around `git show` ignoring
# any provided format with a depth of 1.
- >-
git init repo &&
cd repo &&
git fetch --depth 25 "$GIT_URL" "$GIT_REF" &&
git fetch --depth 1 "$GIT_URL" "$GIT_REF" &&
git reset --hard "$GIT_SHA" &&
python3 etc/taskcluster/decision_task.py
in:
@@ -64,11 +64,17 @@ def task_id(self):
# the merge parents rather that the actual sha of the merge commit. This ensures that tasks
# can be reused if the tree is in an identical state. Otherwise, if the head commit is
# not a merge, we can rely on the head commit sha for that purpose.
merge_parents_output = subprocess.check_output(["git", "show", "--format=%P", "HEAD"])
merge_parents = merge_parents_output.decode("utf8").strip().split(' ')
self._task_id = self.git_sha
if len(merge_parents) > 1:
self._task_id = '-'.join(merge_parents)
raw_commit = subprocess.check_output(["git", "cat-file", "commit", "HEAD"])
parent_commits = [
value.decode("utf8")
for line in raw_commit.split(b"\n")
for key, _, value in [line.partition(b" ")]
if key == b"parent"
]
if len(parent_commits) > 1:
self._task_id = "-".join(parent_commits) # pragma: no cover
else:
self._task_id = self.git_sha # pragma: no cover
return self._task_id

def git_sha_is_current_head(self):

0 comments on commit 3d0be55

Please sign in to comment.
You can’t perform that action at this time.