From 85af7f48e3097b0da7368c992ef91c996aa37ad2 Mon Sep 17 00:00:00 2001 From: Brad Ebinger Date: Thu, 29 Apr 2021 20:36:47 +0000 Subject: [PATCH] Fix repo hook error upon upload Some lines of the presubmit message are coming back as bytes instead of a string using pyton3. So, ensure each line is a str before checking contents. Also, send code 77 back to ensure that the error message is actually printed Test: repo upload Change-Id: Ieecd6228318b3001098ac45e4767b8bf46826387 --- scripts/aosp_tag_preupload.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/aosp_tag_preupload.py b/scripts/aosp_tag_preupload.py index 17f50580b..bfcdbd6a9 100755 --- a/scripts/aosp_tag_preupload.py +++ b/scripts/aosp_tag_preupload.py @@ -41,11 +41,14 @@ def main(): commit_msg = subprocess.check_output(["git", "show", sys.argv[1], "--no-notes"]) for commit_line in commit_msg.splitlines(): - if re.search(AOSP_COMMIT_TAG_REGEX, commit_line, re.IGNORECASE): - _check_aosp_message(commit_line) + # Some lines in the commit message will be given to us as bytes + commit_line_str = str(commit_line) + if re.search(AOSP_COMMIT_TAG_REGEX, str(commit_line_str), re.IGNORECASE): + _check_aosp_message(commit_line_str) print(ERROR_MESSAGE) - sys.exit(0) + # Print the warning, but do not fail the presubmit check. + sys.exit(77) def _is_in_aosp(): branch_info = subprocess.check_output(["git", "branch", "-vv"]) @@ -59,7 +62,8 @@ def _check_aosp_message(aosp_line): sys.exit(0) print(ERROR_MESSAGE) - sys.exit(0) + # Print the warning, but do not fail the presubmit check. + sys.exit(77) if __name__ == '__main__': main()