Make sure Set.GoFiles() is sorted. and other cosmetic code changes.
diff --git a/cmd/pcg/main.go b/cmd/pcg/main.go index 1ef0765..71924d1 100644 --- a/cmd/pcg/main.go +++ b/cmd/pcg/main.go
@@ -393,7 +393,7 @@ // Commands. -func (a *application) cmdHelp(repo scm.ReadOnlyRepo, usage string) error { +func (a *application) cmdHelp(usage string) error { s := &struct { Usage string Max int @@ -574,7 +574,6 @@ // cmdRun runs all the enabled checks. func (a *application) cmdRun(repo scm.ReadOnlyRepo, modes []checks.Mode, against string, prereqReady *sync.WaitGroup) error { - var err error var old scm.Commit if against != "" { if old = repo.Eval(against); old == scm.Invalid { @@ -671,7 +670,7 @@ b := &bytes.Buffer{} fs.SetOutput(b) fs.PrintDefaults() - _ = a.cmdHelp(nil, b.String()) + _ = a.cmdHelp(b.String()) } verboseFlag := fs.Bool("v", checks.IsContinuousIntegration() || os.Getenv("VERBOSE") != "", "enables verbose logging output") allFlag := fs.Bool("a", false, "runs checks as if all files had been modified") @@ -739,7 +738,7 @@ b := &bytes.Buffer{} fs.SetOutput(b) fs.PrintDefaults() - return a.cmdHelp(repo, b.String()) + return a.cmdHelp(b.String()) case "info": if *allFlag != false {
diff --git a/scm/change.go b/scm/change.go index 5ff1a73..7d91de1 100644 --- a/scm/change.go +++ b/scm/change.go
@@ -1,4 +1,4 @@ -// Copyright 2015 Marc-Antoine Ruel. All rights reserved. +// Copyright 2016 Marc-Antoine Ruel. All rights reserved. // Use of this source code is governed under the Apache License, Version 2.0 // that can be found in the LICENSE file. @@ -48,6 +48,8 @@ // Set is a subset of files/directories/packages relative to the change and the // overall repository. +// +// Each list is guaranteed to be sorted according to sort.StringsAreStored(). type Set interface { // GoFiles returns all the source files, including tests. GoFiles() []string @@ -153,7 +155,11 @@ // Still need to sort these since "." will not be at the right place. var wg sync.WaitGroup - wg.Add(4) + wg.Add(6) + go func() { + defer wg.Done() + sort.Strings(c.direct.files) + }() go func() { defer wg.Done() sort.Strings(c.direct.packages) @@ -164,6 +170,10 @@ }() go func() { defer wg.Done() + sort.Strings(c.all.files) + }() + go func() { + defer wg.Done() sort.Strings(c.all.packages) }() go func() { @@ -273,7 +283,12 @@ } } } - wg.Add(2) + wg.Add(3) + go func() { + defer wg.Done() + // TODO(maruel): This is not updated properly. + sort.Strings(c.indirect.files) + }() go func() { defer wg.Done() sort.Strings(c.indirect.packages) @@ -328,6 +343,9 @@ return c.ignorePatterns.Match(p) } +// set implements Set. +// +// Items must be sorted. type set struct { files []string packages []string
diff --git a/scm/repo.go b/scm/repo.go index bfcc474..b4aface 100644 --- a/scm/repo.go +++ b/scm/repo.go
@@ -1,4 +1,4 @@ -// Copyright 2015 Marc-Antoine Ruel. All rights reserved. +// Copyright 2016 Marc-Antoine Ruel. All rights reserved. // Use of this source code is governed under the Apache License, Version 2.0 // that can be found in the LICENSE file. @@ -107,6 +107,7 @@ for _, ignorePattern := range *i { for _, chunk := range chunks { if matched, err := filepath.Match(ignorePattern, chunk); matched { + log.Printf("%s: ignored due to %q", p, ignorePattern) return true } else if err != nil { log.Printf("bad pattern %q", ignorePattern)