Merge lp://staging/~rogpeppe/godeps/004-no-go-get into lp://staging/godeps
Proposed by
Roger Peppe
Status: | Merged |
---|---|
Merged at revision: | 29 |
Proposed branch: | lp://staging/~rogpeppe/godeps/004-no-go-get |
Merge into: | lp://staging/godeps |
Diff against target: |
124 lines (+62/-10) 1 file modified
godeps.go (+62/-10) |
To merge this branch: | bzr merge lp://staging/~rogpeppe/godeps/004-no-go-get |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
godeps-maintainers | Pending | ||
Review via email: mp+258017@code.staging.launchpad.net |
Description of the change
do not use go get to fetch new repositories
"go get" always recursively fetches dependencies,
and this feature cannot be disabled. This means that
when godeps used "go get -d" to fetch a repository,
it could fetch unwanted tip dependencies.
To post a comment you must log in.
Reviewers: mp+258017_ code.launchpad. net,
Message:
Please take a look.
Description:
do not use go get to fetch new repositories
"go get" always recursively fetches dependencies,
and this feature cannot be disabled. This means that
when godeps used "go get -d" to fetch a repository,
it could fetch unwanted tip dependencies.
https:/ /code.launchpad .net/~rogpeppe/ godeps/ 004-no- go-get/ +merge/ 258017
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/230460044/
Affected files (+59, -10 lines):
A [revision details]
M godeps.go
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: godeps.go
=== modified file 'godeps.go'
--- godeps.go 2014-12-04 16:32:37 +0000
+++ godeps.go 2015-05-01 11:00:22 +0000
@@ -19,6 +19,8 @@
"time"
"github. com/kisielk/ gotool" net/godeps/ pkgrepo"
+
+ "launchpad.
)
var ( Printf( "update %s failed; trying to fetch newer version\n", /code.google. com/p/go/ issues/ detail? id=8335 Contains( err.Error( ), "no buildable Go source Fetch(info. dir); err != nil { Update( info.dir, info.revid)
@@ -155,16 +157,8 @@
}
fmt.
info.project)
if info.notThere {
- _, err := runCmd(".", "go", "get", "-d", info.project)
- // Note that we can't add a "/..." to the end of info.project, because
- // that causes go get to fail for vanity import paths with an
- // "unrecognized import path" error. But when we *don't*
- // use /..., we get a "no buildable Go source files" error when
- // the root of the repository does not contain any Go files.
- // It's a no-win situation, so we just ignore the latter error.
- // See https:/
- if err != nil && !strings.
files") {
- return err
+ if err := createRepo(info); err != nil {
+ return fmt.Errorf("cannot create repo: %v", err)
}
} else {
if err := info.vcs.
@@ -174,6 +168,43 @@
return info.vcs.
}
+func createRepo(info *depInfo) error { /go-review. googlesource. com/#/c/ 8725/ Root(info. project) Join(buildConte xt.GOPATH, "src", FromSlash( root.Root) )
+ // We would much prefer to just do:
+ //
+ // _, err := runCmd(".", "go", "get", "-nodeps", "-d", project)
+ //
+ // here, but there's no way to prevent go get from downloading
+ // dependencies recursively, which means that we can get
+ // extraneous dependencies when the package tip has dependencies
+ // not mentioned by the target revision, which can in turn cause
+ // build scripts that are particular about such things to fail.
+ // See also https:/
+ //
+ // Instead, we use code abstracted from the go tool to do the
+ // job.
+ root, err := pkgrepo.
+ if err != nil {
+ return fmt.Errorf("cannot find project root: %v", err)
+ }
+ rootDir := filepath.
filepath.
+ if string(root.VCS) != info.vcs.Kind() {
+ return fmt.Errorf("project has unexpected VCS kind %s; want %s",
root.VCS, info.vcs.Kind())
+ }
+
+ // The rest of this function is also taken directly from
+ // the downloadPackage funct...