Skip to content

Commit

Permalink
Get the real commit hash, not the bundle hash
Browse files Browse the repository at this point in the history
It's extracted from the commit message of the bundle.
  • Loading branch information
camelid committed May 31, 2020
1 parent 5dae012 commit 02d69a0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/servo/command_base.py
Expand Up @@ -734,9 +734,16 @@ def build_env(self, hosts_file_path=None, target=None, is_build=False, test_unit

git_info = []
if os.path.isdir('.git') and is_build:
git_sha = subprocess.check_output([
'git', 'rev-parse', '--short', 'HEAD'
# Get the subject of the bundle commit
git_bundle_subject = subprocess.check_output([
'git', 'show', '-s', '--format=%s', 'HEAD'
]).strip()
# Get the SHA-1 from the bundle subject: "Shallow version of commit {sha1}"
git_sha = git_bundle_subject.split(' ')[-1]
# Verify that it's a valid commit
# NOTE: this will pass even if `git_sha` is 'master' or another branch or ref
subprocess.check_call('git', 'cat-file', 'commit', git_sha)

git_is_dirty = bool(subprocess.check_output([
'git', 'status', '--porcelain'
]).strip())
Expand Down

0 comments on commit 02d69a0

Please sign in to comment.