Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Commit

Permalink
Merge branch 'save_verbose'
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Muller committed Jan 19, 2016
2 parents 26e6c63 + ba96627 commit d84b24d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v50 2016/01/19

* More verbose output on save -v.

# v49 2016/01/13

* Add UK spelling license/licence to the pile + fix up a bunch of typos
Expand Down
1 change: 0 additions & 1 deletion list.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func findDirForPath(path string, ip *build.Package) (string, error) {

// fillPackage full of info. Assumes p.Dir is set at a minimum
func fillPackage(p *build.Package) error {

if p.Goroot {
return nil
}
Expand Down
43 changes: 32 additions & 11 deletions save.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ func save(pkgs []string) error {
if err != nil {
return err
}
debugln("goVersion:", cv)
verboseln("Go Version:", cv)

gold, err := loadDefaultGodepsFile()
if err != nil {
if !os.IsNotExist(err) {
return err
}
verboseln("No old Godeps.json found.")
gold.GoVersion = cv
}

Expand All @@ -138,17 +139,23 @@ func save(pkgs []string) error {
gnew.Packages = pkgs
}

verboseln("Finding dependencies for", pkgs)
a, err := LoadPackages(pkgs...)
if err != nil {
return err
}
debugln("Project Packages", pkgs)

for _, p := range a {
verboseln("Found package:", p.ImportPath)
verboseln("\tDeps:", strings.Join(p.Deps, " "))
}
ppln(a)

projA := projectPackages(dp.Dir, a)
debugln("Filtered projectPackages")
ppln(projA)

verboseln("Computing new Godeps.json file")
err = gnew.fill(a, dp.ImportPath)
if err != nil {
return err
Expand Down Expand Up @@ -185,24 +192,38 @@ func save(pkgs []string) error {
if err != nil {
return err
}

verboseln("Computing diff between old and new deps")
// We use a name starting with "_" so the go tool
// ignores this directory when traversing packages
// starting at the project's root. For example,
// godep go list ./...
srcdir := filepath.FromSlash(strings.Trim(sep, "/"))
rem := subDeps(gold.Deps, gnew.Deps)
debugln("Deps to remove")
ppln(rem)
add := subDeps(gnew.Deps, gold.Deps)
debugln("Deps to add")
ppln(add)
err = removeSrc(srcdir, rem)
if err != nil {
return err
if len(rem) > 0 {
verboseln("Deps to remove:")
for _, r := range rem {
verboseln("\t", r.ImportPath)
}
verboseln("Removing unused dependencies")
err = removeSrc(srcdir, rem)
if err != nil {
return err
}
}
err = copySrc(srcdir, add)
if err != nil {
return err
if len(add) > 0 {
verboseln("Deps to add:")
for _, a := range add {
verboseln("\t", a.ImportPath)
}
verboseln("Adding new dependencies")
err = copySrc(srcdir, add)
if err != nil {
return err
}
}
if !VendorExperiment {
f, _ := filepath.Split(srcdir)
Expand All @@ -214,7 +235,7 @@ func save(pkgs []string) error {
rewritePaths = append(rewritePaths, dep.ImportPath)
}
}
debugln("rewritePaths")
verboseln("Rewriting paths (if necessary)")
ppln(rewritePaths)
return rewrite(projA, dp.ImportPath, rewritePaths)
}
Expand Down
3 changes: 1 addition & 2 deletions save_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ var (
import (
{{range .Imports}} {{printf "%q" .}}
{{end}})
`)) //`Hack: Fix Atom highlighting

`))
)

func pkg(name string, imports ...string) string {
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime"
)

const version = 49
const version = 50

var cmdVersion = &Command{
Name: "version",
Expand Down

0 comments on commit d84b24d

Please sign in to comment.