Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 443490c

Browse files
committed
Ignore gopath and existing tools in network mode
1 parent 45a4c94 commit 443490c

File tree

3 files changed

+34
-21
lines changed

3 files changed

+34
-21
lines changed

cmd/dep/init.go

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,29 +121,52 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
121121
sm.UseDefaultSignalHandling()
122122
defer sm.Release()
123123

124-
// Initialize with imported data, then fill in the gaps using the GOPATH
125-
rootAnalyzer := newRootAnalyzer(cmd.skipTools, ctx, directDeps, sm)
126-
m, l, err := rootAnalyzer.InitializeRootManifestAndLock(root, gps.ProjectRoot(cpr))
127-
if err != nil {
128-
return err
124+
// Create empty manifest and lock
125+
m := &dep.Manifest{
126+
Constraints: make(gps.ProjectConstraints),
127+
Ovr: make(gps.ProjectConstraints),
129128
}
129+
l := &dep.Lock{}
130130

131+
// Initialize rootAnalyzer and gopathScanner
132+
rootAnalyzer := newRootAnalyzer(cmd.skipTools, ctx, directDeps, sm)
131133
gs := newGopathScanner(ctx, directDeps, sm)
134+
135+
params := gps.SolveParameters{}
136+
132137
if cmd.gopath {
138+
// Initialize with imported data, then fill in the gaps using the GOPATH
139+
im, il, err := rootAnalyzer.InitializeRootManifestAndLock(root, gps.ProjectRoot(cpr))
140+
if err != nil {
141+
return err
142+
}
143+
144+
if im != nil {
145+
m = im
146+
}
147+
if il != nil {
148+
l = il
149+
}
150+
133151
err = gs.InitializeRootManifestAndLock(m, l)
134152
if err != nil {
135153
return err
136154
}
137-
}
138155

139-
rootAnalyzer.skipTools = true // Don't import external config during solve for now
156+
rootAnalyzer.skipTools = true // Don't import external config during solve for now
157+
}
140158

141-
params := gps.SolveParameters{
159+
params = gps.SolveParameters{
142160
RootDir: root,
143161
RootPackageTree: pkgT,
144162
Manifest: m,
145163
Lock: l,
146-
ProjectAnalyzer: rootAnalyzer,
164+
}
165+
166+
if cmd.gopath {
167+
params.ProjectAnalyzer = rootAnalyzer
168+
} else {
169+
params.ProjectAnalyzer = dep.Analyzer{}
147170
}
148171

149172
if ctx.Verbose {
@@ -162,8 +185,8 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, args []string) error {
162185
}
163186
l = dep.LockFromSolution(soln)
164187

165-
rootAnalyzer.FinalizeRootManifestAndLock(m, l)
166188
if cmd.gopath {
189+
rootAnalyzer.FinalizeRootManifestAndLock(m, l)
167190
gs.FinalizeRootManifestAndLock(m, l)
168191
} else {
169192
// Pick the direct dependencies from the above solution and add to manifest

cmd/dep/root_analyzer.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@ func (a *rootAnalyzer) InitializeRootManifestAndLock(dir string, pr gps.ProjectR
5252
}
5353
}
5454

55-
if rootM == nil {
56-
rootM = &dep.Manifest{
57-
Constraints: make(gps.ProjectConstraints),
58-
Ovr: make(gps.ProjectConstraints),
59-
}
60-
}
61-
if rootL == nil {
62-
rootL = &dep.Lock{}
63-
}
64-
6555
return
6656
}
6757

cmd/dep/testdata/harness_tests/init/glide/case1/testcase.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"commands": [
3-
["init", "-no-examples"]
3+
["init", "-no-examples", "-gopath"]
44
],
55
"error-expected": "",
66
"gopath-initial": {

0 commit comments

Comments
 (0)