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

Commit 9d269a6

Browse files
authored
Merge pull request #1226 from ibrasho-forks/add-prune-options-to-manifest
Add prune options to manifest
2 parents 3670e70 + b439b8d commit 9d269a6

File tree

6 files changed

+372
-74
lines changed

6 files changed

+372
-74
lines changed

Gopkg.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@
3030
[[constraint]]
3131
name = "github.com/golang/protobuf"
3232
branch = "master"
33+
34+
[prune]
35+
non-go = true
36+
go-tests = true
37+
unused-packages = true

analyzer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestAnalyzerDeriveManifestAndLock(t *testing.T) {
3838
t.Fatal(err)
3939
}
4040
} else {
41-
t.Fatalf("expected %s\n got %s", want, string(got))
41+
t.Fatalf("(WNT):\n%s\n(GOT):\n%s", want, string(got))
4242
}
4343
}
4444

gps/prune.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ import (
1616
// PruneOptions represents the pruning options used to write the dependecy tree.
1717
type PruneOptions uint8
1818

19+
// PruneProjectOptions is map of prune options per project name.
20+
type PruneProjectOptions map[ProjectRoot]PruneOptions
21+
1922
const (
2023
// PruneNestedVendorDirs indicates if nested vendor directories should be pruned.
21-
PruneNestedVendorDirs = 1 << iota
24+
PruneNestedVendorDirs PruneOptions = 1 << iota
2225
// PruneUnusedPackages indicates if unused Go packages should be pruned.
2326
PruneUnusedPackages
2427
// PruneNonGoFiles indicates if non-Go files should be pruned.
@@ -137,7 +140,6 @@ func pruneUnusedPackages(lp LockedProject, projectDir string, logger *log.Logger
137140

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

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

178179
err := filepath.Walk(projectDir, func(path string, info os.FileInfo, err error) error {

hack/lint.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ set -e
99
PKGS=$(go list ./... | grep -vF /vendor/)
1010
go vet $PKGS
1111
golint $PKGS
12-
megacheck -unused.exported -ignore "github.com/golang/dep/internal/test/test.go:U1000 github.com/golang/dep/gps/prune.go:U1000" $PKGS
12+
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

0 commit comments

Comments
 (0)