Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do dynamic lookup of Repo source for custom imports #756

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions cfg/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}