Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include squashed PRs in release notes #8326

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions go/tools/release-notes/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down
8 changes: 4 additions & 4 deletions go/tools/release-notes/release_notes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}