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

Add prune options to manifest #1226

Merged
merged 5 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@
[[constraint]]
name = "github.com/golang/protobuf"
branch = "master"

[prune]
non-go = true
go-tests = true
unused-packages = true
2 changes: 1 addition & 1 deletion analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestAnalyzerDeriveManifestAndLock(t *testing.T) {
t.Fatal(err)
}
} else {
t.Fatalf("expected %s\n got %s", want, string(got))
t.Fatalf("(WNT):\n%s\n(GOT):\n%s", want, string(got))
}
}

Expand Down
7 changes: 4 additions & 3 deletions gps/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import (
// PruneOptions represents the pruning options used to write the dependecy tree.
type PruneOptions uint8

// PruneProjectOptions is map of prune options per project name.
type PruneProjectOptions map[ProjectRoot]PruneOptions

const (
// PruneNestedVendorDirs indicates if nested vendor directories should be pruned.
PruneNestedVendorDirs = 1 << iota
PruneNestedVendorDirs PruneOptions = 1 << iota
// PruneUnusedPackages indicates if unused Go packages should be pruned.
PruneUnusedPackages
// PruneNonGoFiles indicates if non-Go files should be pruned.
Expand Down Expand Up @@ -137,7 +140,6 @@ func pruneUnusedPackages(lp LockedProject, projectDir string, logger *log.Logger

// calculateUnusedPackages generates a list of unused packages in lp.
func calculateUnusedPackages(lp LockedProject, projectDir string) (map[string]struct{}, error) {
// TODO(ibrasho): optimize this...
unused := make(map[string]struct{})
imported := make(map[string]struct{})
for _, pkg := range lp.Packages() {
Expand Down Expand Up @@ -172,7 +174,6 @@ func calculateUnusedPackages(lp LockedProject, projectDir string) (map[string]st

// collectUnusedPackagesFiles returns a slice of all files in the unused packages in projectDir.
func collectUnusedPackagesFiles(projectDir string, unusedPackages map[string]struct{}) ([]string, error) {
// TODO(ibrasho): is this useful?
files := make([]string, 0, len(unusedPackages))

err := filepath.Walk(projectDir, func(path string, info os.FileInfo, err error) error {
Expand Down
2 changes: 1 addition & 1 deletion hack/lint.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ set -e
PKGS=$(go list ./... | grep -vF /vendor/)
go vet $PKGS
golint $PKGS
megacheck -unused.exported -ignore "github.com/golang/dep/internal/test/test.go:U1000 github.com/golang/dep/gps/prune.go:U1000" $PKGS
megacheck -unused.exported -ignore "github.com/golang/dep/internal/test/test.go:U1000 github.com/golang/dep/gps/prune.go:U1000 github.com/golang/dep/manifest.go:U1000" $PKGS
Loading