Repository: bufbuild/buf
Pull request #1574 (2022-11-09 15:25:07)

Promote buf convert to stable
Promotes `buf beta convert` to stable because it's been out in beta for some time and there haven't been any bugs reported.
Keeps `buf beta convert` so that anyone who's using it may continue until we decide to remove it from beta. 



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0a738de5..1be06b51b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
   modules from managed mode, and `override`, which specifies `csharp_namespace` values 
   per module, overriding the default value. By default, when managed mode is enabled, 
   `csharp_namespace` is set to the package name with each package sub-name capitalized.
+- Promote `buf convert` to stable, keep `buf beta convert` aliased in the beta command.
 
 ## [v1.9.0] - 2022-10-19
 
diff --git a/private/buf/cmd/buf/buf.go b/private/buf/cmd/buf/buf.go
index 106e6055b..7ecac9c49 100644
--- a/private/buf/cmd/buf/buf.go
+++ b/private/buf/cmd/buf/buf.go
@@ -25,7 +25,6 @@ import (
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokendelete"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenget"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/alpha/registry/token/tokenlist"
-	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/convert"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/migratev1beta1"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitget"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/registry/commit/commitlist"
@@ -62,6 +61,7 @@ import (
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/beta/studioagent"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/breaking"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/build"
+	"github.com/bufbuild/buf/private/buf/cmd/buf/command/convert"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/export"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/format"
 	"github.com/bufbuild/buf/private/buf/cmd/buf/command/generate"
@@ -115,6 +115,7 @@ func NewRootCommand(name string) *appcmd.Command {
 			generate.NewCommand("generate", builder),
 			lsfiles.NewCommand("ls-files", builder),
 			push.NewCommand("push", builder),
+			convert.NewCommand("convert", builder),
 			{
 				Use:   "mod",
 				Short: "Manage Buf modules.",
diff --git a/private/buf/cmd/buf/command/beta/convert/convert.go b/private/buf/cmd/buf/command/convert/convert.go
similarity index 90%
rename from private/buf/cmd/buf/command/beta/convert/convert.go
rename to private/buf/cmd/buf/command/convert/convert.go
index e459c5703..8cd34e73d 100644
--- a/private/buf/cmd/buf/command/beta/convert/convert.go
+++ b/private/buf/cmd/buf/command/convert/convert.go
@@ -52,34 +52,34 @@ Use an input proto to interpret a proto/json message and convert it to a differe
 
 The simplest form is:
 
-$ buf beta convert <input> --type=<type> --from=<payload> --to=<output>
+$ buf convert <input> --type=<type> --from=<payload> --to=<output>
 
 <input> is the same input as any other buf command. 
 It can be a local .proto file, binary output of "buf build", bsr module or local buf module.
 e.g.
-$ buf beta convert example.proto --type=Foo.proto --from=payload.json --to=output.bin
+$ buf convert example.proto --type=Foo.proto --from=payload.json --to=output.bin
 
 # Other examples
 
 # All of <input>, "--from" and "to" accept formatting options
 
-$ buf beta convert example.proto#format=bin --type=buf.Foo --from=payload#format=json --to=out#format=json
+$ buf convert example.proto#format=bin --type=buf.Foo --from=payload#format=json --to=out#format=json
 
 # Both <input> and "--from" accept stdin redirecting
 
-$ buf beta convert <(buf build -o -)#format=bin --type=foo.Bar --from=<(echo "{\"one\":\"55\"}")#format=json
+$ buf convert <(buf build -o -)#format=bin --type=foo.Bar --from=<(echo "{\"one\":\"55\"}")#format=json
 
 # Redirect from stdin to --from
 
-$ echo "{\"one\":\"55\"}" | buf beta convert buf.proto --type buf.Foo --from -#format=json
+$ echo "{\"one\":\"55\"}" | buf convert buf.proto --type buf.Foo --from -#format=json
 
 # Redirect from stdin to <input>
 
-$ buf build -o - | buf beta convert -#format=bin --type buf.Foo --from=payload.json
+$ buf build -o - | buf convert -#format=bin --type buf.Foo --from=payload.json
 
 # Use a module on the bsr
 
-buf beta convert buf.build/<org>/<repo> --type buf.Foo --from=payload.json
+buf convert buf.build/<org>/<repo> --type buf.Foo --from=payload.json
 `,
 		Args: cobra.MaximumNArgs(1),
 		Run: builder.NewRunFunc(


Test patch:
diff --git a/private/buf/cmd/buf/buf_test.go b/private/buf/cmd/buf/buf_test.go
index a4b5ecf34..50745ab12 100644
--- a/private/buf/cmd/buf/buf_test.go
+++ b/private/buf/cmd/buf/buf_test.go
@@ -37,7 +37,7 @@ import (
 	"github.com/stretchr/testify/require"
 )
 
-var convertTestDataDir = filepath.Join("command", "beta", "convert", "testdata", "convert")
+var convertTestDataDir = filepath.Join("command", "convert", "testdata", "convert")
 
 func TestSuccess1(t *testing.T) {
 	t.Parallel()
@@ -1739,7 +1739,6 @@ func TestConvertWithImage(t *testing.T) {
 			0,
 			stdin,
 			stdout,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -1755,7 +1754,6 @@ func TestConvertWithImage(t *testing.T) {
 			1,
 			"",
 			"Failure: size of input message must not be zero",
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -1786,7 +1784,6 @@ func TestConvertOutput(t *testing.T) {
 			stdin,
 			0,
 			``,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -1815,7 +1812,6 @@ func TestConvertOutput(t *testing.T) {
 			stdin,
 			0,
 			``,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -1844,7 +1840,6 @@ func TestConvertOutput(t *testing.T) {
 			0,
 			stdin,
 			stdout,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -1877,7 +1872,6 @@ func TestConvertInvalidTypeName(t *testing.T) {
 		1,
 		"",
 		`Failure: ".foo" is not a valid fully qualified type name`,
-		"beta",
 		"convert",
 		filepath.Join(tempDir, "image.bin"),
 		"--type",
@@ -1891,7 +1885,6 @@ func TestConvert(t *testing.T) {
 			nil,
 			0,
 			convertTestDataDir+"/bin_json/payload.json",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			"--from="+convertTestDataDir+"/bin_json/payload.bin",
@@ -1903,7 +1896,6 @@ func TestConvert(t *testing.T) {
 			nil,
 			0,
 			convertTestDataDir+"/bin_json/payload.bin",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			"--from="+convertTestDataDir+"/bin_json/payload.json",
@@ -1915,7 +1907,6 @@ func TestConvert(t *testing.T) {
 			strings.NewReader(`{"one":"55"}`),
 			0,
 			convertTestDataDir+"/bin_json/payload.bin",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			"--from",
@@ -1929,7 +1920,6 @@ func TestConvert(t *testing.T) {
 		testRunStdoutFile(t, file,
 			0,
 			convertTestDataDir+"/bin_json/payload.json",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			"--from",
@@ -1942,7 +1932,6 @@ func TestConvert(t *testing.T) {
 			strings.NewReader(`{"one":"55"}`),
 			0,
 			convertTestDataDir+"/bin_json/payload.json",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			convertTestDataDir+"/bin_json/buf.proto",
@@ -1957,7 +1946,6 @@ func TestConvert(t *testing.T) {
 		testRunStdoutFile(t, file,
 			0,
 			convertTestDataDir+"/bin_json/payload.json",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			"-",
@@ -1973,7 +1961,6 @@ func TestConvert(t *testing.T) {
 			file,
 			0,
 			convertTestDataDir+"/bin_json/payload.json",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			convertTestDataDir+"/bin_json/image.bin",
@@ -1989,7 +1976,6 @@ func TestConvert(t *testing.T) {
 			file,
 			0,
 			convertTestDataDir+"/bin_json/payload.json",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			convertTestDataDir+"/bin_json/image.bin",
@@ -2004,7 +1990,6 @@ func TestConvert(t *testing.T) {
 			file,
 			0,
 			convertTestDataDir+"/bin_json/payload.bin",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			convertTestDataDir+"/bin_json/image.bin",
@@ -2021,7 +2006,6 @@ func TestConvert(t *testing.T) {
 			file,
 			0,
 			convertTestDataDir+"/bin_json/payload.bin",
-			"beta",
 			"convert",
 			"--type=buf.Foo",
 			"-#format=json",
@@ -2272,7 +2256,6 @@ func TestConvertRoundTrip(t *testing.T) {
 			0,
 			stdin,
 			encodedMessage,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -2285,7 +2268,6 @@ func TestConvertRoundTrip(t *testing.T) {
 			0,
 			encodedMessage,
 			decodedMessage,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -2302,7 +2284,6 @@ func TestConvertRoundTrip(t *testing.T) {
 			0,
 			stdin,
 			encodedMessage,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -2317,7 +2298,6 @@ func TestConvertRoundTrip(t *testing.T) {
 			0,
 			encodedMessage,
 			decodedMessage,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -2337,7 +2317,6 @@ func TestConvertRoundTrip(t *testing.T) {
 			0,
 			stdin,
 			nil,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",
@@ -2352,7 +2331,6 @@ func TestConvertRoundTrip(t *testing.T) {
 			0,
 			nil,
 			decodedMessage,
-			"beta",
 			"convert",
 			filepath.Join(tempDir, "image.bin"),
 			"--type",