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

cmd/gopherbot: change issue notification comment to include author name #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions cmd/gopherbot/gopherbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ func (b *gopherbot) closeStaleWaitingForInfo(ctx context.Context) error {

}

// cl2issue writes "Change https://golang.org/issue/NNNN mentions this issue"\
// cl2issue writes "Change https://golang.org/issue/NNNN by 'author' mentions this issue"\
// and the change summary on GitHub when a new Gerrit change references a GitHub issue.
func (b *gopherbot) cl2issue(ctx context.Context) error {
monthAgo := time.Now().Add(-30 * 24 * time.Hour)
Expand All @@ -831,7 +831,7 @@ func (b *gopherbot) cl2issue(ctx context.Context) error {
continue
}
hasComment := false
substr := fmt.Sprintf("%d mentions this issue", cl.Number)
substr := fmt.Sprintf("Change https://golang.org/cl/%d mentions this issue.", cl.Number)
gi.ForeachComment(func(c *maintner.GitHubComment) error {
if strings.Contains(c.Body, substr) {
hasComment = true
Expand All @@ -841,7 +841,9 @@ func (b *gopherbot) cl2issue(ctx context.Context) error {
})
if !hasComment {
printIssue("cl2issue", gi)
msg := fmt.Sprintf("Change https://golang.org/cl/%d mentions this issue: `%s`", cl.Number, cl.Commit.Summary())

msg := fmt.Sprintf("Change https://golang.org/cl/%d by %s mentions this issue: `%s`", cl.Number, strings.Split("cl.Commit.Author", "<")[0], cl.Commit.Summary())

if err := b.addGitHubComment(ctx, "golang", "go", gi.Number, msg); err != nil {
return err
}
Expand Down