Skip to content

Commit

Permalink
Merge pull request #1944 from justinsb/tolerate_git_dir
Browse files Browse the repository at this point in the history
✨ Tolerate "dot" directories when checking if dir is empty
  • Loading branch information
k8s-ci-robot committed Jan 29, 2021
2 parents 14b27b4 + 4fd2cd7 commit e222f25
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/plugins/golang/v3/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,16 @@ func checkDir() error {
if err != nil {
return err
}
if info.Name() != "go.mod" && !strings.HasPrefix(info.Name(), ".") {
// Allow the whole .git directory tree
if info.IsDir() && strings.HasPrefix(info.Name(), ".") && info.Name() != "." {
return filepath.SkipDir
}
// Also allow go.mod and dot-files
if info.Name() != "go.mod" && info.Name() != "go.sum" && !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, go.sum, and files and directories with the prefix \".\" are allowed); "+
"found existing file %q",
path)
}
return nil
Expand Down

0 comments on commit e222f25

Please sign in to comment.