diff --git a/internal/stage/util.go b/internal/stage/util.go index a061a1e..4c9f084 100644 --- a/internal/stage/util.go +++ b/internal/stage/util.go @@ -1,16 +1,12 @@ package stage -import ( - "fmt" - - "github.com/mitchellh/mapstructure" -) +import "github.com/mitchellh/mapstructure" func DecodeConf[T any](confAny any) (*T, error) { var conf T err := mapstructure.Decode(confAny, &conf) if err != nil { - return nil, fmt.Errorf("failed to decode conf: %w", err) + return nil, err } return &conf, nil } diff --git a/pkg/healthcheck/commit.go b/pkg/healthcheck/commit.go index 18ef47c..375046e 100644 --- a/pkg/healthcheck/commit.go +++ b/pkg/healthcheck/commit.go @@ -72,7 +72,7 @@ func NonAsciiMsg(root string) error { } if !isCommitLegal { - return fmt.Errorf("non-ASCII characters in commit messages:\n%s", msg) + return fmt.Errorf("Non-ASCII characters in commit messages:\n%s", msg) } return nil } diff --git a/pkg/healthcheck/forbidden.go b/pkg/healthcheck/forbidden.go index c3c11f5..1a46c70 100644 --- a/pkg/healthcheck/forbidden.go +++ b/pkg/healthcheck/forbidden.go @@ -26,7 +26,7 @@ func getForbiddens(root string, fileList []string, localList string) ([]string, if localList != "" { file, err := os.Open(localList) if err != nil { - return nil, fmt.Errorf("failed to open file %s: %v\n", localList, err) + return nil, fmt.Errorf("Failed to open file %s: %v\n", localList, err) } defer file.Close() @@ -35,7 +35,7 @@ func getForbiddens(root string, fileList []string, localList string) ([]string, dirs = append(dirs, scanner.Text()) } if err := scanner.Err(); err != nil { - return nil, fmt.Errorf("error reading file %s: %v\n", localList, err) + return nil, fmt.Errorf("Error reading file %s: %v\n", localList, err) } } @@ -78,7 +78,7 @@ func ForbiddenCheck(rootDir string, regexList []string, localList string, repo s } if len(forbids) > 0 { - return fmt.Errorf("the following forbidden files were found: %s\n\nTo fix it, first make a backup of your repository and then run the following commands:\nfor i in %s%s", + return fmt.Errorf("The following forbidden files were found: %s\n\nTo fix it, first make a backup of your repository and then run the following commands:\nfor i in %s%s", strings.Join(forbids, ", "), strings.Join(forbids, " "), fmt.Sprint( diff --git a/pkg/healthcheck/nonascii.go b/pkg/healthcheck/nonascii.go index d050c9f..0204c3c 100644 --- a/pkg/healthcheck/nonascii.go +++ b/pkg/healthcheck/nonascii.go @@ -20,7 +20,7 @@ func getNonAscii(root string, localList string) ([]string, error) { if localList != "" { file, err := os.Open(localList) if err != nil { - return nil, fmt.Errorf("failed to open file %s: %v\n", localList, err) + return nil, fmt.Errorf("Failed to open file %s: %v\n", localList, err) } defer file.Close() @@ -29,7 +29,7 @@ func getNonAscii(root string, localList string) ([]string, error) { dirs = append(dirs, scanner.Text()) } if err := scanner.Err(); err != nil { - return nil, fmt.Errorf("error reading file %s: %v\n", localList, err) + return nil, fmt.Errorf("Error reading file %s: %v\n", localList, err) } } @@ -86,7 +86,7 @@ func NonAsciiFiles(root string, localList string) error { return fmt.Errorf("error getting non-ascii: %w", err) } if len(nonAscii) > 0 { - return fmt.Errorf("non-ASCII characters found in the following files:\n%s", + return fmt.Errorf("Non-ASCII characters found in the following files:\n%s", strings.Join(nonAscii, "\n")) } return nil diff --git a/pkg/healthcheck/reposize.go b/pkg/healthcheck/reposize.go index 2bd297c..dd17d06 100644 --- a/pkg/healthcheck/reposize.go +++ b/pkg/healthcheck/reposize.go @@ -34,7 +34,7 @@ func RepoSize() error { } } if sum > 2048 { - return fmt.Errorf("repository larger than 2MB. Please clean up or contact the teaching team.") + return fmt.Errorf("Repository larger than 2MB. Please clean up or contact the teaching team.") } return nil } diff --git a/pkg/healthcheck/tag.go b/pkg/healthcheck/tag.go index 167164c..d0f7f76 100644 --- a/pkg/healthcheck/tag.go +++ b/pkg/healthcheck/tag.go @@ -56,7 +56,7 @@ func CheckTags(repoPath string, category string, n int) error { } } if !found { - return fmt.Errorf("wrong release tag '%s' or missing release tags. Please use one of '%s'.", target, strings.Join(tags, "', '")) + return fmt.Errorf("Wrong release tag '%s' or missing release tags. Please use one of '%s'.", target, strings.Join(tags, "', '")) } return nil } diff --git a/pkg/healthcheck/utils.go b/pkg/healthcheck/utils.go index ec55264..005379a 100644 --- a/pkg/healthcheck/utils.go +++ b/pkg/healthcheck/utils.go @@ -29,7 +29,7 @@ func getRegex(fileList []string) ([]*regexp.Regexp, error) { for _, pattern := range fileList { regex, err := regexp.Compile("(?i)" + pattern) if err != nil { - return nil, fmt.Errorf("error compiling regex: %w", err) + return nil, fmt.Errorf("Error compiling regex:%w", err) } regexList = append(regexList, regex) } diff --git a/pkg/healthcheck/verify.go b/pkg/healthcheck/verify.go index f35d539..9357679 100644 --- a/pkg/healthcheck/verify.go +++ b/pkg/healthcheck/verify.go @@ -33,10 +33,10 @@ func checkFileChecksum(rootDir, fileName, expectedChecksum string) error { filePath := filepath.Join(rootDir, strings.TrimSpace(fileName)) actualChecksum, err := getChecksum(filePath) if err != nil { - return fmt.Errorf("error reading file %s: %v", filePath, err) + return fmt.Errorf("Error reading file %s: %v", filePath, err) } if actualChecksum != expectedChecksum { - return fmt.Errorf("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 fmt.Errorf("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 nil } @@ -49,7 +49,7 @@ func VerifyFiles(rootDir string, checkFileNameList string, checkFileSumList stri checkSums := strings.Split(checkFileSumList, ",") // Check if the number of files matches the number of checksums if len(fileNames) != len(checkSums) { - return fmt.Errorf("the number of files and checksums do not match") + return fmt.Errorf("Error: The number of files and checksums do not match.") } // Check each file's checksum for i, fileName := range fileNames {