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

fix: more friendly reply for /lgtm and /merge by contributor without … #538

Merged
merged 2 commits into from
May 13, 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
4 changes: 3 additions & 1 deletion internal/pkg/externalplugins/lgtm/lgtm.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ func handle(wantLGTM bool, config *tiexternalplugins.Configuration, rc reviewCtx

// Not reviewers but want to add LGTM.
if !reviewers.Has(author) && wantLGTM {
resp := "`/lgtm` is only allowed for the reviewers in [list](" + tichiURL + ")."
resp := "Thanks for your review. "
resp += "The bot only counts `/lgtm` from reviewers and higher roles in [list](" + tichiURL + "), "
resp += "but you're still welcome to leave your comments."
log.Infof("Reply /lgtm request in comment: \"%s\"", resp)
return gc.CreateComment(org, repo, number, tiexternalplugins.FormatResponseRaw(body, htmlURL, author, resp))
}
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/externalplugins/lgtm/lgtm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestLGTMIssueAndReviewComment(t *testing.T) {
commenter: "not-in-the-org",
shouldToggle: false,
shouldComment: true,
expectComment: "org/repo#5:@not-in-the-org: `/lgtm` is only allowed for the reviewers in [list](https://tichiWebLink/repos/org/repo/pulls/5/owners).\n\n<details>\n\nIn response to [this](<url>):\n\n>/lgtm\n\n\nInstructions for interacting with me using PR comments are available [here](https://prow.tidb.io/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.\n</details>",
expectComment: "org/repo#5:@not-in-the-org: Thanks for your review. The bot only counts `/lgtm` from reviewers and higher roles in [list](https://tichiWebLink/repos/org/repo/pulls/5/owners), but you're still welcome to leave your comments.\n\n<details>\n\nIn response to [this](<url>):\n\n>/lgtm\n\n\nInstructions for interacting with me using PR comments are available [here](https://prow.tidb.io/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.\n</details>",
},
{
name: "lgtm cancel by reviewer collab2",
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestLGTMIssueAndReviewComment(t *testing.T) {
currentLabel: lgtmTwo,
shouldToggle: false,
shouldComment: true,
expectComment: "org/repo#5:@not-in-the-org: `/lgtm` is only allowed for the reviewers in [list](https://tichiWebLink/repos/org/repo/pulls/5/owners).\n\n<details>\n\nIn response to [this](<url>):\n\n>/lgtm \n\n\nInstructions for interacting with me using PR comments are available [here](https://prow.tidb.io/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.\n</details>",
expectComment: "org/repo#5:@not-in-the-org: Thanks for your review. The bot only counts `/lgtm` from reviewers and higher roles in [list](https://tichiWebLink/repos/org/repo/pulls/5/owners), but you're still welcome to leave your comments.\n\n<details>\n\nIn response to [this](<url>):\n\n>/lgtm \n\n\nInstructions for interacting with me using PR comments are available [here](https://prow.tidb.io/command-help). If you have questions or suggestions related to my behavior, please file an issue against the [ti-community-infra/tichi](https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository.\n</details>",
},
{
name: "lgtm comment by reviewer collab1, lgtm twice",
Expand Down
4 changes: 3 additions & 1 deletion internal/pkg/externalplugins/merge/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ func handle(wantMerge bool, config *tiexternalplugins.Configuration, rc reviewCt

// Not committers but want merge.
if !committers.Has(author) && wantMerge {
resp := "`/merge` is only allowed for the committers in [list](" + tichiURL + ")."
resp := "`/merge` is only allowed for the committers, "
resp += "you can assign this pull request to the committer in [list](" + tichiURL + ") "
resp += "by filling `/assign @committer` in the comment to help merge this pull request."
log.Infof("Reply /merge request in comment: \"%s\"", resp)
return gc.CreateComment(org, repoName, number, tiexternalplugins.FormatResponseRaw(body, htmlURL, author, resp))
}
Expand Down