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

Commit

Permalink
I am lost in a sea of circ deps
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynvs committed May 10, 2017
1 parent 9705cf2 commit fd6d7ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
27 changes: 14 additions & 13 deletions internal/gopathAnalyzer.go → cmd/dep/gopathAnalyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,38 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package internal
package main

import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/golang/dep"
"github.com/golang/dep/gps/pkgtree"
"github.com/golang/dep/internal/gps"
"github.com/pkg/errors"
"github.com/golang/dep"
)

// GopathAnalyzer deduces configuration from the projects in the GOPATH
type GopathAnalyzer struct {
// gopathAnalyzer deduces configuration from the projects in the GOPATH
type gopathAnalyzer struct {
Ctx *dep.Ctx
PkgT pkgtree.PackageTree
Cpr string
SM *gps.SourceMgr
}

func NewGopathAnalyzer(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.SourceMgr) GopathAnalyzer {
return GopathAnalyzer{
func newGopathAnalyzer(ctx *dep.Ctx, pkgT pkgtree.PackageTree, cpr string, sm *gps.SourceMgr) gopathAnalyzer {
return gopathAnalyzer{
Ctx: ctx,
PkgT: pkgtree,
Cpr: cpr,
SM: sm,
}
}

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

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

Vlogf("Found import of %q, analyzing...", ip)
internal.Vlogf("Found import of %q, analyzing...", ip)

dependencies[pr] = []string{ip}
v, err := ctx.VersionInWorkspace(pr)
if err != nil {
notondisk[pr] = true
Vlogf("Could not determine version for %q, omitting from generated manifest", pr)
internal.Vlogf("Could not determine version for %q, omitting from generated manifest", pr)
continue
}

ondisk[pr] = v
constraints[pr] = getProjectPropertiesFromVersion(v)
}

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

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

func trimPathPrefix(p1, p2 string) string {
if HasFilepathPrefix(p1, p2) {
if internal.HasFilepathPrefix(p1, p2) {
return p1[len(p2):]
}
return p1
Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ func (cmd *initCommand) Run(ctx *dep.Ctx, loggers *Loggers, args []string) error
var rootAnalyzer internal.RootProjectAnalyzer
var analyzer gps.ProjectAnalyzer
if cmd.skipTools {
rootAnalyzer = internal.NewGopathAnalyzer(ctx, pkgtree, cpr, sm)
rootAnalyzer = newGopathAnalyzer(ctx, pkgtree, cpr, sm)
analyzer = dep.Analyzer{}
} else {
rootAnalyzer = internal.CompositeAnalyzer{
Analyzers: []internal.RootProjectAnalyzer{
internal.NewGopathAnalyzer(ctx, pkgtree, cpr, sm),
newGopathAnalyzer(ctx, pkgtree, cpr, sm),
internal.ImportAnalyzer{},
}}
analyzer = internal.ImportAnalyzer{}
Expand Down

0 comments on commit fd6d7ff

Please sign in to comment.