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

Commit bc90972

Browse files
committed
internal/gps: export PruneProject and fix minor nits
Signed-off-by: Ibrahim AshShohail <[email protected]>
1 parent 20907fd commit bc90972

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

internal/gps/prune.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package gps
66

77
import (
8-
"fmt"
98
"log"
109
"os"
1110
"path/filepath"
@@ -70,9 +69,9 @@ func Prune(baseDir string, options PruneOptions, l Lock, logger *log.Logger) err
7069
return nil
7170
}
7271

73-
// pruneProject remove excess files according to the options passed, from
72+
// PruneProject remove excess files according to the options passed, from
7473
// the lp directory in baseDir.
75-
func pruneProject(baseDir string, lp LockedProject, options PruneOptions, logger *log.Logger) error {
74+
func PruneProject(baseDir string, lp LockedProject, options PruneOptions, logger *log.Logger) error {
7675
projectDir := filepath.Join(baseDir, string(lp.Ident().ProjectRoot))
7776

7877
if (options & PruneNestedVendorDirs) != 0 {
@@ -158,7 +157,6 @@ func calculateUnusedPackages(lp LockedProject, projectDir string) (map[string]st
158157
if err != nil {
159158
return errors.Wrap(err, "unexpected error while calculating unused packages")
160159
}
161-
fmt.Println(pkg)
162160

163161
if _, ok := imported[pkg]; !ok {
164162
unused[pkg] = struct{}{}
@@ -174,7 +172,6 @@ func calculateUnusedPackages(lp LockedProject, projectDir string) (map[string]st
174172
func collectUnusedPackagesFiles(projectDir string, unusedPackages map[string]struct{}) ([]string, error) {
175173
// TODO(ibrasho): is this useful?
176174
files := make([]string, 0, len(unusedPackages))
177-
fmt.Println(unusedPackages)
178175

179176
err := filepath.Walk(projectDir, func(path string, info os.FileInfo, err error) error {
180177
if err != nil {
@@ -256,9 +253,7 @@ func collectNonGoFiles(baseDir string, logger *log.Logger) ([]string, error) {
256253
}
257254

258255
// isPreservedFile checks if the file name idicates that the file should be
259-
// preserved.
260-
// isPreservedFile checks if the file name contains one of the prefixes in
261-
// licenseFilePrefixes or contains one of the legalFileSubstrings entries.
256+
// preserved based on licenseFilePrefixes or legalFileSubstrings.
262257
func isPreservedFile(name string) bool {
263258
name = strings.ToLower(name)
264259

@@ -279,7 +274,7 @@ func isPreservedFile(name string) bool {
279274

280275
// pruneGoTestFiles deletes all Go test files (*_test.go) within baseDir.
281276
func pruneGoTestFiles(baseDir string, logger *log.Logger) error {
282-
files, err := collectGoTestsFile(baseDir)
277+
files, err := collectGoTestFiles(baseDir)
283278
if err != nil {
284279
return errors.Wrap(err, "could not collect Go test files")
285280
}
@@ -291,9 +286,9 @@ func pruneGoTestFiles(baseDir string, logger *log.Logger) error {
291286
return nil
292287
}
293288

294-
// collectGoTestsFile returns a slice contains all Go test files (any files
289+
// collectGoTestFiles returns a slice contains all Go test files (any files
295290
// prefixed with _test.go) in baseDir.
296-
func collectGoTestsFile(baseDir string) ([]string, error) {
291+
func collectGoTestFiles(baseDir string) ([]string, error) {
297292
files := make([]string, 0)
298293

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

0 commit comments

Comments
 (0)