Files
cliprepo/internal/tree/ignore.go
T
2026-05-16 01:39:45 +08:00

19 lines
351 B
Go

package tree
import (
"os"
"path/filepath"
ignore "github.com/sabhiram/go-gitignore"
)
// Load 加载 .gitignore
func Load(root string) (*ignore.GitIgnore, error) {
path := filepath.Join(root, ".gitignore")
if _, err := os.Stat(path); os.IsNotExist(err) {
return ignore.CompileIgnoreLines(), nil
}
return ignore.CompileIgnoreFile(path)
}