Skip to content

Commit ac98cbf

Browse files
authored
fix(internal/pkg/externalplugins/cherrypicker): do not change commit message (#1188)
1 parent 2c387de commit ac98cbf

File tree

17 files changed

+210
-129
lines changed

17 files changed

+210
-129
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v3
1919
- name: golangci-lint
20-
uses: golangci/golangci-lint-action@v3
20+
uses: golangci/golangci-lint-action@v6.1.0
2121
with:
22-
version: v1.51.0
22+
version: v1.59.1
2323
args: --timeout=500s

.golangci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ linters:
22
disable-all: true
33
enable:
44
- bodyclose
5-
- deadcode
6-
- depguard
75
- dupl
86
- gochecknoinits
97
- gocritic
@@ -22,10 +20,8 @@ linters:
2220
- rowserrcheck
2321
- exportloopref
2422
- staticcheck
25-
- structcheck
2623
- typecheck
2724
- unconvert
2825
- unparam
29-
- varcheck
3026
- whitespace
31-
- errcheck
27+
- errcheck

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ staticcheck: tools/bin/golangci-lint
5454
tools/bin/golangci-lint run $$($(PACKAGE_DIRECTORIES)) --timeout 500s
5555

5656
tools/bin/golangci-lint:
57-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.41.1
57+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ./tools/bin v1.59.1
5858

5959
label-dumpling-checks:
6060
@echo "label-dumpling checks"

internal/pkg/externalplugins/blunderbuss/blunderbuss.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ func handle(gc githubClient, opts *tiexternalplugins.TiCommunityBlunderbuss, rep
225225
}
226226

227227
// Always seed random!
228-
//nolint: staticcheck
229228
rand.Seed(time.Now().UTC().UnixNano())
230229
// List the contributors of the changes.
231230
contributors, err := listChangesContributors(gc, repo.Owner.Login, repo.Name, pr.Number, log)

internal/pkg/externalplugins/cherrypicker/cherrypicker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ func (s *Server) handle(logger *logrus.Entry, requestor string,
646646
}
647647

648648
// Try git cherry-pick.
649-
cherrypick := ex.Command("git", "cherry-pick", "-m", "1", *pr.MergeSHA)
649+
cherrypick := ex.Command("git", "cherry-pick", "-m", "1", "--cleanup=verbatim", *pr.MergeSHA)
650650
cherrypick.SetDir(dir)
651651
out, err = cherrypick.CombinedOutput()
652652
if err != nil {

internal/pkg/externalplugins/cherrypicker/cherrypicker_invite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func TestInviteIC(t *testing.T) {
203203
BotUser: botUser,
204204
GitClient: c,
205205
ConfigAgent: ca,
206-
Push: func(forkName, newBranch string, force bool) error { return nil },
206+
Push: func(_, _ string, _ bool) error { return nil },
207207
GitHubClient: ghc,
208208
WebhookSecretGenerator: getSecret,
209209
GitHubTokenGenerator: getGithubToken,

internal/pkg/externalplugins/cherrypicker/cherrypicker_test.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ type fghc struct {
109109
collaborators []string
110110
}
111111

112-
func (f *fghc) GetSingleCommit(org, repo, sha string) (github.RepositoryCommit, error) {
112+
func (f *fghc) GetSingleCommit(_, _, sha string) (github.RepositoryCommit, error) {
113113
f.Lock()
114114
defer f.Unlock()
115115
return f.commits[sha], nil
116116
}
117117

118-
func (f *fghc) AddLabels(org, repo string, number int, labels ...string) error {
118+
func (f *fghc) AddLabels(_, _ string, number int, labels ...string) error {
119119
f.Lock()
120120
defer f.Unlock()
121121
for i := range f.prs {
@@ -128,7 +128,7 @@ func (f *fghc) AddLabels(org, repo string, number int, labels ...string) error {
128128
return nil
129129
}
130130

131-
func (f *fghc) AssignIssue(org, repo string, number int, logins []string) error {
131+
func (f *fghc) AssignIssue(_, _ string, number int, logins []string) error {
132132
f.Lock()
133133
defer f.Unlock()
134134
var users []github.User
@@ -143,19 +143,19 @@ func (f *fghc) AssignIssue(org, repo string, number int, logins []string) error
143143
return nil
144144
}
145145

146-
func (f *fghc) GetPullRequest(org, repo string, number int) (*github.PullRequest, error) {
146+
func (f *fghc) GetPullRequest(string, string, int) (*github.PullRequest, error) {
147147
f.Lock()
148148
defer f.Unlock()
149149
return f.pr, nil
150150
}
151151

152-
func (f *fghc) GetPullRequestPatch(org, repo string, number int) ([]byte, error) {
152+
func (f *fghc) GetPullRequestPatch(string, string, int) ([]byte, error) {
153153
f.Lock()
154154
defer f.Unlock()
155155
return f.patch, nil
156156
}
157157

158-
func (f *fghc) GetPullRequests(org, repo string) ([]github.PullRequest, error) {
158+
func (f *fghc) GetPullRequests(string, string) ([]github.PullRequest, error) {
159159
f.Lock()
160160
defer f.Unlock()
161161
return f.prs, nil
@@ -172,13 +172,13 @@ func (f *fghc) CreateComment(org, repo string, number int, comment string) error
172172
return nil
173173
}
174174

175-
func (f *fghc) GetRepo(owner, name string) (github.FullRepo, error) {
175+
func (f *fghc) GetRepo(_, _ string) (github.FullRepo, error) {
176176
f.Lock()
177177
defer f.Unlock()
178178
return github.FullRepo{}, nil
179179
}
180180

181-
func (f *fghc) EnsureFork(forkingUser, org, repo string) (string, error) {
181+
func (f *fghc) EnsureFork(_, _, repo string) (string, error) {
182182
if repo == "changeme" {
183183
return "changed", nil
184184
}
@@ -188,7 +188,7 @@ func (f *fghc) EnsureFork(forkingUser, org, repo string) (string, error) {
188188
return repo, nil
189189
}
190190

191-
func (f *fghc) IsMember(org, user string) (bool, error) {
191+
func (f *fghc) IsMember(_, user string) (bool, error) {
192192
f.Lock()
193193
defer f.Unlock()
194194

@@ -200,15 +200,15 @@ func (f *fghc) IsMember(org, user string) (bool, error) {
200200
}
201201
}
202202

203-
func (f *fghc) IsCollaborator(org, repo, user string) (bool, error) {
203+
func (f *fghc) IsCollaborator(_, _, user string) (bool, error) {
204204
if strings.Contains(user, patternErrWhenIsCollaborator) {
205205
return false, errors.New("fake error")
206206
}
207207

208208
return sets.NewString(f.collaborators...).Has(user), nil
209209
}
210210

211-
func (f *fghc) AddCollaborator(org, repo, user string, permission github.RepoPermissionLevel) error {
211+
func (f *fghc) AddCollaborator(_, _, user string, _ github.RepoPermissionLevel) error {
212212
if strings.Contains(user, patternErrWhenAddCollaborator) {
213213
return errors.New("fake error")
214214
}
@@ -217,7 +217,7 @@ func (f *fghc) AddCollaborator(org, repo, user string, permission github.RepoPer
217217
return nil
218218
}
219219

220-
func (f *fghc) ListRepoInvitations(org, repo string) ([]*gc.RepositoryInvitation, error) {
220+
func (f *fghc) ListRepoInvitations(string, string) ([]*gc.RepositoryInvitation, error) {
221221
return f.repoInvitations, nil
222222
}
223223

@@ -234,7 +234,7 @@ func prToString(pr github.PullRequest) string {
234234
return fmt.Sprintf(prFormat, pr.Title, pr.Body, pr.Head.Ref, pr.Base.Ref, labels, assignees)
235235
}
236236

237-
func (f *fghc) CreateIssue(org, repo, title, body string, milestone int, labels, assignees []string) (int, error) {
237+
func (f *fghc) CreateIssue(_, _, title, body string, _ int, labels, assignees []string) (int, error) {
238238
f.Lock()
239239
defer f.Unlock()
240240

@@ -262,7 +262,7 @@ func (f *fghc) CreateIssue(org, repo, title, body string, milestone int, labels,
262262
return num, nil
263263
}
264264

265-
func (f *fghc) CreatePullRequest(org, repo, title, body, head, base string, canModify bool) (int, error) {
265+
func (f *fghc) CreatePullRequest(_, _, title, body, head, base string, _ bool) (int, error) {
266266
f.Lock()
267267
defer f.Unlock()
268268
num := len(f.prs) + 1
@@ -276,19 +276,19 @@ func (f *fghc) CreatePullRequest(org, repo, title, body, head, base string, canM
276276
return num, nil
277277
}
278278

279-
func (f *fghc) ListIssueComments(org, repo string, number int) ([]github.IssueComment, error) {
279+
func (f *fghc) ListIssueComments(_, _ string, _ int) ([]github.IssueComment, error) {
280280
f.Lock()
281281
defer f.Unlock()
282282
return f.prComments, nil
283283
}
284284

285-
func (f *fghc) GetIssueLabels(org, repo string, number int) ([]github.Label, error) {
285+
func (f *fghc) GetIssueLabels(_, _ string, _ int) ([]github.Label, error) {
286286
f.Lock()
287287
defer f.Unlock()
288288
return f.prLabels, nil
289289
}
290290

291-
func (f *fghc) ListOrgMembers(org, role string) ([]github.TeamMember, error) {
291+
func (f *fghc) ListOrgMembers(_, role string) ([]github.TeamMember, error) {
292292
f.Lock()
293293
defer f.Unlock()
294294
if role != "all" {
@@ -297,7 +297,7 @@ func (f *fghc) ListOrgMembers(org, role string) ([]github.TeamMember, error) {
297297
return f.orgMembers, nil
298298
}
299299

300-
func (f *fghc) CreateFork(org, repo string) (string, error) {
300+
func (f *fghc) CreateFork(_, repo string) (string, error) {
301301
return repo, nil
302302
}
303303

@@ -418,7 +418,7 @@ func testCherryPickIC(clients localgit.Clients, t *testing.T) {
418418
BotUser: botUser,
419419
GitClient: c,
420420
ConfigAgent: ca,
421-
Push: func(forkName, newBranch string, force bool) error { return nil },
421+
Push: func(_, _ string, _ bool) error { return nil },
422422
GitHubClient: ghc,
423423
WebhookSecretGenerator: getSecret,
424424
GitHubTokenGenerator: getGithubToken,
@@ -600,7 +600,7 @@ func testCherryPickPRWithLabels(clients localgit.Clients, t *testing.T) {
600600
BotUser: botUser,
601601
GitClient: c,
602602
ConfigAgent: ca,
603-
Push: func(forkName, newBranch string, force bool) error { return nil },
603+
Push: func(_, _ string, _ bool) error { return nil },
604604
GitHubClient: ghc,
605605
WebhookSecretGenerator: getSecret,
606606
GitHubTokenGenerator: getGithubToken,
@@ -810,7 +810,7 @@ func testCherryPickPRWithComment(clients localgit.Clients, t *testing.T) {
810810
BotUser: botUser,
811811
GitClient: c,
812812
ConfigAgent: ca,
813-
Push: func(forkName, newBranch string, force bool) error { return nil },
813+
Push: func(_, _ string, _ bool) error { return nil },
814814
GitHubClient: ghc,
815815
WebhookSecretGenerator: getSecret,
816816
GitHubTokenGenerator: getGithubToken,
@@ -1037,7 +1037,7 @@ func testCherryPickPRLabeled(clients localgit.Clients, t *testing.T) {
10371037
BotUser: botUser,
10381038
GitClient: c,
10391039
ConfigAgent: ca,
1040-
Push: func(forkName, newBranch string, force bool) error { return nil },
1040+
Push: func(_, _ string, _ bool) error { return nil },
10411041
GitHubClient: ghc,
10421042
WebhookSecretGenerator: getSecret,
10431043
GitHubTokenGenerator: getGithubToken,
@@ -1363,7 +1363,7 @@ type threadUnsafeFGHC struct {
13631363
orgRepoCountCalled int
13641364
}
13651365

1366-
func (tuf *threadUnsafeFGHC) EnsureFork(login, org, repo string) (string, error) {
1366+
func (tuf *threadUnsafeFGHC) EnsureFork(_, _, _ string) (string, error) {
13671367
tuf.orgRepoCountCalled++
13681368
return "", errors.New("that is enough")
13691369
}

internal/pkg/externalplugins/config.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,7 @@ func validateLabelBlockerAction(actions []string) error {
761761
allowActionSet := sets.NewString(LabeledAction, UnlabeledAction)
762762

763763
for _, action := range actions {
764-
if allowActionSet.Has(action) {
765-
continue
766-
} else {
764+
if !allowActionSet.Has(action) {
767765
return fmt.Errorf("actions contain illegal value %s", action)
768766
}
769767
}

0 commit comments

Comments
 (0)