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 all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -734,9 +734,28 @@ 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 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())
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.