From e1fdc17e14f5eb8ff98e12aac19b972ea0fc1028 Mon Sep 17 00:00:00 2001 From: zzjc1234 <2359047351@qq.com> Date: Mon, 21 Oct 2024 16:09:28 +0800 Subject: [PATCH] feat(forbidden file): customize stdpath --- cmd/repo-health-checker/main.go | 4 +++- pkg/healthcheck/forbidden.go | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/repo-health-checker/main.go b/cmd/repo-health-checker/main.go index bba0991..a2469d5 100644 --- a/cmd/repo-health-checker/main.go +++ b/cmd/repo-health-checker/main.go @@ -46,6 +46,8 @@ func main() { 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") + stdout := flag.String("stdout", "stdout", "location of stdout") + stderr := flag.String("stderr", "stderr", "location of stderr") parseMultiValueFlag(&metaFile, "meta", "meta files to check") // TODO: remove gitWhitelist, it is only for backward compatibility now var gitWhitelist []string @@ -69,7 +71,7 @@ func main() { if err != nil { fmt.Printf("### Repo Size Check Failed:\n%s\n", err.Error()) } - err = healthcheck.ForbiddenCheck(*rootDir) + err = healthcheck.ForbiddenCheck(*rootDir, *stdout, *stderr) if err != nil { fmt.Printf("### Forbidden File Check Failed:\n%s\n", err.Error()) } diff --git a/pkg/healthcheck/forbidden.go b/pkg/healthcheck/forbidden.go index 37c70fc..ca49522 100644 --- a/pkg/healthcheck/forbidden.go +++ b/pkg/healthcheck/forbidden.go @@ -12,7 +12,7 @@ import ( // getForbiddens retrieves a list of forbidden files in the specified root directory. // It searches for files that match the specified ignore patterns in the .gitignore file. -func getForbiddens(root string) ([]string, error) { +func getForbiddens(root string, stdout string, stderr string) ([]string, error) { var matches []string // Create a gitignore instance from the .gitignore file @@ -38,7 +38,7 @@ func getForbiddens(root string) ([]string, error) { return err } // TODO: remove this temporary fix for stdout and stderr - if relPath == "stdout" || relPath == "stderr" { + if relPath == stdout || relPath == stderr { return nil } match := ignore.Relative(relPath, true) @@ -56,8 +56,8 @@ func getForbiddens(root string) ([]string, error) { // 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. -func ForbiddenCheck(rootDir string) error { - forbids, err := getForbiddens(rootDir) +func ForbiddenCheck(rootDir string, stdout string, stderr string) error { + forbids, err := getForbiddens(rootDir, stdout, stderr) if err != nil { slog.Error("getting forbiddens", "error", err) return fmt.Errorf("error getting forbiddens: %w", err)