first mvp
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user