fix/nonascii_attributes #69

Merged
张泊明518370910136 merged 11 commits from fix/nonascii_attributes into master 2024-10-21 17:04:53 +08:00
Showing only changes of commit 348eaa247c - Show all commits

View File

@ -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(".")
zzjc123 marked this conversation as resolved Outdated

the naming is weird, we need to think what is !noAttri. Just sth like gitattributesExist.

the naming is weird, we need to think what is `!noAttri`. Just sth like `gitattributesExist`.
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
zzjc123 marked this conversation as resolved Outdated

Can we check the .gitea dir now?

Can we check the `.gitea` dir now?
} }
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)
zzjc123 marked this conversation as resolved Outdated

and can this healthcheck skip be removed now?

and can this healthcheck skip be removed now?

no we can't for now.

no we can't for now.

what about now?

what about now?

what do you mean? for now we still need to copy the healthcheck bin into /w to run for test case. I don't now what's the better solution.

what do you mean? for now we still need to copy the healthcheck bin into /w to run for test case. I don't now what's the better solution.

oh sorry, I didn't see your commit. I will try it soon.

oh sorry, I didn't see your commit. I will try it soon.

it got fixed.

it got fixed.
if ret {
return nil return nil
} }
zzjc123 marked this conversation as resolved Outdated

this line is too long now, should make it in two lines.

this line is too long now, should make it in two lines.