Skip to content

Commit

Permalink
Tolerate .git directory when checking if dir is empty
Browse files Browse the repository at this point in the history
Many users will be running version control; we should ignore .git
directories also therefore.
  • Loading branch information
justinsb committed Jan 15, 2021
1 parent 1001d36 commit 32b36fb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/plugins/golang/v3/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,16 @@ func checkDir() error {
if err != nil {
return err
}
// Allow the whole .git directory tree
if info.Name() == ".git" {
return filepath.SkipDir
}
// Also allow go.mod and dot-files
if info.Name() != "go.mod" && !strings.HasPrefix(info.Name(), ".") {
return fmt.Errorf(
"target directory is not empty (only go.mod and files with the prefix \".\" are allowed); found existing file %q",
"target directory is not empty "+
"(only go.mod, files with the prefix \".\" and .git directories are allowed); "+
"found existing file %q",
path)
}
return nil
Expand Down

0 comments on commit 32b36fb

Please sign in to comment.