summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/git-cherry-gerrit.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/scripts/git-cherry-gerrit.py b/scripts/git-cherry-gerrit.py
index df7e0c02..bb8235fa 100755
--- a/scripts/git-cherry-gerrit.py
+++ b/scripts/git-cherry-gerrit.py
@@ -52,8 +52,12 @@ def main() -> None:
if len(sys.argv) >= 5:
whitelist_file = sys.argv[4]
+ hash_length = 0
+ if len(sys.argv) >= 6:
+ hash_length = int(sys.argv[5])
+
if not cherry_from:
- print("Usage: git-cherry-gerrit.py cherry_from cherry_to [branch_point_from] [whitelist_file]")
+ print("Usage: git-cherry-gerrit.py cherry_from cherry_to [branch_point_from] [whitelist_file] [hash_length]")
sys.exit(1)
merge_base = from_pipe(["git", "merge-base", cherry_from, cherry_to])
@@ -77,7 +81,11 @@ def main() -> None:
whitelist = stream.read().strip().split("\n")
for from_hash in from_hashes:
changeid = get_change_id(git_cat_file, from_hash)
- pretty = from_pipe(["git", "--no-pager", "log", "-1", "--format=format:%h%x09%an%x09%s%x0a", from_hash])
+ if hash_length:
+ # Avoid '%h' that may not be exactly hash_length characters, but out stored whitelist has that length.
+ pretty = from_hash[:hash_length] + "\t" + from_pipe(["git", "--no-pager", "log", "-1", "--format=format:%an%x09%s%x0a", from_hash])
+ else:
+ pretty = from_pipe(["git", "--no-pager", "log", "-1", "--format=format:%h%x09%an%x09%s%x0a", from_hash])
if not changeid:
if not whitelist_file or not [entry for entry in whitelist if pretty in entry]:
print("WARNING: commit '" + pretty + "' has no Change-Id, assuming it has to be cherry-picked.")