Skip to content

Commit

Permalink
update_build_version.py produce deterministic header. (#5426)
Browse files Browse the repository at this point in the history
When building, .git directory may not exist in current
directory (e.g. chromium build), so it will produce
with current timestamp, which becomes non-deterministic build.

Check if repo_path is in git repository and use git info.
Also fix fallback logic when 'git describe' failed.
'git rev-parse HEAD' result was not used because it didn't
update success.
  • Loading branch information
ukai authored Oct 18, 2023
1 parent 5bb5950 commit a9c61d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions utils/update_build_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,11 @@ def describe(repo_path):
successful, returns the output; otherwise returns 'unknown hash, <date>'."""

# if we're in a git repository, attempt to extract version info
if os.path.exists(".git"):

This comment has been minimized.

Copy link
@pmistryNV

pmistryNV Nov 8, 2023

Contributor

what if a build environment doesn't have git at all? This will cause the command_output to fail. This is a bug. We should always check for git

success, output = command_output(["git", "rev-parse", "--show-toplevel"], repo_path)
if success:
success, output = command_output(["git", "describe"], repo_path)
if not success:
output = command_output(["git", "rev-parse", "HEAD"], repo_path)
success, output = command_output(["git", "rev-parse", "HEAD"], repo_path)

if success:
# decode() is needed here for Python3 compatibility. In Python2,
Expand Down

0 comments on commit a9c61d1

Please sign in to comment.