From ff25c293af9480510c02925613a36049a6dfe76d Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Sat, 8 Jun 2024 13:10:28 +0800 Subject: [PATCH 1/3] cmd/gerritbot: flag common PR mistakes consider backport This is CL avoid report The commit title should start with the primary affected package name followed by a colon, like "net/http: improve [...]". for [release-branch.go1.22] os/exec: on Windows look for extensions in Run if not already done For #61573 --- cmd/gerritbot/internal/rules/rules.go | 4 ++++ cmd/gerritbot/internal/rules/rules_test.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/cmd/gerritbot/internal/rules/rules.go b/cmd/gerritbot/internal/rules/rules.go index 41429ff463..fb9c78d773 100644 --- a/cmd/gerritbot/internal/rules/rules.go +++ b/cmd/gerritbot/internal/rules/rules.go @@ -115,6 +115,10 @@ var ruleGroups = [][]rule{ // We also allow things like "go/types, types2: ..." (but not "hello, fun world: ..."). return "", "" } + if change.Repo == "go" && strings.Contains(start, "release-branch.go1.22") { + // Consider backport. + return "", "" + } return finding, commitMessageAdvice }, }, diff --git a/cmd/gerritbot/internal/rules/rules_test.go b/cmd/gerritbot/internal/rules/rules_test.go index f95621cf5a..5f5a8d33b6 100644 --- a/cmd/gerritbot/internal/rules/rules_test.go +++ b/cmd/gerritbot/internal/rules/rules_test.go @@ -55,6 +55,11 @@ The commit title and commit message body come from the GitHub PR title and descr The commit title and commit message body come from the GitHub PR title and description, and must be edited in the GitHub web interface (not via git). For instructions, see [here](https://go.dev/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message). For guidelines on commit messages for the Go project, see [here](https://go.dev/doc/contribute#commit_messages). `, }, + { + title: `[release-branch.go1.22] os/exec: on Windows look for extensions in Run if not already done`, + body: goodCommitBody, + want: "", + }, } for _, tt := range tests { t.Run("title "+tt.title, func(t *testing.T) { From ecd59aac54cc2ef115a7a0caacd356f8fc55019e Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Mon, 10 Jun 2024 22:59:41 +0800 Subject: [PATCH 2/3] n --- cmd/gerritbot/internal/rules/rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gerritbot/internal/rules/rules.go b/cmd/gerritbot/internal/rules/rules.go index fb9c78d773..ead84a5d02 100644 --- a/cmd/gerritbot/internal/rules/rules.go +++ b/cmd/gerritbot/internal/rules/rules.go @@ -115,7 +115,7 @@ var ruleGroups = [][]rule{ // We also allow things like "go/types, types2: ..." (but not "hello, fun world: ..."). return "", "" } - if change.Repo == "go" && strings.Contains(start, "release-branch.go1.22") { + if change.Repo == "go" && strings.Contains(start, "release-branch") { // Consider backport. return "", "" } From d4f6ba349d70bdda24911bb99852558dd673b2cf Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Tue, 11 Jun 2024 01:03:14 +0800 Subject: [PATCH 3/3] n --- cmd/gerritbot/gerritbot.go | 10 +++++++++- cmd/gerritbot/internal/rules/rules.go | 4 ---- cmd/gerritbot/internal/rules/rules_test.go | 5 ----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/gerritbot/gerritbot.go b/cmd/gerritbot/gerritbot.go index e9417bb6df..7781e27925 100644 --- a/cmd/gerritbot/gerritbot.go +++ b/cmd/gerritbot/gerritbot.go @@ -789,7 +789,15 @@ Please visit Gerrit at %s. return err } - if newCL { + checkCommonMistakes := newCL + if releaseOrInternalBranch := strings.HasPrefix(pr.Base.GetRef(), "release-branch.") || + strings.HasPrefix(pr.Base.GetRef(), "internal-branch."); releaseOrInternalBranch { + // The rules for commit messages on release and internal branches + // are different, so don't use the same rules for checking for + // common mistakes. + checkCommonMistakes = false + } + if checkCommonMistakes { // Check if we spot any problems with the CL according to our internal // set of rules, and if so, add an unresolved comment to Gerrit. // If the author responds to this, it also helps a reviewer see the author has diff --git a/cmd/gerritbot/internal/rules/rules.go b/cmd/gerritbot/internal/rules/rules.go index ead84a5d02..41429ff463 100644 --- a/cmd/gerritbot/internal/rules/rules.go +++ b/cmd/gerritbot/internal/rules/rules.go @@ -115,10 +115,6 @@ var ruleGroups = [][]rule{ // We also allow things like "go/types, types2: ..." (but not "hello, fun world: ..."). return "", "" } - if change.Repo == "go" && strings.Contains(start, "release-branch") { - // Consider backport. - return "", "" - } return finding, commitMessageAdvice }, }, diff --git a/cmd/gerritbot/internal/rules/rules_test.go b/cmd/gerritbot/internal/rules/rules_test.go index 5f5a8d33b6..f95621cf5a 100644 --- a/cmd/gerritbot/internal/rules/rules_test.go +++ b/cmd/gerritbot/internal/rules/rules_test.go @@ -55,11 +55,6 @@ The commit title and commit message body come from the GitHub PR title and descr The commit title and commit message body come from the GitHub PR title and description, and must be edited in the GitHub web interface (not via git). For instructions, see [here](https://go.dev/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message). For guidelines on commit messages for the Go project, see [here](https://go.dev/doc/contribute#commit_messages). `, }, - { - title: `[release-branch.go1.22] os/exec: on Windows look for extensions in Run if not already done`, - body: goodCommitBody, - want: "", - }, } for _, tt := range tests { t.Run("title "+tt.title, func(t *testing.T) {