diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-06-06 11:40:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-06 11:40:22 -0400 |
commit | 51fd0e83e96a405ee48c7d72906a159ff1ba919f (patch) | |
tree | 91229269bf3f3d3824037f7766939faf77ad4567 /python/servo | |
parent | 2f6efcbc3a535ed6718457b2f8ab5c78002ca09c (diff) | |
parent | 2e5ad99022b9107631c42f976fb5488ca295f7c0 (diff) | |
download | servo-51fd0e83e96a405ee48c7d72906a159ff1ba919f.tar.gz servo-51fd0e83e96a405ee48c7d72906a159ff1ba919f.zip |
Auto merge of #26720 - camelid:real-version-hash, r=SimonSapin
Show the real commit hash for `./servo --version`, not the bundle hash
<!-- Please describe your changes on the following line: -->
Show the real commit hash of the build when run on a bundle commit, rather than showing the bundle's hash.
It gets the real commit hash by extracting it from the bundle commit message, which has the form `Shallow version of commit {sha1}`, where `{sha1}` is the real commit hash.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors (edits Python code, no Rust changes)
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #26386 (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because this only changes infrastructure
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'python/servo')
-rw-r--r-- | python/servo/command_base.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py index e3942ef66e0..db9f550e61d 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -734,9 +734,28 @@ install them, let us know by filing a bug!") 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 commit + git_commit_subject = subprocess.check_output([ + 'git', 'show', '-s', '--format=%s', 'HEAD' ]).strip() + + git_sha = None + # Check if it's a bundle commit + if git_commit_subject.startswith(b"Shallow version of commit "): + # This is a bundle commit + # Get the SHA-1 from the bundle subject: "Shallow version of commit {sha1}" + git_sha = git_commit_subject.split(b' ')[-1].strip() + # Shorten hash + # NOTE: Partially verifies the hash, but it will still pass if it's, e.g., a tree + git_sha = subprocess.check_output([ + 'git', 'rev-parse', '--short', git_sha + ]) + else: + # This is a regular commit + git_sha = subprocess.check_output([ + 'git', 'rev-parse', '--short', 'HEAD' + ]).strip() + git_is_dirty = bool(subprocess.check_output([ 'git', 'status', '--porcelain' ]).strip()) |