-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcherrypick_cl_hook.py
More file actions
executable file
·38 lines (30 loc) · 1.1 KB
/
cherrypick_cl_hook.py
File metadata and controls
executable file
·38 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
import argparse
import sys
def main():
parser = argparse.ArgumentParser(
description='Check if the cherrypick_cl.py script has been run')
parser.add_argument('commit_msg', type=str, help='commit message')
parser.add_argument('commit_files', type=str, nargs='*',
help='files changed in the commit')
args = parser.parse_args()
commit_msg = args.commit_msg
commit_files = args.commit_files
patch_list = []
for file in commit_files:
if file.endswith('.patch'):
patch_list.append(file)
if len(patch_list) == 0:
return 0
for line in commit_msg.splitlines():
line = line.strip()
if line.startswith("This change is generated automatically by the script"):
return 0
print('This change seems to manually add/change the following patch files:')
for file in patch_list:
print(file)
print('Please run llvm_android/cherrypick_cl.py script to cherry pick changes instead.')
return 1
if __name__ == '__main__':
exit_code = main()
sys.exit(exit_code)