1010import subprocess
1111import sys
1212
13- KEYWORDS = [' fixes' , ' closes' , 're' , ' ref' ]
14- NO_ISSUE = ' [noissue]'
15- STATUSES = [' NEW' , ' ASSIGNED' , ' POST' ]
13+ KEYWORDS = [" fixes" , " closes" , "re" , " ref" ]
14+ NO_ISSUE = " [noissue]"
15+ STATUSES = [" NEW" , " ASSIGNED" , " POST" ]
1616
1717sha = sys .argv [1 ]
18- message = subprocess .check_output ([' git' , ' log' , ' --format=%B' , ' -n 1' , sha ]).decode (' utf-8' )
18+ message = subprocess .check_output ([" git" , " log" , " --format=%B" , " -n 1" , sha ]).decode (" utf-8" )
1919
2020
2121def __check_status (issue ):
22- response = requests .get (' https://pulp.plan.io/issues/{}.json' .format (issue ))
22+ response = requests .get (" https://pulp.plan.io/issues/{}.json" .format (issue ))
2323 response .raise_for_status ()
2424 bug_json = response .json ()
25- status = bug_json [' issue' ][ ' status' ][ ' name' ]
25+ status = bug_json [" issue" ][ " status" ][ " name" ]
2626 if status not in STATUSES :
27- sys .exit ("Error: issue #{issue} has invalid status of {status}. Status must be one of "
28- "{statuses}." .format (issue = issue , status = status , statuses = ", " .join (STATUSES )))
27+ sys .exit (
28+ "Error: issue #{issue} has invalid status of {status}. Status must be one of "
29+ "{statuses}." .format (issue = issue , status = status , statuses = ", " .join (STATUSES ))
30+ )
2931
3032
3133print ("Checking commit message for {sha}." .format (sha = sha [0 :7 ]))
@@ -34,7 +36,7 @@ def __check_status(issue):
3436if NO_ISSUE in message :
3537 print ("Commit {sha} has no issue attached. Skipping issue check" .format (sha = sha [0 :7 ]))
3638else :
37- regex = r' (?:{keywords})[\s:]+#(\d+)' .format (keywords = ('|' ).join (KEYWORDS ))
39+ regex = r" (?:{keywords})[\s:]+#(\d+)" .format (keywords = ("|" ).join (KEYWORDS ))
3840 pattern = re .compile (regex )
3941
4042 issues = pattern .findall (message )
@@ -43,7 +45,9 @@ def __check_status(issue):
4345 for issue in pattern .findall (message ):
4446 __check_status (issue )
4547 else :
46- sys .exit ("Error: no attached issues found for {sha}. If this was intentional, add "
47- " '{tag}' to the commit message." .format (sha = sha [0 :7 ], tag = NO_ISSUE ))
48+ sys .exit (
49+ "Error: no attached issues found for {sha}. If this was intentional, add "
50+ " '{tag}' to the commit message." .format (sha = sha [0 :7 ], tag = NO_ISSUE )
51+ )
4852
4953print ("Commit message for {sha} passed." .format (sha = sha [0 :7 ]))
0 commit comments