diff --git a/cfg/config.go b/cfg/config.go index ae01039a..690acb03 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -469,6 +469,11 @@ func (d *Dependency) Remote() string { r = d.Repository } else { r = "https://" + d.Name + repo, err := vcs.NewRepo("https://"+d.Name, "") + // TODO: change the function signature and return the error (?) + if err == nil { + r = repo.Remote() + } } f, nr, _ := mirrors.Get(r) diff --git a/cfg/config_test.go b/cfg/config_test.go index 6313ff02..0aae9e83 100644 --- a/cfg/config_test.go +++ b/cfg/config_test.go @@ -36,6 +36,7 @@ import: - package: github.com/Masterminds/structable - package: github.com/Masterminds/cookoo/color - package: github.com/Masterminds/cookoo/convert + - package: golang.org/x/crypto testImport: - package: github.com/kylelemons/go-gypsy @@ -176,3 +177,21 @@ func TestOwners(t *testing.T) { t.Error("Unable to parse owners from yaml") } } + +func TestRemote(t *testing.T) { + tests := []struct { + name string + remote string + }{ + {"golang.org/x/crypto", "https://go.googlesource.com/crypto"}, + {"gopkg.in/yaml.v2", "https://gopkg.in/yaml.v2"}, + {"github.com/Masterminds/glide", "https://github.com/Masterminds/glide"}, + } + for _, tt := range tests { + d := Dependency{Name: tt.name} + r := d.Remote() + if r != tt.remote { + t.Errorf("Bad remote - want %s, got %s", tt.remote, r) + } + } +}