From 71ea467f7e9022dc4f9c34eb9367981045ba3a83 Mon Sep 17 00:00:00 2001 From: Fumitoshi Ukai Date: Thu, 5 Oct 2023 10:43:29 +0900 Subject: [PATCH] update_build_version.py produce deterministic header. 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. --- utils/update_build_version.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/update_build_version.py b/utils/update_build_version.py index 1d7f565150..ea8020c79d 100755 --- a/utils/update_build_version.py +++ b/utils/update_build_version.py @@ -112,10 +112,11 @@ def describe(repo_path): successful, returns the output; otherwise returns 'unknown hash, '.""" # if we're in a git repository, attempt to extract version info - if os.path.exists(".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,