fix(healthcheck): remove unused args #59

Merged
张泊明518370910136 merged 2 commits from fix-health-check into master 2024-10-14 22:44:31 +08:00
2 changed files with 4 additions and 11 deletions
Showing only changes of commit 018bfbf8e5 - Show all commits

View File

@ -42,10 +42,8 @@ func main() {
var gitWhitelist, metaFile []string var gitWhitelist, metaFile []string
showVersion := flag.Bool("version", false, "print current version") showVersion := flag.Bool("version", false, "print current version")
rootDir := flag.String("root", "", "") rootDir := flag.String("root", "", "")
repo := flag.String("repo", "", "")
size := flag.Float64("repoSize", 2, "maximum size of the repo in MiB") size := flag.Float64("repoSize", 2, "maximum size of the repo in MiB")
localList := flag.String("localList", "", "") localList := flag.String("localList", "", "")
droneBranch := flag.String("droneBranch", "", "")
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.")
parseMultiValueFlag(&gitWhitelist, "whitelist", "") parseMultiValueFlag(&gitWhitelist, "whitelist", "")
@ -61,7 +59,7 @@ func main() {
if err != nil { if err != nil {
fmt.Printf("### Repo Size Check Failed:\n%s\n", err.Error()) fmt.Printf("### Repo Size Check Failed:\n%s\n", err.Error())
} }
err = healthcheck.ForbiddenCheck(*rootDir, gitWhitelist, *localList, *repo, *droneBranch) err = healthcheck.ForbiddenCheck(*rootDir, gitWhitelist, *localList)
if err != nil { if err != nil {
fmt.Printf("### Forbidden File Check Failed:\n%s\n", err.Error()) fmt.Printf("### Forbidden File Check Failed:\n%s\n", err.Error())
} }

View File

@ -70,7 +70,7 @@ func getForbiddens(root string, fileList []string, localList string) ([]string,
// forbiddenCheck checks for forbidden files in the specified root directory. // forbiddenCheck checks for forbidden files in the specified root directory.
// It prints the list of forbidden files found, along with instructions on how to fix them. // It prints the list of forbidden files found, along with instructions on how to fix them.
func ForbiddenCheck(rootDir string, regexList []string, localList string, repo string, droneBranch string) error { func ForbiddenCheck(rootDir string, regexList []string, localList string) error {
forbids, err := getForbiddens(rootDir, regexList, localList) forbids, err := getForbiddens(rootDir, regexList, localList)
if err != nil { if err != nil {
slog.Error("getting forbiddens", "error", err) slog.Error("getting forbiddens", "error", err)
@ -78,13 +78,8 @@ func ForbiddenCheck(rootDir string, regexList []string, localList string, repo s
} }
if len(forbids) > 0 { 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",
strings.Join(forbids, ", "), strings.Join(forbids, "`, `"))
strings.Join(forbids, " "),
fmt.Sprint(
"; do git filter-repo --force --invert-paths --path \"$i\"; done\ngit remote add origin ",
repo, "\ngit push --set-upstream origin ",
droneBranch, " --force"))
} }
return nil return nil
} }