Skip to content
This repository was archived by the owner on Mar 6, 2020. It is now read-only.
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
8 changes: 4 additions & 4 deletions cmd/gb-vendor/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func restore(ctx *gb.Context) error {
func restoreWorker(ctx *gb.Context, work chan vendor.Dependency, wg *sync.WaitGroup, errChan chan error) {
defer wg.Done()
for dep := range work {
fmt.Printf("Getting %s\n", dep.Importpath)
repo, _, err := vendor.DeduceRemoteRepo(dep.Importpath, insecure)
fmt.Printf("Getting %s from %s\n", dep.Importpath, dep.Repository)
repo, _, err := vendor.DeduceRemoteRepo(dep.Repository, insecure)
if err != nil {
errChan <- errors.Wrap(err, "could not process dependency")
return
Expand All @@ -89,12 +89,12 @@ func restoreWorker(ctx *gb.Context, work chan vendor.Dependency, wg *sync.WaitGr
src := filepath.Join(wc.Dir(), dep.Path)

if err := fileutils.Copypath(dst, src); err != nil {
errChan <- err
errChan <- errors.Wrap(err, "could not copy src to dst")
return
}

if err := wc.Destroy(); err != nil {
errChan <- err
errChan <- errors.Wrap(err, "could not destroy working copy")
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gb-vendor/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Flags:
return errors.Wrap(err, "dependency could not be deleted from manifest")
}

repo, extra, err := vendor.DeduceRemoteRepo(d.Importpath, insecure)
repo, extra, err := vendor.DeduceRemoteRepo(d.Repository, insecure)
if err != nil {
return errors.Wrapf(err, "could not determine repository for import %q", d.Importpath)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/vendor/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var (
bbregex = regexp.MustCompile(`^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`)
lpregex = regexp.MustCompile(`^launchpad.net/([A-Za-z0-9-._]+)(/[A-Za-z0-9-._]+)?(/.+)?`)
gcregex = regexp.MustCompile(`^(?P<root>code\.google\.com/[pr]/(?P<project>[a-z0-9\-]+)(\.(?P<subrepo>[a-z0-9\-]+))?)(/[A-Za-z0-9_.\-]+)*$`)
gsregex = regexp.MustCompile(`^go.googlesource.com/([a-z0-9-]+)`)
genericre = regexp.MustCompile(`^(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?/[A-Za-z0-9_.\-/~]*?)\.(?P<vcs>bzr|git|hg|svn))([/A-Za-z0-9_.\-]+)*$`)
)

Expand Down Expand Up @@ -112,6 +113,9 @@ func DeduceRemoteRepo(path string, insecure bool) (RemoteRepo, string, error) {
return repo, v[0][len(v[1]):], nil
}
return nil, "", fmt.Errorf("unknown repository type")
case gsregex.MatchString(path):
repo, err := Gitrepo(u, insecure, schemes...)
return repo, "", errors.Wrap(err, "failed to construct Gitrepo for go.googlesource.com path")
case lpregex.MatchString(path):
v := lpregex.FindStringSubmatch(path)
v = append(v, "", "")
Expand Down
5 changes: 5 additions & 0 deletions internal/vendor/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ func TestDeduceRemoteRepo(t *testing.T) {
},
extra: "/go/vcs",
}, {
path: "https://go.googlesource.com/image",
want: &gitrepo{
url: "https://go.googlesource.com/image",
},
}, {}, {
path: "labix.org/v2/mgo",
want: &bzrrepo{
url: "https://launchpad.net/mgo/v2",
Expand Down