diff options
Diffstat (limited to 'gitignore.go')
| -rw-r--r-- | gitignore.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gitignore.go b/gitignore.go new file mode 100644 index 0000000..f6816bd --- /dev/null +++ b/gitignore.go @@ -0,0 +1,22 @@ +package main + +import ( + "os" + "path/filepath" + + ignore "github.com/sabhiram/go-gitignore" +) + +func loadGitignore(hostDir string) (*ignore.GitIgnore, error) { + gitignorePath := filepath.Join(hostDir, ".gitignore") + + data, err := os.ReadFile(gitignorePath) + if err != nil { + if os.IsNotExist(err) { + return ignore.CompileIgnoreLines(), nil + } + return nil, err + } + + return ignore.CompileIgnoreLines(string(data)), nil +} |
