feat: repo health check (#16) #17
|  | @ -37,13 +37,13 @@ func checkFileChecksum(rootDir, fileName, expectedChecksum string) (bool, string | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if actualChecksum == expectedChecksum { | 	if actualChecksum == expectedChecksum { | ||||||
| 		return true, ""//fmt.Sprintf("Checksum for %s passed!", filePath)
 | 		return true, "" // fmt.Sprintf("Checksum for %s passed!", filePath)
 | ||||||
| 
					
					bomingzh marked this conversation as resolved
					
						
						
							Outdated
						
					
				 | |||||||
| 	} else { | 	} else { | ||||||
| 		return false, fmt.Sprintf("Checksum for %s failed. Expected %s, but got %s. Please revert your changes or contact the teaching team if you have a valid reason for adjusting them.", filePath, expectedChecksum, actualChecksum) | 		return false, fmt.Sprintf("Checksum for %s failed. Expected %s, but got %s. Please revert your changes or contact the teaching team if you have a valid reason for adjusting them.", filePath, expectedChecksum, actualChecksum) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList string ) error { | func VerifyFiles(rootDir string, checkFileNameList string, checkFileSumList string) error { | ||||||
| 	// Parse command-line arguments
 | 	// Parse command-line arguments
 | ||||||
| 
					
					bomingzh marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  ditto ditto | |||||||
| 	// checkFileNameList := flag.String("checkFileNameList", "", "Comma-separated list of files to check.")
 | 	// checkFileNameList := flag.String("checkFileNameList", "", "Comma-separated list of files to check.")
 | ||||||
| 	// checkFileSumList := flag.String("checkFileSumList", "", "Comma-separated list of expected checksums.")
 | 	// checkFileSumList := flag.String("checkFileSumList", "", "Comma-separated list of expected checksums.")
 | ||||||
|  | @ -51,7 +51,7 @@ func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList strin | ||||||
| 	// flag.Parse()
 | 	// flag.Parse()
 | ||||||
| 	// Process input file names and checksums
 | 	// Process input file names and checksums
 | ||||||
| 	if len(checkFileNameList) == 0 { | 	if len(checkFileNameList) == 0 { | ||||||
| 		return nil//fmt.Errorf("No checksum happened")
 | 		return nil // fmt.Errorf("No checksum happened")
 | ||||||
| 		os.Exit(1) | 		os.Exit(1) | ||||||
| 
					
					bomingzh marked this conversation as resolved
					
						
						
							Outdated
						
					
				 
				
					
						张泊明518370910136
						commented  remove it remove it | |||||||
| 	} | 	} | ||||||
| 	fileNames := strings.Split(checkFileNameList, ",") | 	fileNames := strings.Split(checkFileNameList, ",") | ||||||
|  | @ -59,7 +59,6 @@ func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList strin | ||||||
| 
 | 
 | ||||||
| 	// Check if the number of files matches the number of checksums
 | 	// Check if the number of files matches the number of checksums
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	if len(fileNames) != len(checkSums) { | 	if len(fileNames) != len(checkSums) { | ||||||
| 		return fmt.Errorf("Error: The number of files and checksums do not match.") | 		return fmt.Errorf("Error: The number of files and checksums do not match.") | ||||||
| 		os.Exit(1) | 		os.Exit(1) | ||||||
| 
				
					
						张泊明518370910136
						commented  remove it remove it 
				
					
						张泊明518370910136
						commented  I mean remove the  I mean remove the `os.Exit(1)`, and also the one on line 55. | |||||||
|  | @ -80,9 +79,8 @@ func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList strin | ||||||
| 			errorMessages = append(errorMessages, message) | 			errorMessages = append(errorMessages, message) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	fmt.Printf("test") |  | ||||||
| 	if allPassed { | 	if allPassed { | ||||||
| 		return nil//fmt.Errorf("Congratulations! All checksums passed!")
 | 		return nil // fmt.Errorf("Congratulations! All checksums passed!")
 | ||||||
| 
				
					
						张泊明518370910136
						commented  ditto ditto | |||||||
| 	} else { | 	} else { | ||||||
| 		return fmt.Errorf("Some checksums failed. Please review the errors below:") | 		return fmt.Errorf("Some checksums failed. Please review the errors below:") | ||||||
| 
				
					
						张泊明518370910136
						commented  Why so many returns? Why so many returns? | |||||||
| 		for _, msg := range errorMessages { | 		for _, msg := range errorMessages { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	
remove the comment