Skip to content

Commit bedf09a

Browse files
Revise parsing of commit history to include also GitHub squash commits
1 parent 78d2d22 commit bedf09a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

.github/change_log.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,34 @@ def find_pr_list(start: str, end: str):
6464
"""
6565

6666
# Let git generate the proper pr history
67-
cmd = "git log --merges --oneline " + start + ".." + end
67+
cmd = "git log --oneline " + start + ".." + end
6868
cmd = cmd.split()
6969
output = subprocess.run(cmd, cwd=FOLDER, stdout=subprocess.PIPE)
7070
pr_commits = output.stdout.split(b"\n")
7171

7272
# Fetch ids for all merge requests from PRS
73-
pattern_re = re.compile("(\S+) Merge pull request #\d+ from (\S+)")
74-
uid_re = re.compile("#\d+")
73+
merge_re = re.compile("\S+ Merge pull request #(\d+) from \S+")
74+
squash_re = re.compile("\(#(\d+)\)")
7575

7676
ids = []
7777
for pr in pr_commits:
7878

7979
pr_s = str(pr)
8080

81-
# ignore if doesn't follow the usual pattern
82-
if not pattern_re.fullmatch(pr_s):
83-
continue
81+
# Match agains usual pattern
82+
uid = None
83+
match = merge_re.fullmatch(pr_s)
84+
85+
# Match agains squash pattern
86+
if not match:
87+
match = squash_re.search(pr_s)
88+
89+
# Abort
90+
if not match:
91+
continue
8492

8593
# Extract PR uid
86-
uid = int(uid_re.search(pr_s).group(0)[1:])
94+
uid = int(match.group(1))
8795
ids.append(uid)
8896

8997
return ids

0 commit comments

Comments
 (0)