Skip to content

Commit 5fda66b

Browse files
authored
Move registry commit and label commands under modules (#3454)
1 parent 10ddcf5 commit 5fda66b

File tree

22 files changed

+188
-137
lines changed

22 files changed

+188
-137
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## [Unreleased]
44

5-
- No changes yet.
5+
- Move `buf registry commit` to `buf registry module commit`. Command
6+
`buf registry commit` is now deprecated.
7+
- Move `buf registry label` to `buf registry module label`. Command
8+
`buf registry label` is now deprecated.
69

710
## [v1.46.0] - 2024-10-29
811

private/buf/cmd/buf/buf.go

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ import (
6363
"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modlslintrules"
6464
"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modopen"
6565
"github.com/bufbuild/buf/private/buf/cmd/buf/command/push"
66-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitaddlabel"
67-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitinfo"
68-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitlist"
69-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitresolve"
70-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labelarchive"
71-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labelinfo"
72-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labellist"
73-
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labelunarchive"
66+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitaddlabel"
67+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitinfo"
68+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitlist"
69+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitresolve"
7470
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecreate"
7571
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduledelete"
7672
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduledeprecate"
7773
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduleinfo"
74+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabelarchive"
75+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabelinfo"
76+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabellist"
77+
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabelunarchive"
7878
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduleundeprecate"
7979
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduleupdate"
8080
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/organization/organizationcreate"
@@ -151,20 +151,20 @@ func NewRootCommand(name string) *appcmd.Command {
151151
},
152152
{
153153
Use: "mod",
154-
Short: `Manage Buf modules. All commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
155-
Deprecated: `All commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
154+
Short: `Manage Buf modules, all commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
155+
Deprecated: `all commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
156156
Hidden: true,
157157
SubCommands: []*appcmd.Command{
158158
// Deprecated and hidden.
159-
configinit.NewCommand("init", builder, `use "buf config init" instead. However, "buf mod init" will continue to work.`, true, true),
159+
configinit.NewCommand("init", builder, deprecatedMessage("buf config init", "buf mod init"), true, true),
160160
// Deprecated and hidden.
161-
depprune.NewCommand("prune", builder, `use "buf dep prune" instead. However, "buf mod update" will continue to work.`, true),
161+
depprune.NewCommand("prune", builder, deprecatedMessage("buf dep prune", "buf mod update"), true),
162162
// Deprecated and hidden.
163-
depupdate.NewCommand("update", builder, `use "buf dep update" instead. However, "buf mod update" will continue to work.`, true),
163+
depupdate.NewCommand("update", builder, deprecatedMessage("buf dep update", "buf mod update"), true),
164164
// Deprecated and hidden.
165165
modopen.NewCommand("open", builder),
166166
// Deprecated and hidden.
167-
registrycc.NewCommand("clear-cache", builder, `use "buf registry cc" instead. However, "buf mod clear-cache" will continue to work.`, true, "cc"),
167+
registrycc.NewCommand("clear-cache", builder, deprecatedMessage("buf registry cc", "buf mod clear-cache"), true, "cc"),
168168
// Deprecated and hidden.
169169
modlslintrules.NewCommand("ls-lint-rules", builder),
170170
// Deprecated and hidden.
@@ -180,13 +180,15 @@ func NewRootCommand(name string) *appcmd.Command {
180180
whoami.NewCommand("whoami", builder),
181181
registrycc.NewCommand("cc", builder, ``, false),
182182
{
183-
Use: "commit",
184-
Short: "Manage a repository's commits",
183+
Use: "commit",
184+
Short: `Manage a module's commits, all commands are deprecated and have moved to the "buf registry module commit" subcommands`,
185+
Deprecated: `all commands are deprecated and have moved to the "buf registry module commit" subcommands.`,
186+
Hidden: true,
185187
SubCommands: []*appcmd.Command{
186-
commitaddlabel.NewCommand("add-label", builder),
187-
commitinfo.NewCommand("info", builder),
188-
commitlist.NewCommand("list", builder),
189-
commitresolve.NewCommand("resolve", builder),
188+
modulecommitaddlabel.NewCommand("add-label", builder, deprecatedMessage("buf registry module commit add-label", "buf registry commit add-label")),
189+
modulecommitinfo.NewCommand("info", builder, deprecatedMessage("buf registry module commit info", "buf registry commit info")),
190+
modulecommitlist.NewCommand("list", builder, deprecatedMessage("buf registry module commit list", "buf registry commit list")),
191+
modulecommitresolve.NewCommand("resolve", builder, deprecatedMessage("buf registry module commit resolve", "buf registry commit resolve")),
190192
},
191193
},
192194
{
@@ -197,13 +199,15 @@ func NewRootCommand(name string) *appcmd.Command {
197199
},
198200
},
199201
{
200-
Use: "label",
201-
Short: "Manage a module's labels",
202+
Use: "label",
203+
Short: `Manage a module's labels, all commands are deprecated and have moved to the "buf registry module label" subcommands`,
204+
Deprecated: `all commands are deprecated and have moved to the "buf registry module label" subcommands.`,
205+
Hidden: true,
202206
SubCommands: []*appcmd.Command{
203-
labelarchive.NewCommand("archive", builder),
204-
labelinfo.NewCommand("info", builder),
205-
labellist.NewCommand("list", builder),
206-
labelunarchive.NewCommand("unarchive", builder),
207+
modulelabelarchive.NewCommand("archive", builder, deprecatedMessage("buf registry module label archive", "buf registry label archive")),
208+
modulelabelinfo.NewCommand("info", builder, deprecatedMessage("buf registry module label info", "buf registry label info")),
209+
modulelabellist.NewCommand("list", builder, deprecatedMessage("buf registry module label list", "buf registry label list")),
210+
modulelabelunarchive.NewCommand("unarchive", builder, deprecatedMessage("buf registry module label unarchive", "buf registry label unarchive")),
207211
},
208212
},
209213
{
@@ -220,6 +224,26 @@ func NewRootCommand(name string) *appcmd.Command {
220224
Use: "module",
221225
Short: "Manage BSR modules",
222226
SubCommands: []*appcmd.Command{
227+
{
228+
Use: "commit",
229+
Short: "Manage a module's commits",
230+
SubCommands: []*appcmd.Command{
231+
modulecommitaddlabel.NewCommand("add-label", builder, ""),
232+
modulecommitinfo.NewCommand("info", builder, ""),
233+
modulecommitlist.NewCommand("list", builder, ""),
234+
modulecommitresolve.NewCommand("resolve", builder, ""),
235+
},
236+
},
237+
{
238+
Use: "label",
239+
Short: "Manage a module's labels",
240+
SubCommands: []*appcmd.Command{
241+
modulelabelarchive.NewCommand("archive", builder, ""),
242+
modulelabelinfo.NewCommand("info", builder, ""),
243+
modulelabellist.NewCommand("list", builder, ""),
244+
modulelabelunarchive.NewCommand("unarchive", builder, ""),
245+
},
246+
},
223247
modulecreate.NewCommand("create", builder),
224248
moduleinfo.NewCommand("info", builder),
225249
moduledelete.NewCommand("delete", builder),
@@ -458,3 +482,11 @@ func isPossibleNewCLIOldBSRError(connectErr *connect.Error) bool {
458482
return false
459483
}
460484
}
485+
486+
// deprecatedMessage returns a message indicating that a command is deprecated.
487+
func deprecatedMessage(newCommand, oldCommand string) string {
488+
return fmt.Sprintf(
489+
`use "%s" instead. However, "%s" will continue to work.`,
490+
newCommand, oldCommand,
491+
)
492+
}

private/buf/cmd/buf/command/registry/label/labelarchive/usage.gen.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

private/buf/cmd/buf/command/registry/label/labelinfo/usage.gen.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

private/buf/cmd/buf/command/registry/label/labellist/usage.gen.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

private/buf/cmd/buf/command/registry/label/labelunarchive/usage.gen.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

private/buf/cmd/buf/command/registry/commit/commitaddlabel/commitaddlabel.go renamed to private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitaddlabel/modulecommitaddlabel.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commitaddlabel
15+
package modulecommitaddlabel
1616

1717
import (
1818
"context"
@@ -40,12 +40,14 @@ const (
4040
func NewCommand(
4141
name string,
4242
builder appext.SubCommandBuilder,
43+
deprecated string,
4344
) *appcmd.Command {
4445
flags := newFlags()
4546
return &appcmd.Command{
46-
Use: name + " <remote/owner/module:commit> --label <label>",
47-
Short: "Add labels to a commit",
48-
Args: appcmd.ExactArgs(1),
47+
Use: name + " <remote/owner/module:commit> --label <label>",
48+
Short: "Add labels to a commit",
49+
Args: appcmd.ExactArgs(1),
50+
Deprecated: deprecated,
4951
Run: builder.NewRunFunc(
5052
func(ctx context.Context, container appext.Container) error {
5153
return run(ctx, container, flags)

private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitaddlabel/usage.gen.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

private/buf/cmd/buf/command/registry/commit/commitinfo/commitinfo.go renamed to private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitinfo/modulecommitinfo.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commitinfo
15+
package modulecommitinfo
1616

1717
import (
1818
"context"
@@ -37,12 +37,14 @@ const formatFlagName = "format"
3737
func NewCommand(
3838
name string,
3939
builder appext.SubCommandBuilder,
40+
deprecated string,
4041
) *appcmd.Command {
4142
flags := newFlags()
4243
return &appcmd.Command{
43-
Use: name + " <remote/owner/repository:commit>",
44-
Short: "Get commit information",
45-
Args: appcmd.ExactArgs(1),
44+
Use: name + " <remote/owner/repository:commit>",
45+
Short: "Get commit information",
46+
Args: appcmd.ExactArgs(1),
47+
Deprecated: deprecated,
4648
Run: builder.NewRunFunc(
4749
func(ctx context.Context, container appext.Container) error {
4850
return run(ctx, container, flags)

private/buf/cmd/buf/command/registry/commit/commitresolve/usage.gen.go renamed to private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitinfo/usage.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

private/buf/cmd/buf/command/registry/commit/commitlist/commitlist.go renamed to private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitlist/modulecommitlist.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commitlist
15+
package modulecommitlist
1616

1717
import (
1818
"context"
@@ -44,6 +44,7 @@ const (
4444
func NewCommand(
4545
name string,
4646
builder appext.SubCommandBuilder,
47+
deprecated string,
4748
) *appcmd.Command {
4849
flags := newFlags()
4950
return &appcmd.Command{
@@ -54,7 +55,8 @@ For a commit reference, it lists the commit itself.
5455
For a label reference, it lists the current and past commits associated with this label.
5556
If no reference is specified, it lists all commits in this module.
5657
`,
57-
Args: appcmd.ExactArgs(1),
58+
Args: appcmd.ExactArgs(1),
59+
Deprecated: deprecated,
5860
Run: builder.NewRunFunc(
5961
func(ctx context.Context, container appext.Container) error {
6062
return run(ctx, container, flags)

private/buf/cmd/buf/command/registry/commit/commitinfo/usage.gen.go renamed to private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitlist/usage.gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

private/buf/cmd/buf/command/registry/commit/commitresolve/commitresolve.go renamed to private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitresolve/modulecommitresolve.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
package commitresolve
15+
package modulecommitresolve
1616

1717
import (
1818
"context"
@@ -36,12 +36,14 @@ const formatFlagName = "format"
3636
func NewCommand(
3737
name string,
3838
builder appext.SubCommandBuilder,
39+
deprecated string,
3940
) *appcmd.Command {
4041
flags := newFlags()
4142
return &appcmd.Command{
42-
Use: name + " <remote/owner/repository[:ref]>",
43-
Short: "Resolve commit from a reference",
44-
Args: appcmd.ExactArgs(1),
43+
Use: name + " <remote/owner/repository[:ref]>",
44+
Short: "Resolve commit from a reference",
45+
Args: appcmd.ExactArgs(1),
46+
Deprecated: deprecated,
4547
Run: builder.NewRunFunc(
4648
func(ctx context.Context, container appext.Container) error {
4749
return run(ctx, container, flags)

private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitresolve/usage.gen.go

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)