feat(forbidden file): customize stdpath
This commit is contained in:
parent
213bff201f
commit
e1fdc17e14
|
@ -46,6 +46,8 @@ func main() {
|
||||||
localList := flag.String("localList", "", "local file list for non-ascii file check")
|
localList := flag.String("localList", "", "local file list for non-ascii file check")
|
||||||
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")
|
||||||
|
stdout := flag.String("stdout", "stdout", "location of stdout")
|
||||||
|
stderr := flag.String("stderr", "stderr", "location of stderr")
|
||||||
parseMultiValueFlag(&metaFile, "meta", "meta files to check")
|
parseMultiValueFlag(&metaFile, "meta", "meta files to check")
|
||||||
// TODO: remove gitWhitelist, it is only for backward compatibility now
|
// TODO: remove gitWhitelist, it is only for backward compatibility now
|
||||||
var gitWhitelist []string
|
var gitWhitelist []string
|
||||||
|
@ -69,7 +71,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)
|
err = healthcheck.ForbiddenCheck(*rootDir, *stdout, *stderr)
|
||||||
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())
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
// getForbiddens retrieves a list of forbidden files in the specified root directory.
|
// 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.
|
// 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
|
var matches []string
|
||||||
|
|
||||||
// Create a gitignore instance from the .gitignore file
|
// Create a gitignore instance from the .gitignore file
|
||||||
|
@ -38,7 +38,7 @@ func getForbiddens(root string) ([]string, error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// TODO: remove this temporary fix for stdout and stderr
|
// TODO: remove this temporary fix for stdout and stderr
|
||||||
if relPath == "stdout" || relPath == "stderr" {
|
if relPath == stdout || relPath == stderr {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
match := ignore.Relative(relPath, true)
|
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.
|
// 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) error {
|
func ForbiddenCheck(rootDir string, stdout string, stderr string) error {
|
||||||
forbids, err := getForbiddens(rootDir)
|
forbids, err := getForbiddens(rootDir, stdout, stderr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("getting forbiddens", "error", err)
|
slog.Error("getting forbiddens", "error", err)
|
||||||
return fmt.Errorf("error getting forbiddens: %w", err)
|
return fmt.Errorf("error getting forbiddens: %w", err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user