Skip to content

Commit

Permalink
Make fileModified local (bazelbuild#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmos committed Dec 12, 2020
1 parent 351bc05 commit a9c0053
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions edit/buildozer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ func NewOpts() *Options {
// Usage is a user-overridden func to print the program usage.
var Usage = func() {}

var fileModified = false // set to true when a file has been fixed

const stdinPackageName = "-" // the special package name to represent stdin

// CmdEnvironment stores the information the commands below have access to.
Expand Down Expand Up @@ -1004,7 +1002,6 @@ func rewrite(opts *Options, commandsForFile commandsForFile) *rewriteResult {
return &rewriteResult{file: name, errs: []error{err}, records: records}
}

fileModified = true
return &rewriteResult{file: name, errs: errs, modified: true, records: records}
}

Expand Down Expand Up @@ -1235,13 +1232,15 @@ func Buildozer(opts *Options, args []string) int {
}
close(data)
records := []*apipb.Output_Record{}
hasErrors := false
var hasErrors bool
var fileModified bool
for i := 0; i < numFiles; i++ {
fileResults := <-results
if fileResults == nil {
continue
}
hasErrors = hasErrors || len(fileResults.errs) > 0
fileModified = fileModified || fileResults.modified
for _, err := range fileResults.errs {
fmt.Fprintf(opts.ErrWriter, "%s: %s\n", fileResults.file, err)
}
Expand Down

0 comments on commit a9c0053

Please sign in to comment.