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
diff --git a/scripts/aosp_tag_preupload.py b/scripts/aosp_tag_preupload.py
index 17f5058..bfcdbd6 100755
--- a/scripts/aosp_tag_preupload.py
+++ b/scripts/aosp_tag_preupload.py
@@ -41,11 +41,14 @@
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 @@
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()