Skip to content

Commit fe519ca

Browse files
committed
workflows: automation: removed redundant code and improved formatting
1 parent bceedb3 commit fe519ca

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

.github/automation/commit-msg-check.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ def __scopeCheck(msg: str):
3131
status = "Message scope: "
3232

3333
if not re.match('^[a-z0-9]+(, [a-z0-9]+)*: ', msg):
34-
print(f"{status} FAILED: Commit message must follow the format <scope>:[ <scope>:] <short description>")
34+
print(f"{status} FAILED: Commit message must follow the format "
35+
"<scope>:[ <scope>:] <short description>")
3536
return False
3637

3738
print(f"{status} OK")
3839
return True
3940

40-
# Ensuring a character limit for the first line.
41+
# Ensure a character limit for the first line.
4142
def __numCharacterCheck(msg: str):
4243
status = "Message length:"
43-
summary = msg.partition("\n")[0]
44-
msgSummaryLen = len(summary)
45-
if msgSummaryLen <= 72:
44+
if len(msg) <= 72:
4645
print(f"{status} OK")
4746
return True
4847
else:
49-
print(f"{status} FAILED: Commit message summary must not exceed 72 characters.")
48+
print(f"{status} FAILED: Commit message summary must not "
49+
"exceed 72 characters.")
5050
return False
5151

5252
def main():
@@ -58,7 +58,8 @@ def main():
5858
head: str = args.head
5959

6060
commit_range = base + ".." + head
61-
messages = subprocess.run(["git", "rev-list", "--format=oneline", commit_range], capture_output=True, text=True).stdout
61+
messages = subprocess.run(["git", "rev-list", "--format=oneline",
62+
commit_range], capture_output=True, text=True).stdout
6263

6364
is_ok = True
6465
for i in messages.splitlines():
@@ -72,7 +73,8 @@ def main():
7273
if is_ok:
7374
print("All commmit messages are formatted correctly. ")
7475
else:
75-
print("Some commit message checks failed. Please align commit messages with Contributing Guidelines and update the PR.")
76+
print("Some commit message checks failed. Please align commit messages "
77+
"with Contributing Guidelines and update the PR.")
7678
exit(1)
7779

7880

0 commit comments

Comments
 (0)