mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 20:05:51 +00:00
Ignore checking formatting if no formatted files are staged (#1469)
I'm constantly harassed to follow the rules when I'm not doing anything relevant. This is an attempt to ameliorate that rather than `--no-verify` or just disabling hooks altogether. 🍄 ☁️ Somebody might want to confirm `basename` is included with macOS.
This commit is contained in:
@@ -5,6 +5,20 @@
|
|||||||
# This script checks the format of the code and cmake files.
|
# This script checks the format of the code and cmake files.
|
||||||
# In many cases it will automatically fix the issues and abort the commit.
|
# In many cases it will automatically fix the issues and abort the commit.
|
||||||
|
|
||||||
|
no_formatted_directories_staged() {
|
||||||
|
staged_directories=$(git diff-index --cached --name-only HEAD | awk -F/ '{print $1}')
|
||||||
|
for sd in $staged_directories; do
|
||||||
|
if [[ "$sd" =~ ^(benchmark|cmake|src|tests)$ ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if no_formatted_directories_staged ; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
echo "+ Checking code format..."
|
echo "+ Checking code format..."
|
||||||
|
|
||||||
# paths to check and re-format
|
# paths to check and re-format
|
||||||
|
|||||||
Reference in New Issue
Block a user