feat: repo health check (#16) #17

Merged
张泊明518370910136 merged 37 commits from file_check into master 2024-09-11 20:09:27 +08:00
Showing only changes of commit 36b75ad578 - Show all commits

View File

@ -37,7 +37,7 @@ func checkFileChecksum(rootDir, fileName, expectedChecksum string) (bool, string
}
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

remove the comment

remove the comment
} else {
return false, fmt.Sprintf("Checksum for %s failed. Expected %s, but got %s. Please revert the changes!", filePath, expectedChecksum, actualChecksum)
}
@ -55,7 +55,7 @@ func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList strin
bomingzh marked this conversation as resolved Outdated

remove it

remove it
// Check if the number of files matches the number of checksums
if len(fileNames) == 0 {
return fmt.Errorf("No checksum happened")
return nil//fmt.Errorf("No checksum happened")
}
if len(fileNames) != len(checkSums) {
@ -70,15 +70,17 @@ func VerifyFiles(rootDir string,checkFileNameList string, checkFileSumList strin
for i, fileName := range fileNames {
expectedChecksum := strings.TrimSpace(checkSums[i])
passed, message := checkFileChecksum(rootDir, fileName, expectedChecksum)
return fmt.Errorf(message)
if message != "" {
return fmt.Errorf(message)
}
if !passed {
allPassed = false
errorMessages = append(errorMessages, message)
}
}
fmt.Printf("test")
if allPassed {
return fmt.Errorf("Congratulations! All checksums passed!")
return nil//fmt.Errorf("Congratulations! All checksums passed!")

ditto

ditto
} else {
return fmt.Errorf("Some checksums failed. Please review the errors below:")

Why so many returns?

Why so many returns?
for _, msg := range errorMessages {