From 1c74227ed7740d1ccae6cf700987ee4b5a3c9dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 28 Jan 2020 18:22:29 +0100 Subject: [PATCH 1/2] Use new repo name for update notifier and changelog --- .goreleaser.yml | 2 +- command/root.go | 2 +- command/root_test.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 5e0221ee2..e05144879 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,7 +13,7 @@ builds: - -s -w -X github.com/cli/cli/command.Version={{.Version}} -X github.com/cli/cli/command.BuildDate={{time "2006-01-02"}} - -X github.com/cli/cli/context.oauthClientID={{.Env.GH_OAUTH_CLIENT_ID}} - -X github.com/cli/cli/context.oauthClientSecret={{.Env.GH_OAUTH_CLIENT_SECRET}} - - -X main.updaterEnabled=github/homebrew-gh + - -X main.updaterEnabled=cli/cli goos: - linux - darwin diff --git a/command/root.go b/command/root.go index 58bc27ee9..26888d699 100644 --- a/command/root.go +++ b/command/root.go @@ -142,7 +142,7 @@ func colorableErr(cmd *cobra.Command) io.Writer { } func changelogURL(version string) string { - path := "https://github.com/github/homebrew-gh" + path := "https://github.com/cli/cli" r := regexp.MustCompile(`^v\d+\.\d+.\d+$`) if !r.MatchString(version) { return fmt.Sprintf("%s/releases/latest", path) diff --git a/command/root_test.go b/command/root_test.go index 42a934a76..46da89845 100644 --- a/command/root_test.go +++ b/command/root_test.go @@ -7,21 +7,21 @@ import ( func TestChangelogURL(t *testing.T) { tag := "v0.3.2" - url := fmt.Sprintf("https://github.com/github/homebrew-gh/releases/tag/v0.3.2") + url := fmt.Sprintf("https://github.com/cli/cli/releases/tag/v0.3.2") result := changelogURL(tag) if result != url { t.Errorf("expected %s to create url %s but got %s", tag, url, result) } tag = "0.3.5-90-gdd3f0e0" - url = fmt.Sprintf("https://github.com/github/homebrew-gh/releases/latest") + url = fmt.Sprintf("https://github.com/cli/cli/releases/latest") result = changelogURL(tag) if result != url { t.Errorf("expected %s to create url %s but got %s", tag, url, result) } tag = "deadbeef" - url = fmt.Sprintf("https://github.com/github/homebrew-gh/releases/latest") + url = fmt.Sprintf("https://github.com/cli/cli/releases/latest") result = changelogURL(tag) if result != url { t.Errorf("expected %s to create url %s but got %s", tag, url, result) From 7b28605e6fe32b2d13aec7fcbd75b34eefa95931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 28 Jan 2020 18:31:12 +0100 Subject: [PATCH 2/2] Fix current changelog link in `gh version` Also allow pre-release tags. --- command/root.go | 5 ++--- command/root_test.go | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/command/root.go b/command/root.go index 26888d699..02ffff646 100644 --- a/command/root.go +++ b/command/root.go @@ -143,12 +143,11 @@ func colorableErr(cmd *cobra.Command) io.Writer { func changelogURL(version string) string { path := "https://github.com/cli/cli" - r := regexp.MustCompile(`^v\d+\.\d+.\d+$`) + r := regexp.MustCompile(`^\d+\.\d+.\d+(-[\w.]+)?$`) if !r.MatchString(version) { return fmt.Sprintf("%s/releases/latest", path) } - tag := version - url := fmt.Sprintf("%s/releases/tag/%s", path, tag) + url := fmt.Sprintf("%s/releases/tag/v%s", path, version) return url } diff --git a/command/root_test.go b/command/root_test.go index 46da89845..1da650519 100644 --- a/command/root_test.go +++ b/command/root_test.go @@ -6,13 +6,20 @@ import ( ) func TestChangelogURL(t *testing.T) { - tag := "v0.3.2" + tag := "0.3.2" url := fmt.Sprintf("https://github.com/cli/cli/releases/tag/v0.3.2") result := changelogURL(tag) if result != url { t.Errorf("expected %s to create url %s but got %s", tag, url, result) } + tag = "0.3.2-pre.1" + url = fmt.Sprintf("https://github.com/cli/cli/releases/tag/v0.3.2-pre.1") + result = changelogURL(tag) + if result != url { + t.Errorf("expected %s to create url %s but got %s", tag, url, result) + } + tag = "0.3.5-90-gdd3f0e0" url = fmt.Sprintf("https://github.com/cli/cli/releases/latest") result = changelogURL(tag)