-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Set nonzero exit code with --critical #42
Comments
That's a good idea. We'd definitely want a way to distinguish between runtime errors (e.g., repository was corrupt) vs. size "errors"; for example, by returning different exit codes. |
I like this idea and I have some time to work on it. Following @mingalsuo description updating the tool to support custom user defined exit codes could be an approach. Have the user provide a config file with them listed. |
A "nice" workaround is to use JSON output and jq. To just display the results: git-sizer --json --json-version=2 2>/dev/null | jq -r '. | values[] | select (.levelOfConcern >= 1) | [.description, ((.value | tostring) + .unit), (.levelOfConcern * 100 | floor / 100)] | @tsv' | column -t -s $'\t' To set the exit code to 1 when all is good (there is no match >= threshold): git-sizer --json --json-version=2 2>/dev/null | jq -e -r '. | values[] | select (.levelOfConcern >= 1) | [.description, ((.value | tostring) + .unit), (.levelOfConcern * 100 | floor / 100)]' Then you can "reverse" the exit code. You can tweak the threshold in export THRESHOLD=0.5
git-sizer --json --json-version=2 2>/dev/null | jq -e -r '. | values[] | select (.levelOfConcern >= (env.THRESHOLD | tonumber)) | [.description, ((.value | tostring) + .unit), (.levelOfConcern * 100 | floor / 100)]' This can be further cleaned up in a nice zsh/bash wrapper file and/or a nice jq script file. |
git cat-file -p : |
For automation purposes, it would be a great feature to be able to analyze repositories and get a machine readable exit code that states that critical issues were found.
One way is to directly have --critical set the exit code or add another flag that does that if critical issues were found.
Thanks for creating this great tool.
The text was updated successfully, but these errors were encountered: