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

Commit fd6d7ff

Browse files
committed
I am lost in a sea of circ deps
1 parent 9705cf2 commit fd6d7ff

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

internal/gopathAnalyzer.go cmd/dep/gopathAnalyzer.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,38 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
package internal
5+
package main
66

77
import (
88
"fmt"
99
"os"
1010
"path/filepath"
1111
"strings"
1212

13+
"github.com/golang/dep"
1314
"github.com/golang/dep/gps/pkgtree"
15+
"github.com/golang/dep/internal/gps"
1416
"github.com/pkg/errors"
15-
"github.com/golang/dep"
1617
)
1718

18-
// GopathAnalyzer deduces configuration from the projects in the GOPATH
19-
type GopathAnalyzer struct {
19+
// gopathAnalyzer deduces configuration from the projects in the GOPATH
20+
type gopathAnalyzer struct {
2021
Ctx *dep.Ctx
2122
PkgT pkgtree.PackageTree
2223
Cpr string
2324
SM *gps.SourceMgr
2425
}
2526

26-
func NewGopathAnalyzer(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.SourceMgr) GopathAnalyzer {
27-
return GopathAnalyzer{
27+
func newGopathAnalyzer(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.SourceMgr) gopathAnalyzer {
28+
return gopathAnalyzer{
2829
Ctx: ctx,
2930
PkgT: pkgtree,
3031
Cpr: cpr,
3132
SM: sm,
3233
}
3334
}
3435

35-
func (a GopathAnalyzer) DeriveRootManifestAndLock(path string, n gps.ProjectRoot) (gps.RootManifest, gps.Lock, error) {
36+
func (a gopathAnalyzer) DeriveRootManifestAndLock(path string, n gps.ProjectRoot) (gps.RootManifest, gps.Lock, error) {
3637
pd, err := getProjectData(a.Ctx, a.PkgT, a.Cpr, a.SM)
3738
if err != nil {
3839
return nil, nil, err
@@ -96,7 +97,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
9697
return projectData{}, nil
9798
}
9899

99-
Vlogf("Building dependency graph...")
100+
internal.Vlogf("Building dependency graph...")
100101
// Exclude stdlib imports from the list returned from Flatten().
101102
const omitStdlib = false
102103
for _, ip := range rm.Flatten(omitStdlib) {
@@ -112,21 +113,21 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
112113
}
113114
go syncDep(pr, sm)
114115

115-
Vlogf("Found import of %q, analyzing...", ip)
116+
internal.Vlogf("Found import of %q, analyzing...", ip)
116117

117118
dependencies[pr] = []string{ip}
118119
v, err := ctx.VersionInWorkspace(pr)
119120
if err != nil {
120121
notondisk[pr] = true
121-
Vlogf("Could not determine version for %q, omitting from generated manifest", pr)
122+
internal.Vlogf("Could not determine version for %q, omitting from generated manifest", pr)
122123
continue
123124
}
124125

125126
ondisk[pr] = v
126127
constraints[pr] = getProjectPropertiesFromVersion(v)
127128
}
128129

129-
Vlogf("Analyzing transitive imports...")
130+
internal.Vlogf("Analyzing transitive imports...")
130131
// Explore the packages we've found for transitive deps, either
131132
// completing the lock or identifying (more) missing projects that we'll
132133
// need to ask gps to solve for us.
@@ -145,7 +146,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
145146
dft = func(pkg string) error {
146147
switch colors[pkg] {
147148
case white:
148-
Vlogf("Analyzing %q...", pkg)
149+
internal.Vlogf("Analyzing %q...", pkg)
149150
colors[pkg] = grey
150151

151152
pr, err := sm.DeduceProjectRoot(pkg)
@@ -269,7 +270,7 @@ func getProjectData(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.
269270
}
270271

271272
func trimPathPrefix(p1, p2 string) string {
272-
if HasFilepathPrefix(p1, p2) {
273+
if internal.HasFilepathPrefix(p1, p2) {
273274
return p1[len(p2):]
274275
}
275276
return p1

cmd/dep/init.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, loggers *Loggers, args []string) error
113113
var rootAnalyzer internal.RootProjectAnalyzer
114114
var analyzer gps.ProjectAnalyzer
115115
if cmd.skipTools {
116-
rootAnalyzer = internal.NewGopathAnalyzer(ctx, pkgtree, cpr, sm)
116+
rootAnalyzer = newGopathAnalyzer(ctx, pkgtree, cpr, sm)
117117
analyzer = dep.Analyzer{}
118118
} else {
119119
rootAnalyzer = internal.CompositeAnalyzer{
120120
Analyzers: []internal.RootProjectAnalyzer{
121-
internal.NewGopathAnalyzer(ctx, pkgtree, cpr, sm),
121+
newGopathAnalyzer(ctx, pkgtree, cpr, sm),
122122
internal.ImportAnalyzer{},
123123
}}
124124
analyzer = internal.ImportAnalyzer{}

0 commit comments

Comments
 (0)