fix(healthcheck/nonasciifile): no gitattributes
This commit is contained in:
		
							parent
							
								
									c8f377245f
								
							
						
					
					
						commit
						decadeaef1
					
				
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							|  | @ -5,7 +5,6 @@ go 1.23.1 | |||
| require ( | ||||
| 	github.com/criyle/go-judge v1.8.5 | ||||
| 	github.com/denormal/go-gitignore v0.0.0-20180930084346-ae8ad1d07817 | ||||
| 	github.com/go-git/go-billy/v5 v5.5.0 | ||||
| 	github.com/go-git/go-git/v5 v5.12.0 | ||||
| 	github.com/jinzhu/copier v0.4.0 | ||||
| 	github.com/koding/multiconfig v0.0.0-20171124222453-69c27309b2d7 | ||||
|  | @ -28,6 +27,7 @@ require ( | |||
| 	github.com/fatih/camelcase v1.0.0 // indirect | ||||
| 	github.com/fatih/structs v1.1.0 // indirect | ||||
| 	github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect | ||||
| 	github.com/go-git/go-billy/v5 v5.5.0 // indirect | ||||
| 	github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||||
| 	github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect | ||||
| 	github.com/kevinburke/ssh_config v1.2.0 // indirect | ||||
|  |  | |||
|  | @ -16,6 +16,15 @@ import ( | |||
| // 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) { | ||||
| 	var nonAscii []string | ||||
| 	noAttri := false | ||||
| 	var matcher gitattributes.Matcher | ||||
| 	_, err := os.Stat(".gitattributes") | ||||
| 	if os.IsNotExist(err) { | ||||
| 		noAttri = true | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	if !noAttri { | ||||
| 		fs := os.DirFS(".") | ||||
| 		f, err := fs.Open(".gitattributes") | ||||
| 		if err != nil { | ||||
|  | @ -26,8 +35,8 @@ func getNonAscii(root string) ([]string, error) { | |||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 
 | ||||
| 	matcher := gitattributes.NewMatcher(attribute) | ||||
| 		matcher = gitattributes.NewMatcher(attribute) | ||||
| 	} | ||||
| 
 | ||||
| 	err = filepath.Walk(root, func(path string, info os.FileInfo, err error) error { | ||||
| 		if err != nil { | ||||
|  | @ -46,6 +55,7 @@ func getNonAscii(root string) ([]string, error) { | |||
| 			return nil | ||||
| 		} | ||||
| 
 | ||||
| 		if !noAttri { | ||||
| 			relPath, err := filepath.Rel(root, path) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
|  | @ -55,6 +65,7 @@ func getNonAscii(root string) ([]string, error) { | |||
| 			if ret { | ||||
| 				return nil | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		file, err := os.Open(path) | ||||
| 		if err != nil { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 zzjc1234
						zzjc1234