Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the real commit hash for `./servo --version`, not the bundle hash #26720

Merged
merged 4 commits into from Jun 6, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Don't fail if run on non-bundle commit

  • Loading branch information
camelid committed May 31, 2020
commit e362538bf23fe458ce8a117770a58afa3799798d
@@ -734,15 +734,27 @@ 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:
# Get the subject of the bundle commit
git_bundle_subject = subprocess.check_output([
# Get the subject of the commit
git_commit_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_sha = None
# Check if it's a bundle commit
if git_commit_subject.startswith("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(' ')[-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'
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.