diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2023-04-13 21:07:06 +0000 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2023-04-13 21:07:06 +0000 |
commit | 1fefcf27edcac7ebb87c1d3c68bcd9870e3ae78a (patch) | |
tree | 10fad15ba856d4f88259f426571e3f08d341e7a3 /contrib | |
parent | 19764dc143281376ea08e954018479ed10405b72 (diff) | |
download | bitcoin-1fefcf27edcac7ebb87c1d3c68bcd9870e3ae78a.tar.xz |
verify-commits: error and exit cleanly when git is too old.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/verify-commits/verify-commits.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/verify-commits/verify-commits.py b/contrib/verify-commits/verify-commits.py index f301964280..a1fe78a643 100755 --- a/contrib/verify-commits/verify-commits.py +++ b/contrib/verify-commits/verify-commits.py @@ -178,7 +178,20 @@ def main(): allow_unclean = current_commit in unclean_merge_allowed if len(parents) == 2 and check_merge and not allow_unclean: current_tree = subprocess.check_output([GIT, 'show', '--format=%T', current_commit]).decode('utf8').splitlines()[0] - recreated_tree = subprocess.check_output([GIT, "merge-tree", parents[0], parents[1]]).decode('utf8').splitlines()[0] + + # This merge-tree functionality requires git >= 2.38. The + # --write-tree option was added in order to opt-in to the new + # behavior. Older versions of git will not recognize the option and + # will instead exit with code 128. + try: + recreated_tree = subprocess.check_output([GIT, "merge-tree", "--write-tree", parents[0], parents[1]]).decode('utf8').splitlines()[0] + except subprocess.CalledProcessError as e: + if e.returncode == 128: + print("git v2.38+ is required for this functionality.", file=sys.stderr) + sys.exit(1) + else: + raise e + if current_tree != recreated_tree: print("Merge commit {} is not clean".format(current_commit), file=sys.stderr) subprocess.call([GIT, 'diff', recreated_tree, current_tree]) |