fix/nonascii_attributes #69
|  | @ -43,12 +43,12 @@ func main() { | |||
| 	showVersion := flag.Bool("version", false, "print current version") | ||||
| 	rootDir := flag.String("root", ".", "root dir for forbidden files check") | ||||
| 	repoSize := flag.Float64("repoSize", 2, "maximum size of the repo in MiB") | ||||
| 	// TODO: remove gitWhitelist, it is only for backward compatibility now
 | ||||
| 	// TODO: remove git whitelist, it is only for backward compatibility now
 | ||||
| 
					
					zzjc123 marked this conversation as resolved
					
						
						
							Outdated
						
					
				 | ||||
| 	localList := flag.String("localList", "", "local file list for non-ascii file check") | ||||
| 	checkFileNameList := flag.String("checkFileNameList", "", "comma-separated list of files to check") | ||||
| 	checkFileSumList := flag.String("checkFileSumList", "", "comma-separated list of expected checksums") | ||||
| 	parseMultiValueFlag(&metaFile, "meta", "meta files to check") | ||||
| 	// TODO: remove gitWhitelist, it is only for backward compatibility now
 | ||||
| 	// TODO: remove git whitelist, it is only for backward compatibility now
 | ||||
| 	var gitWhitelist []string | ||||
| 	parseMultiValueFlag(&gitWhitelist, "whitelist", "[DEPRECATED] will be ignored") | ||||
| 	flag.Parse() | ||||
|  |  | |||
|  | @ -16,14 +16,14 @@ 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 | ||||
| 	gitattrExist := true | ||||
| 
					
					zzjc123 marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  the naming is weird, we need to think what is  the naming is weird, we need to think what is `!noAttri`. Just sth like `gitattributesExist`. | ||||
| 	var matcher gitattributes.Matcher | ||||
| 	_, err := os.Stat(".gitattributes") | ||||
| 	if os.IsNotExist(err) { | ||||
| 		noAttri = true | ||||
| 		gitattrExist = false | ||||
| 	} | ||||
| 
 | ||||
| 	if !noAttri { | ||||
| 	if gitattrExist { | ||||
| 		fs := os.DirFS(".") | ||||
| 		f, err := fs.Open(".gitattributes") | ||||
| 		if err != nil { | ||||
|  | @ -43,25 +43,19 @@ func getNonAscii(root string) ([]string, error) { | |||
| 		} | ||||
| 
 | ||||
| 		if info.IsDir() { | ||||
| 			if info.Name() == ".git" || info.Name() == ".gitea" { | ||||
| 			if info.Name() == ".git" { | ||||
| 
					
					zzjc123 marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  Can we check the  Can we check the `.gitea` dir now? | ||||
| 				return filepath.SkipDir | ||||
| 			} else { | ||||
| 				return nil | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if info.Name() == "healthcheck" { | ||||
| 			return nil | ||||
| 		} | ||||
| 
 | ||||
| 		if !noAttri { | ||||
| 		if gitattrExist { | ||||
| 			relPath, err := filepath.Rel(root, path) | ||||
| 
					
					zzjc123 marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  and can this healthcheck skip be removed now? and can this healthcheck skip be removed now? 
				
					
						周赵嘉程521432910016
						commented  no we can't for now. no we can't for now. 
				
					
						张泊明518370910136
						commented  what about now? what about now? 
				
					
						周赵嘉程521432910016
						commented  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. 
				
					
						周赵嘉程521432910016
						commented  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. 
				
					
						周赵嘉程521432910016
						commented  it got fixed. it got fixed. | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 			str := strings.Split(relPath, "/") | ||||
| 			_, ret := matcher.Match(str, nil) | ||||
| 			if ret { | ||||
| 			if _, ret := matcher.Match(strings.Split(relPath, "/"), nil); ret { | ||||
| 
					
					zzjc123 marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  this line is too long now, should make it in two lines. this line is too long now, should make it in two lines. | ||||
| 				return nil | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	
typo here
i mean it should be "remove localList" here, and "remove gitWhitelist“ down there