Skip to content

Commit 99924fb

Browse files
authored
refactor(internal/librarian): rename tag-and-release variables to tag (#2740)
In #2731, the `tag-and-release` command was renamed to `tag`. Update all related variables to reflect this change. For #1926
1 parent a6ffb3e commit 99924fb

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ func TestReleaseInit(t *testing.T) {
585585
}
586586
}
587587

588-
func TestReleaseTagAndRelease(t *testing.T) {
588+
func TestReleaseTag(t *testing.T) {
589589
for _, test := range []struct {
590590
name string
591591
prBody string

internal/librarian/help.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Examples:
112112
# Manually specify a version for a single library, overriding the calculation.
113113
librarian release init --library=secretmanager --library-version=2.0.0 --push`
114114

115-
tagAndReleaseLongHelp = `The 'tag' command is the final step in the release
115+
tagLongHelp = `The 'tag' command is the final step in the release
116116
process. It is designed to be run after a release pull request, created by
117117
'release init', has been merged.
118118

internal/librarian/librarian.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func newLibrarianCommand() *cli.Command {
5858
Long: releaseLongHelp,
5959
Commands: []*cli.Command{
6060
newCmdInit(),
61-
newCmdTagAndRelease(),
61+
newCmdTag(),
6262
},
6363
}
6464
cmdRelease.Init()
@@ -116,12 +116,12 @@ func newCmdGenerate() *cli.Command {
116116
return cmdGenerate
117117
}
118118

119-
func newCmdTagAndRelease() *cli.Command {
119+
func newCmdTag() *cli.Command {
120120
var verbose bool
121-
cmdTagAndRelease := &cli.Command{
121+
cmdTag := &cli.Command{
122122
Short: "tag tags and creates a GitHub release for a merged pull request.",
123123
UsageLine: "librarian release tag [arguments]",
124-
Long: tagAndReleaseLongHelp,
124+
Long: tagLongHelp,
125125
Action: func(ctx context.Context, cmd *cli.Command) error {
126126
setupLogger(verbose)
127127
slog.Debug("tag command verbose logging")
@@ -131,19 +131,19 @@ func newCmdTagAndRelease() *cli.Command {
131131
if _, err := cmd.Config.IsValid(); err != nil {
132132
return fmt.Errorf("failed to validate config: %s", err)
133133
}
134-
runner, err := newTagAndReleaseRunner(cmd.Config)
134+
runner, err := newTagRunner(cmd.Config)
135135
if err != nil {
136136
return err
137137
}
138138
return runner.run(ctx)
139139
},
140140
}
141-
cmdTagAndRelease.Init()
142-
addFlagRepo(cmdTagAndRelease.Flags, cmdTagAndRelease.Config)
143-
addFlagPR(cmdTagAndRelease.Flags, cmdTagAndRelease.Config)
144-
addFlagGitHubAPIEndpoint(cmdTagAndRelease.Flags, cmdTagAndRelease.Config)
145-
addFlagVerbose(cmdTagAndRelease.Flags, &verbose)
146-
return cmdTagAndRelease
141+
cmdTag.Init()
142+
addFlagRepo(cmdTag.Flags, cmdTag.Config)
143+
addFlagPR(cmdTag.Flags, cmdTag.Config)
144+
addFlagGitHubAPIEndpoint(cmdTag.Flags, cmdTag.Config)
145+
addFlagVerbose(cmdTag.Flags, &verbose)
146+
return cmdTag
147147
}
148148

149149
func newCmdInit() *cli.Command {

internal/librarian/tag_and_release.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ import (
3636
)
3737

3838
const (
39-
pullRequestSegments = 7
40-
tagAndReleaseCmdName = "tag"
41-
releasePendingLabel = "release:pending"
42-
releaseDoneLabel = "release:done"
39+
pullRequestSegments = 7
40+
tagCmdName = "tag"
41+
releasePendingLabel = "release:pending"
42+
releaseDoneLabel = "release:done"
4343
)
4444

4545
var (
@@ -56,7 +56,7 @@ var (
5656
`))
5757
)
5858

59-
type tagAndReleaseRunner struct {
59+
type tagRunner struct {
6060
ghClient GitHubClient
6161
pullRequest string
6262
}
@@ -77,7 +77,7 @@ type libraryReleaseBuilder struct {
7777
version string
7878
}
7979

80-
func newTagAndReleaseRunner(cfg *config.Config) (*tagAndReleaseRunner, error) {
80+
func newTagRunner(cfg *config.Config) (*tagRunner, error) {
8181
if cfg.GitHubToken == "" {
8282
return nil, fmt.Errorf("`%s` must be set", config.LibrarianGithubToken)
8383
}
@@ -95,7 +95,7 @@ func newTagAndReleaseRunner(cfg *config.Config) (*tagAndReleaseRunner, error) {
9595
}
9696
ghClient.BaseURL = endpoint
9797
}
98-
return &tagAndReleaseRunner{
98+
return &tagRunner{
9999
ghClient: ghClient,
100100
pullRequest: cfg.PullRequest,
101101
}, nil
@@ -119,7 +119,7 @@ func parseRemote(repo string) (*github.Repository, error) {
119119
return GetGitHubRepositoryFromGitRepo(githubRepo)
120120
}
121121

122-
func (r *tagAndReleaseRunner) run(ctx context.Context) error {
122+
func (r *tagRunner) run(ctx context.Context) error {
123123
slog.Info("running tag command")
124124
prs, err := r.determinePullRequestsToProcess(ctx)
125125
if err != nil {
@@ -147,7 +147,7 @@ func (r *tagAndReleaseRunner) run(ctx context.Context) error {
147147
return nil
148148
}
149149

150-
func (r *tagAndReleaseRunner) determinePullRequestsToProcess(ctx context.Context) ([]*github.PullRequest, error) {
150+
func (r *tagRunner) determinePullRequestsToProcess(ctx context.Context) ([]*github.PullRequest, error) {
151151
slog.Info("determining pull requests to process")
152152
if r.pullRequest != "" {
153153
slog.Info("processing a single pull request", "pr", r.pullRequest)
@@ -176,7 +176,7 @@ func (r *tagAndReleaseRunner) determinePullRequestsToProcess(ctx context.Context
176176
return prs, nil
177177
}
178178

179-
func (r *tagAndReleaseRunner) processPullRequest(ctx context.Context, p *github.PullRequest) error {
179+
func (r *tagRunner) processPullRequest(ctx context.Context, p *github.PullRequest) error {
180180
slog.Info("processing pull request", "pr", p.GetNumber())
181181
releases := parsePullRequestBody(p.GetBody())
182182
if len(releases) == 0 {
@@ -315,7 +315,7 @@ func parsePullRequestBody(body string) []libraryRelease {
315315
}
316316

317317
// replacePendingLabel is a helper function that replaces the `release:pending` label with `release:done`.
318-
func (r *tagAndReleaseRunner) replacePendingLabel(ctx context.Context, p *github.PullRequest) error {
318+
func (r *tagRunner) replacePendingLabel(ctx context.Context, p *github.PullRequest) error {
319319
var currentLabels []string
320320
for _, label := range p.Labels {
321321
currentLabels = append(currentLabels, label.GetName())

internal/librarian/tag_and_release_test.go renamed to internal/librarian/tag_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/googleapis/librarian/internal/github"
2626
)
2727

28-
func TestNewTagAndReleaseRunner(t *testing.T) {
28+
func TestNewTagRunner(t *testing.T) {
2929
testcases := []struct {
3030
name string
3131
cfg *config.Config
@@ -37,27 +37,27 @@ func TestNewTagAndReleaseRunner(t *testing.T) {
3737
GitHubToken: "some-token",
3838
Repo: "https://github.com/googleapis/some-test-repo",
3939
WorkRoot: t.TempDir(),
40-
CommandName: tagAndReleaseCmdName,
40+
CommandName: tagCmdName,
4141
},
4242
wantErr: false,
4343
},
4444
{
4545
name: "missing github token",
4646
cfg: &config.Config{
47-
CommandName: tagAndReleaseCmdName,
47+
CommandName: tagCmdName,
4848
},
4949
wantErr: true,
5050
},
5151
}
5252
for _, tc := range testcases {
5353
t.Run(tc.name, func(t *testing.T) {
54-
r, err := newTagAndReleaseRunner(tc.cfg)
54+
r, err := newTagRunner(tc.cfg)
5555
if (err != nil) != tc.wantErr {
56-
t.Errorf("newTagAndReleaseRunner() error = %v, wantErr %v", err, tc.wantErr)
56+
t.Errorf("newTagRunner() error = %v, wantErr %v", err, tc.wantErr)
5757
return
5858
}
5959
if !tc.wantErr && r == nil {
60-
t.Errorf("newTagAndReleaseRunner() got nil runner, want non-nil")
60+
t.Errorf("newTagRunner() got nil runner, want non-nil")
6161
}
6262
})
6363
}
@@ -130,7 +130,7 @@ func TestDeterminePullRequestsToProcess(t *testing.T) {
130130
},
131131
} {
132132
t.Run(test.name, func(t *testing.T) {
133-
r := &tagAndReleaseRunner{
133+
r := &tagRunner{
134134
pullRequest: test.cfg.PullRequest,
135135
ghClient: test.ghClient,
136136
}
@@ -151,7 +151,7 @@ func TestDeterminePullRequestsToProcess(t *testing.T) {
151151
}
152152
}
153153

154-
func Test_tagAndReleaseRunner_run(t *testing.T) {
154+
func Test_tagRunner_run(t *testing.T) {
155155
pr123 := &github.PullRequest{}
156156
pr456 := &github.PullRequest{}
157157

@@ -191,7 +191,7 @@ func Test_tagAndReleaseRunner_run(t *testing.T) {
191191
},
192192
} {
193193
t.Run(test.name, func(t *testing.T) {
194-
r := &tagAndReleaseRunner{
194+
r := &tagRunner{
195195
ghClient: test.ghClient,
196196
}
197197
err := r.run(t.Context())
@@ -594,7 +594,7 @@ func TestProcessPullRequest(t *testing.T) {
594594
},
595595
} {
596596
t.Run(test.name, func(t *testing.T) {
597-
r := &tagAndReleaseRunner{
597+
r := &tagRunner{
598598
ghClient: test.ghClient,
599599
}
600600
err := r.processPullRequest(t.Context(), test.pr)
@@ -655,7 +655,7 @@ func TestReplacePendingLabel(t *testing.T) {
655655
},
656656
} {
657657
t.Run(test.name, func(t *testing.T) {
658-
r := &tagAndReleaseRunner{
658+
r := &tagRunner{
659659
ghClient: test.ghClient,
660660
}
661661
err := r.replacePendingLabel(t.Context(), test.pr)
@@ -674,7 +674,7 @@ func TestReplacePendingLabel(t *testing.T) {
674674
}
675675
}
676676

677-
func Test_tagAndReleaseRunner_run_processPullRequests(t *testing.T) {
677+
func Test_tagRunner_run_processPullRequests(t *testing.T) {
678678
branch := "main"
679679
pr1 := &github.PullRequest{
680680
Body: gh.Ptr(`<details><summary>google-cloud-storage: v1.2.3</summary>release notes</details>`),
@@ -709,7 +709,7 @@ func Test_tagAndReleaseRunner_run_processPullRequests(t *testing.T) {
709709
},
710710
}
711711

712-
r := &tagAndReleaseRunner{
712+
r := &tagRunner{
713713
ghClient: ghClient,
714714
}
715715
err := r.run(t.Context())

0 commit comments

Comments
 (0)