MCPcopy Create free account
hub / github.com/Cambricon/mlu-ops / valid_commit_msg

Function valid_commit_msg

tools/commitlint.py:75–101  ·  view source on GitHub ↗
(commit_msg, scopes)

Source from the content-addressed store, hash-verified

73 return msg[0:res.span()[0]]
74
75def valid_commit_msg(commit_msg, scopes):
76 res1 = re.match(r'(?P<type>\[\w+\])(?P<scope>\(\w+\))(?P<colon>:)(?P<subject> *\w+)', commit_msg)
77 res2 = re.match(r'(?P<type>\[\w+\])(?P<scope>\(mlu-ops\))(?P<colon>:)(?P<subject> *\w+)', commit_msg)
78 if res1 == None and res2 == None:
79 print("\033[0;35m-- please input standard format for commit: {[type](scope): <subject> }\033[0m")
80 print("\033[0;35m-- the type should be one of: 'Feature', 'Fix', 'Docs', 'TEST', 'WIP' \033[0m")
81 print("\033[0;35m-- the msg_scope should be one of api name 'mluOpXXX' in mlu_op.h or 'mlu-ops' \033[0m")
82 return False
83 else:
84 res = ""
85 if res1 is not None:
86 res = res1
87 else:
88 res = res2
89 msg_type = res.groupdict()['type'].lstrip().rstrip()
90 if msg_type not in types:
91 print("\033[0;35m-- type not match, the type should be one of: 'Feature', 'Fix', 'Docs', 'TEST', 'WIP' \033[0m")
92 print("\033[0;35m-- please input standard format for commit: {[type](scope): <subject> }\033[0m")
93 return False
94
95 msg_scope = res.groupdict()['scope'].lstrip('(').rstrip(')')
96 if msg_scope not in scopes:
97 print("\033[0;35m-- msg_scope not match, the msg_scope should be one of api name 'mluOpXXX' in mlu_op.h\n "
98 " or one of lite api name 'mluXXX' in ./scripts/bangc_kernels_path_config/*.json\n or 'mlu-ops' \033[0m")
99 print("\033[0;35m-- please input standard format for commit: {[type](scope): <subject> }\033[0m")
100 return False
101 return True
102
103def main():
104 print('-- [commit-msg] Checking git-commit-format')

Callers 1

mainFunction · 0.85

Calls 1

matchMethod · 0.80

Tested by

no test coverage detected