fix/nonascii_attributes #69
|
@ -9,7 +9,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/go-git/go-billy/v5/memfs"
|
|
||||||
"github.com/go-git/go-git/v5/plumbing/format/gitattributes"
|
"github.com/go-git/go-git/v5/plumbing/format/gitattributes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,11 +16,13 @@ import (
|
||||||
// It searches for non-ASCII characters in each file's content and returns a list of paths to files containing non-ASCII characters.
|
// It searches for non-ASCII characters in each file's content and returns a list of paths to files containing non-ASCII characters.
|
||||||
func getNonAscii(root string) ([]string, error) {
|
func getNonAscii(root string) ([]string, error) {
|
||||||
var nonAscii []string
|
var nonAscii []string
|
||||||
fs := memfs.New()
|
fs := os.DirFS(".")
|
||||||
rootPath := []string{"./"}
|
f, err := fs.Open(".gitattributes")
|
||||||
var emptyStr []string
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
attribute, err := gitattributes.ReadPatterns(fs, rootPath)
|
attribute, err := gitattributes.ReadAttributes(f, nil, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -45,7 +46,13 @@ func getNonAscii(root string) ([]string, error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ret := matcher.Match(rootPath, append(emptyStr, info.Name())); ret {
|
relPath, err := filepath.Rel(root, path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
str := strings.Split(relPath, "/")
|
||||||
|
_, ret := matcher.Match(str, nil)
|
||||||
|
if ret {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user