diff --git a/cmd/action/version.go b/cmd/action/version.go index d80f874c389..5391ba376ca 100644 --- a/cmd/action/version.go +++ b/cmd/action/version.go @@ -2,6 +2,7 @@ package action import ( "fmt" + "strings" "github.com/spf13/cobra" "golang.org/x/mod/semver" @@ -27,7 +28,12 @@ func init() { // parse returns a user facing version and release notes url func parse(version string) (string, string) { if ok := semver.IsValid(version); !ok { - return "- development", "https://github.com/ariga/atlas/releases/tag/latest" + v := "- development" + s := strings.Split(version, "_") + if len(s) != 0 && s[len(s)-1] == "canary" { + v = version + } + return v, "https://github.com/ariga/atlas/releases/tag/latest" } return version, fmt.Sprintf("https://github.com/ariga/atlas/releases/tag/%s", version) } diff --git a/internal/integration/integration_test.go b/internal/integration/integration_test.go index 08ea50575e8..4b61db76eb6 100644 --- a/internal/integration/integration_test.go +++ b/internal/integration/integration_test.go @@ -225,6 +225,16 @@ func TestCLI_Version(t *testing.T) { ), expected: "atlas CLI version v1.2.3\nhttps://github.com/ariga/atlas/releases/tag/v1.2.3\n", }, + { + name: "canary", + cmd: exec.Command("go", "run", + "-ldflags", + "-X ariga.io/atlas/cmd/action.version=v0.3.0_6539f2704b5d_canary", + "ariga.io/atlas/cmd/atlas", + "version", + ), + expected: "atlas CLI version v0.3.0_6539f2704b5d_canary\nhttps://github.com/ariga/atlas/releases/tag/latest\n", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {