Skip to content

Commit

Permalink
Move registry commit and label commands under modules (#3454)
Browse files Browse the repository at this point in the history
  • Loading branch information
emcfarlane authored Nov 13, 2024
1 parent 10ddcf5 commit 5fda66b
Show file tree
Hide file tree
Showing 22 changed files with 188 additions and 137 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## [Unreleased]

- No changes yet.
- Move `buf registry commit` to `buf registry module commit`. Command
`buf registry commit` is now deprecated.
- Move `buf registry label` to `buf registry module label`. Command
`buf registry label` is now deprecated.

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

Expand Down
84 changes: 58 additions & 26 deletions private/buf/cmd/buf/buf.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ import (
"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modlslintrules"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/mod/modopen"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/push"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitaddlabel"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitinfo"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitlist"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/commit/commitresolve"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labelarchive"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labelinfo"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labellist"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/label/labelunarchive"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitaddlabel"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitinfo"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitlist"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecommit/modulecommitresolve"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulecreate"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduledelete"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduledeprecate"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduleinfo"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabelarchive"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabelinfo"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabellist"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/modulelabel/modulelabelunarchive"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduleundeprecate"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/module/moduleupdate"
"github.com/bufbuild/buf/private/buf/cmd/buf/command/registry/organization/organizationcreate"
Expand Down Expand Up @@ -151,20 +151,20 @@ func NewRootCommand(name string) *appcmd.Command {
},
{
Use: "mod",
Short: `Manage Buf modules. All commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
Deprecated: `All commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
Short: `Manage Buf modules, all commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
Deprecated: `all commands are deprecated and have moved to the "buf config", "buf dep", or "buf registry" subcommands.`,
Hidden: true,
SubCommands: []*appcmd.Command{
// Deprecated and hidden.
configinit.NewCommand("init", builder, `use "buf config init" instead. However, "buf mod init" will continue to work.`, true, true),
configinit.NewCommand("init", builder, deprecatedMessage("buf config init", "buf mod init"), true, true),
// Deprecated and hidden.
depprune.NewCommand("prune", builder, `use "buf dep prune" instead. However, "buf mod update" will continue to work.`, true),
depprune.NewCommand("prune", builder, deprecatedMessage("buf dep prune", "buf mod update"), true),
// Deprecated and hidden.
depupdate.NewCommand("update", builder, `use "buf dep update" instead. However, "buf mod update" will continue to work.`, true),
depupdate.NewCommand("update", builder, deprecatedMessage("buf dep update", "buf mod update"), true),
// Deprecated and hidden.
modopen.NewCommand("open", builder),
// Deprecated and hidden.
registrycc.NewCommand("clear-cache", builder, `use "buf registry cc" instead. However, "buf mod clear-cache" will continue to work.`, true, "cc"),
registrycc.NewCommand("clear-cache", builder, deprecatedMessage("buf registry cc", "buf mod clear-cache"), true, "cc"),
// Deprecated and hidden.
modlslintrules.NewCommand("ls-lint-rules", builder),
// Deprecated and hidden.
Expand All @@ -180,13 +180,15 @@ func NewRootCommand(name string) *appcmd.Command {
whoami.NewCommand("whoami", builder),
registrycc.NewCommand("cc", builder, ``, false),
{
Use: "commit",
Short: "Manage a repository's commits",
Use: "commit",
Short: `Manage a module's commits, all commands are deprecated and have moved to the "buf registry module commit" subcommands`,
Deprecated: `all commands are deprecated and have moved to the "buf registry module commit" subcommands.`,
Hidden: true,
SubCommands: []*appcmd.Command{
commitaddlabel.NewCommand("add-label", builder),
commitinfo.NewCommand("info", builder),
commitlist.NewCommand("list", builder),
commitresolve.NewCommand("resolve", builder),
modulecommitaddlabel.NewCommand("add-label", builder, deprecatedMessage("buf registry module commit add-label", "buf registry commit add-label")),
modulecommitinfo.NewCommand("info", builder, deprecatedMessage("buf registry module commit info", "buf registry commit info")),
modulecommitlist.NewCommand("list", builder, deprecatedMessage("buf registry module commit list", "buf registry commit list")),
modulecommitresolve.NewCommand("resolve", builder, deprecatedMessage("buf registry module commit resolve", "buf registry commit resolve")),
},
},
{
Expand All @@ -197,13 +199,15 @@ func NewRootCommand(name string) *appcmd.Command {
},
},
{
Use: "label",
Short: "Manage a module's labels",
Use: "label",
Short: `Manage a module's labels, all commands are deprecated and have moved to the "buf registry module label" subcommands`,
Deprecated: `all commands are deprecated and have moved to the "buf registry module label" subcommands.`,
Hidden: true,
SubCommands: []*appcmd.Command{
labelarchive.NewCommand("archive", builder),
labelinfo.NewCommand("info", builder),
labellist.NewCommand("list", builder),
labelunarchive.NewCommand("unarchive", builder),
modulelabelarchive.NewCommand("archive", builder, deprecatedMessage("buf registry module label archive", "buf registry label archive")),
modulelabelinfo.NewCommand("info", builder, deprecatedMessage("buf registry module label info", "buf registry label info")),
modulelabellist.NewCommand("list", builder, deprecatedMessage("buf registry module label list", "buf registry label list")),
modulelabelunarchive.NewCommand("unarchive", builder, deprecatedMessage("buf registry module label unarchive", "buf registry label unarchive")),
},
},
{
Expand All @@ -220,6 +224,26 @@ func NewRootCommand(name string) *appcmd.Command {
Use: "module",
Short: "Manage BSR modules",
SubCommands: []*appcmd.Command{
{
Use: "commit",
Short: "Manage a module's commits",
SubCommands: []*appcmd.Command{
modulecommitaddlabel.NewCommand("add-label", builder, ""),
modulecommitinfo.NewCommand("info", builder, ""),
modulecommitlist.NewCommand("list", builder, ""),
modulecommitresolve.NewCommand("resolve", builder, ""),
},
},
{
Use: "label",
Short: "Manage a module's labels",
SubCommands: []*appcmd.Command{
modulelabelarchive.NewCommand("archive", builder, ""),
modulelabelinfo.NewCommand("info", builder, ""),
modulelabellist.NewCommand("list", builder, ""),
modulelabelunarchive.NewCommand("unarchive", builder, ""),
},
},
modulecreate.NewCommand("create", builder),
moduleinfo.NewCommand("info", builder),
moduledelete.NewCommand("delete", builder),
Expand Down Expand Up @@ -458,3 +482,11 @@ func isPossibleNewCLIOldBSRError(connectErr *connect.Error) bool {
return false
}
}

// deprecatedMessage returns a message indicating that a command is deprecated.
func deprecatedMessage(newCommand, oldCommand string) string {
return fmt.Sprintf(
`use "%s" instead. However, "%s" will continue to work.`,
newCommand, oldCommand,
)
}

This file was deleted.

19 changes: 0 additions & 19 deletions private/buf/cmd/buf/command/registry/label/labelinfo/usage.gen.go

This file was deleted.

19 changes: 0 additions & 19 deletions private/buf/cmd/buf/command/registry/label/labellist/usage.gen.go

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package commitaddlabel
package modulecommitaddlabel

import (
"context"
Expand Down Expand Up @@ -40,12 +40,14 @@ const (
func NewCommand(
name string,
builder appext.SubCommandBuilder,
deprecated string,
) *appcmd.Command {
flags := newFlags()
return &appcmd.Command{
Use: name + " <remote/owner/module:commit> --label <label>",
Short: "Add labels to a commit",
Args: appcmd.ExactArgs(1),
Use: name + " <remote/owner/module:commit> --label <label>",
Short: "Add labels to a commit",
Args: appcmd.ExactArgs(1),
Deprecated: deprecated,
Run: builder.NewRunFunc(
func(ctx context.Context, container appext.Container) error {
return run(ctx, container, flags)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package commitinfo
package modulecommitinfo

import (
"context"
Expand All @@ -37,12 +37,14 @@ const formatFlagName = "format"
func NewCommand(
name string,
builder appext.SubCommandBuilder,
deprecated string,
) *appcmd.Command {
flags := newFlags()
return &appcmd.Command{
Use: name + " <remote/owner/repository:commit>",
Short: "Get commit information",
Args: appcmd.ExactArgs(1),
Use: name + " <remote/owner/repository:commit>",
Short: "Get commit information",
Args: appcmd.ExactArgs(1),
Deprecated: deprecated,
Run: builder.NewRunFunc(
func(ctx context.Context, container appext.Container) error {
return run(ctx, container, flags)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package commitlist
package modulecommitlist

import (
"context"
Expand Down Expand Up @@ -44,6 +44,7 @@ const (
func NewCommand(
name string,
builder appext.SubCommandBuilder,
deprecated string,
) *appcmd.Command {
flags := newFlags()
return &appcmd.Command{
Expand All @@ -54,7 +55,8 @@ For a commit reference, it lists the commit itself.
For a label reference, it lists the current and past commits associated with this label.
If no reference is specified, it lists all commits in this module.
`,
Args: appcmd.ExactArgs(1),
Args: appcmd.ExactArgs(1),
Deprecated: deprecated,
Run: builder.NewRunFunc(
func(ctx context.Context, container appext.Container) error {
return run(ctx, container, flags)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package commitresolve
package modulecommitresolve

import (
"context"
Expand All @@ -36,12 +36,14 @@ const formatFlagName = "format"
func NewCommand(
name string,
builder appext.SubCommandBuilder,
deprecated string,
) *appcmd.Command {
flags := newFlags()
return &appcmd.Command{
Use: name + " <remote/owner/repository[:ref]>",
Short: "Resolve commit from a reference",
Args: appcmd.ExactArgs(1),
Use: name + " <remote/owner/repository[:ref]>",
Short: "Resolve commit from a reference",
Args: appcmd.ExactArgs(1),
Deprecated: deprecated,
Run: builder.NewRunFunc(
func(ctx context.Context, container appext.Container) error {
return run(ctx, container, flags)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5fda66b

Please sign in to comment.