Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a configlet formatting check (#265)
* Adding a configlet formatting check.
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This ensures that the track configuration files are formatted correctly. | ||
|
||
repo=$(cd "$(dirname "$0")/.." && pwd) | ||
configlet="${repo}/bin/configlet" | ||
|
||
if ! cfg=$($configlet fmt .); then | ||
echo "configlet fmt returned non-0 exit code with output:" | ||
echo "$cfg" | ||
exit 1 | ||
fi | ||
|
||
if git diff-index --quiet HEAD --; then | ||
# No changes detected | ||
echo "configlet fmt: no changes needed" | ||
exit 0 | ||
else | ||
# Changes needed | ||
echo "configlet fmt: changes needed" | ||
echo "Run 'bin/fetch-configlet && bin/configlet fmt .' to apply these changes." | ||
echo "" | ||
git diff | ||
exit 1 | ||
fi | ||
|
||
exit 0 |