From 9697a00d8ec00e78f7d3c1deb3aae2aa4739955d Mon Sep 17 00:00:00 2001 From: Edward Muller Date: Thu, 14 Jan 2016 10:41:28 -0800 Subject: [PATCH 1/2] Better verbose output for save. Report on the top level actions and their outcomes. Fixes #388 (or at least the reported issue) --- list.go | 1 - save.go | 43 ++++++++++++++++++++++++++++++++----------- save_test.go | 3 +-- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/list.go b/list.go index 3cc6fb1..04ffe37 100644 --- a/list.go +++ b/list.go @@ -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 } diff --git a/save.go b/save.go index 3138219..65f931e 100644 --- a/save.go +++ b/save.go @@ -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 } @@ -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 @@ -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) @@ -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) } diff --git a/save_test.go b/save_test.go index ea64346..ec6b054 100644 --- a/save_test.go +++ b/save_test.go @@ -29,8 +29,7 @@ var ( import ( {{range .Imports}} {{printf "%q" .}} {{end}}) -`)) //`Hack: Fix Atom highlighting - +`)) ) func pkg(name string, imports ...string) string { From ba966274fd3a6878aaeea20948bca9ea6101f4c8 Mon Sep 17 00:00:00 2001 From: Edward Muller Date: Tue, 19 Jan 2016 14:23:55 -0800 Subject: [PATCH 2/2] Bump Version --- Changelog.md | 4 ++++ version.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index f509e3b..2dd1d26 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/version.go b/version.go index 56a7e27..7396411 100644 --- a/version.go +++ b/version.go @@ -5,7 +5,7 @@ import ( "runtime" ) -const version = 49 +const version = 50 var cmdVersion = &Command{ Name: "version",