Skip to content

Commit

Permalink
Merge pull request #64 from coreruleset/fix-exit-code-on-github
Browse files Browse the repository at this point in the history
fix: exit with 1 when checking format
  • Loading branch information
theseion authored Nov 25, 2022
2 parents 8e4ab88 + 5adecaa commit 2486693
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cmd/regex_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ type UnformattedFileError struct {
}

func (u *UnformattedFileError) Error() string {
return fmt.Sprintf("File not properly formatted: %s", u.filePath)
if u.HasPathInfo() {
return fmt.Sprintf("File not properly formatted: %s", u.filePath)
}

return "One or more files are not properly formatted"
}

func (u *UnformattedFileError) HasPathInfo() bool {
return u.filePath != ""
}

// formatCmd represents the generate command
Expand Down Expand Up @@ -100,7 +108,6 @@ scheme, as they don't correspond to any particular rule.`,
// Errors are not command related
cmd.SilenceErrors = true
cmd.SilenceUsage = true
logger.Error().Err(err).Msg("formatting failed")
}
return err
},
Expand Down Expand Up @@ -152,6 +159,7 @@ func processAll(ctxt *processors.Context, checkOnly bool) error {
if failed && rootValues.output == gitHub {
fmt.Println("::error::All assembly files need to be properly formatted.",
"Please run `crs-toolchain regex format --all")
return &UnformattedFileError{}

}
return nil
Expand Down

0 comments on commit 2486693

Please sign in to comment.