This repository was archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 451
Respect the GO15VENDOREXPERIMENT env variable #244
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,8 @@ with the exact source control revision of each dependency, and copies | |
their source code into a subdirectory. | ||
|
||
The list is written to Godeps/Godeps.json, and source code for all | ||
dependencies is copied into Godeps/_workspace. | ||
dependencies is copied into either Godeps/_workspace or, if the vendor | ||
experiment it turned on, vendor. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/it/is/ |
||
|
||
The dependency list is a JSON document with the following structure: | ||
|
||
|
@@ -44,7 +45,8 @@ Any dependencies already present in the list will be left unchanged. | |
To update a dependency to a newer revision, use 'godep update'. | ||
|
||
If -r is given, import statements will be rewritten to refer | ||
directly to the copied source code. | ||
directly to the copied source code. This is not compatible with the | ||
vendor experiment. | ||
|
||
For more about specifying packages, see 'go help packages'. | ||
`, | ||
|
@@ -62,6 +64,10 @@ func init() { | |
} | ||
|
||
func runSave(cmd *Command, args []string) { | ||
if VendorExperiment && saveR { | ||
log.Println("flag -r is incompatible with the vendoring experiment") | ||
cmd.UsageExit() | ||
} | ||
if !saveCopy { | ||
log.Println("flag unsupported: -copy=false") | ||
cmd.UsageExit() | ||
|
@@ -145,8 +151,7 @@ func save(pkgs []string) error { | |
// ignores this directory when traversing packages | ||
// starting at the project's root. For example, | ||
// godep go list ./... | ||
workspace := filepath.Join("Godeps", "_workspace") | ||
srcdir := filepath.Join(workspace, "src") | ||
srcdir := filepath.FromSlash(strings.Trim(sep, "/")) | ||
rem := subDeps(gold.Deps, gnew.Deps) | ||
add := subDeps(gnew.Deps, gold.Deps) | ||
err = removeSrc(srcdir, rem) | ||
|
@@ -157,7 +162,10 @@ func save(pkgs []string) error { | |
if err != nil { | ||
return err | ||
} | ||
writeVCSIgnore(workspace) | ||
if !VendorExperiment { | ||
f, _ := filepath.Split(srcdir) | ||
writeVCSIgnore(f) | ||
} | ||
var rewritePaths []string | ||
if saveR { | ||
for _, dep := range gnew.Deps { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest the signature
defaultSep(experiment bool) string
for this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I likened it to flag handling, which is done elsewhere in init functions.
Are you suggesting that init should call
defaultSep(VendorExperiment)
to set sep or that everywhere sep is currently used it should be replaced withdefaultSep(VendorExperiment)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suggesting the first, e.g.
var sep = defaultSep(VendorExperiment)
.Flags are defined in init functions only because they have to to avoid a cycle. (Try changing it to
var saveR = cmdSave.Flag.Bool(...)
to see what happens.)