include squashed PRs in release notes

Signed-off-by: Alkin Tezuysal <alkin.tezuysal@gmail.com>
This commit is contained in:
Alkin Tezuysal 2021-06-14 10:55:39 +03:00
Родитель 4449aa9ccd
Коммит f947bd1c0f
2 изменённых файлов: 17 добавлений и 10 удалений

Просмотреть файл

@ -94,6 +94,7 @@ func loadMergedPRs(from, to string) (prs []string, authors []string, commitCount
func parseGitLog(s string) (prs []string, authorCommits []string, commitCount int, err error) {
rx := regexp.MustCompile(`(.+)\t(.+)\t(.+)\t(.+)`)
mergePR := regexp.MustCompile(`Merge pull request #(\d+)`)
squashPR := regexp.MustCompile(`\(#(\d+)\)`)
authMap := map[string]string{} // here we will store email <-> gh user mappings
lines := strings.Split(s, "\n")
for _, line := range lines {
@ -112,13 +113,19 @@ func parseGitLog(s string) (prs []string, authorCommits []string, commitCount in
continue
}
if len(parents) > lengthOfSingleSHA {
// if we have two parents, it means this is a merge commit. we only count non-merge commits
continue
if len(parents) <= lengthOfSingleSHA {
// we have a single parent, and the commit counts
commitCount++
if _, exists := authMap[authorEmail]; !exists {
authMap[authorEmail] = sha
}
}
commitCount++
if _, exists := authMap[authorEmail]; !exists {
authMap[authorEmail] = sha
squashed := squashPR.FindStringSubmatch(title)
if len(squashed) == 2 {
// this is a merged PR. remember the PR #
prs = append(prs, squashed[1])
continue
}
}

Просмотреть файл

@ -98,9 +98,9 @@ aquarapTEST@gmail.com Fix mysql80 docker build with dep. a28591577b8d432b9c5d78a
TEST@planetscale.com Revert "docker/lite/install_dependencies.sh: Upgrade MySQL 8 to 8.0.24" 7858ff46545cff749b3663c92ae90ef27a5dfbc2 27a5dfbc2
TEST@planetscale.com docker/lite/install_dependencies.sh: Upgrade MySQL 8 to 8.0.24 c91d46782933292941a846fef2590ff1a6fa193f a6fa193f`
prs, authorCommits, count, err := parseGitLog(in)
prs, authorCommits, nonMergeCommits, err := parseGitLog(in)
require.NoError(t, err)
assert.Equal(t, []string{"7629", "7831", "7912", "7943", "7951", "7959", "7964", "7968", "7970"}, prs)
assert.Equal(t, []string{"385d0b327", "3b744e782", "4a0a943b0", "538709da5", "616f5562c", "6b9a731a2", "e5242a88a", "edac2baf8"}, authorCommits)
assert.Equal(t, 28, count)
assert.Equal(t, prs, []string{"7629", "7831", "7912", "7934", "7943", "7951", "7959", "7964", "7968", "7970"})
assert.Equal(t, authorCommits, []string{"385d0b327", "3b744e782", "4a0a943b0", "538709da5", "616f5562c", "6b9a731a2", "e5242a88a", "edac2baf8"})
assert.Equal(t, 28, nonMergeCommits)
}