Skip to content

Commit fc3123b

Browse files
Bump version to 2.0.27
Signed-off-by: Jai Pradeesh <jai@deepsource.io>
1 parent 9ec57aa commit fc3123b

5 files changed

Lines changed: 37 additions & 5 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.26
1+
2.0.27

command/repository/dashboard/tests/dashboard_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestDashboardRepoFlag(t *testing.T) {
4444
}
4545

4646
got := strings.TrimSpace(buf.String())
47-
expected := "https://deepsource.com/gh/owner/repo/"
47+
expected := "https://app.deepsource.com/gh/owner/repo/"
4848
if got != expected {
4949
t.Errorf("expected URL %q, got %q", expected, got)
5050
}
@@ -75,7 +75,7 @@ func TestDashboardShortFlag(t *testing.T) {
7575
}
7676

7777
got := strings.TrimSpace(buf.String())
78-
expected := "https://deepsource.com/gh/owner/repo/"
78+
expected := "https://app.deepsource.com/gh/owner/repo/"
7979
if got != expected {
8080
t.Errorf("expected URL %q, got %q", expected, got)
8181
}

internal/services/repo/service.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (s *Service) ViewURL(ctx context.Context, repoArg string) (string, error) {
123123
return "", fmt.Errorf("Unknown VCS provider: %s", remote.VCSProvider)
124124
}
125125

126-
return fmt.Sprintf("https://%s/%s/%s/%s/", cfg.Host, vcsShortcode, remote.Owner, remote.RepoName), nil
126+
return fmt.Sprintf("https://%s/%s/%s/%s/", getDashboardHost(cfg.Host), vcsShortcode, remote.Owner, remote.RepoName), nil
127127
}
128128

129129
// EnabledAnalyzers returns the analyzers enabled on a repository.
@@ -153,6 +153,20 @@ func (s *Service) EnabledAnalyzers(ctx context.Context, repoArg string) ([]analy
153153
return client.GetEnabledAnalyzers(ctx, remote.Owner, remote.RepoName, remote.VCSProvider)
154154
}
155155

156+
// getDashboardHost maps the API hostname to the web dashboard hostname.
157+
// Cloud users have their dashboard at app.deepsource.com, while enterprise
158+
// users access it on their own hostname.
159+
func getDashboardHost(host string) string {
160+
switch host {
161+
case "deepsource.com", "deepsource.io":
162+
return "app.deepsource.com"
163+
case "deepsource.one":
164+
return "app.deepsource.one"
165+
default:
166+
return host
167+
}
168+
}
169+
156170
func vcsShortcode(provider string) string {
157171
switch provider {
158172
case "GITHUB":

internal/services/repo/service_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ func TestServiceStatus(t *testing.T) {
5151
}
5252
}
5353

54+
func TestGetDashboardHost(t *testing.T) {
55+
tests := []struct {
56+
host string
57+
want string
58+
}{
59+
{"deepsource.com", "app.deepsource.com"},
60+
{"deepsource.io", "app.deepsource.com"},
61+
{"deepsource.one", "app.deepsource.one"},
62+
{"on-prem.example.com", "on-prem.example.com"},
63+
}
64+
for _, tt := range tests {
65+
t.Run(tt.host, func(t *testing.T) {
66+
assert.Equal(t, tt.want, getDashboardHost(tt.host))
67+
})
68+
}
69+
}
70+
5471
func TestServiceViewURLUnauthorized(t *testing.T) {
5572
tempDir := t.TempDir()
5673
homeDir := func() (string, error) { return tempDir, nil }

internal/testutil/testutil_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package testutil
22

33
import (
4+
"bytes"
45
"os"
56
"path/filepath"
67
"testing"
@@ -16,7 +17,7 @@ func TestLoadGoldenFile(t *testing.T) {
1617
}
1718

1819
got := LoadGoldenFile(t, path)
19-
if string(got) != string(content) {
20+
if !bytes.Equal(got, content) {
2021
t.Errorf("LoadGoldenFile returned %q, want %q", got, content)
2122
}
2223
}

0 commit comments

Comments
 (0)