blob: f6816bd836cf1ed8eac5de13a17498c731a8089a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
}
|