Skip to content

Commit

Permalink
cmd/cueckoo: drop "thank you to" section
Browse files Browse the repository at this point in the history
GitHub releases now show the users who contributed towards a release
at the bottom of the release UI, with their profile pictures,
driven by the usernames @-mentioned in the markdown release notes.

We already mention every contributor for every commit via the dropdown,
so we can drop the "thank you to" section and avoid duplication.

While here, make the commit list an expandable dropdown UI widget,
which I had been manually editing in previous releases.
It's easier for the tool to do this itself directly.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I72eec9e569c2f8a197b0f5ff139bf12e7c8041dc
Dispatch-Trailer: {"type":"trybot","CL":1178234,"patchset":1,"ref":"refs/changes/34/1178234/1","targetBranch":"master"}
  • Loading branch information
mvdan authored and cueckoo committed Mar 13, 2024
1 parent 3762cbe commit d827794
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions cmd/cueckoo/cmd/releaselog.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package cmd

import (
"fmt"
"sort"
"strings"

"github.com/google/go-github/v53/github"
Expand Down Expand Up @@ -54,8 +53,9 @@ func releaseLog(cmd *Command, args []string) error {
cmd.Flags()

if len(args) != 2 {
return fmt.Errorf("expected exactly two args which will be interpreted like git log $1..$2")
return fmt.Errorf("expected exactly two args which will be interpreted like git log $1..$2, like: v0.8.0-alpha.1 master")
}
fromRef, toRef := args[0], args[1]

cfg, err := loadConfig(cmd.Context())
if err != nil {
Expand All @@ -67,11 +67,9 @@ func releaseLog(cmd *Command, args []string) error {
Page: 1,
}

authors := make(map[string]bool)

// Gather commits and authors
for {
res, resp, err := cfg.githubClient.Repositories.CompareCommits(cmd.Context(), cfg.githubOwner, cfg.githubRepo, args[0], args[1], opts)
res, resp, err := cfg.githubClient.Repositories.CompareCommits(cmd.Context(), cfg.githubOwner, cfg.githubRepo, fromRef, toRef, opts)
// Check for any errors
if err != nil {
return fmt.Errorf("failed to compare commits: %w", err)
Expand All @@ -88,32 +86,15 @@ func releaseLog(cmd *Command, args []string) error {
opts.Page++
}

// Author summary
for _, v := range commits {
author := v.GetAuthor().GetLogin()
authors[author] = true
}
var authorList []string
for k := range authors {
authorList = append(authorList, "@"+k)
}
sort.Strings(authorList)
if len(authorList) > 1 {
authorList[len(authorList)-1] = "and " + authorList[len(authorList)-1]
}
fmt.Printf("Thank you to %s for contributing to this release!\n", strings.Join(authorList, ", "))

// Clear line before Changelog for readability
fmt.Println("")

fmt.Println("## Changelog")
fmt.Printf("<details>\n\n<summary><b>Full list of changes since %s</b></summary>\n\n", fromRef)
for i := len(commits) - 1; i >= 0; i-- {
commit := commits[i]
msg := commit.Commit.GetMessage()
author := commit.GetAuthor().GetLogin()
summary, _, _ := strings.Cut(msg, "\n")
fmt.Printf("* %s by @%s in %s\n", summary, author, commit.GetSHA())
}
fmt.Printf("\n</details>\n")

return nil
}

0 comments on commit d827794

Please sign in to comment.