HOOKS: added bios to json lint

This commit is contained in:
XargonWan 2025-01-22 09:47:30 +09:00
parent 0c3fd376c8
commit 8ae46b2f21
4 changed files with 20 additions and 14 deletions

View file

@ -1,15 +1,21 @@
#!/bin/bash
# A pre-commit hook to lint features.json if it is edited
# A pre-commit hook to lint json files if it they're edited
# Check if any path contains 'features.json'
if git diff --cached --name-only | grep -q 'config/retrodeck/reference_lists/features.json'; then
lint_list=(
"config/retrodeck/reference_lists/features.json"
"config/retrodeck/reference_lists/bios.json"
)
for file in "${lint_list[@]}"; do
if git diff --cached --name-only | grep -q "$file"; then
# Run the linting script
echo "Linting config/retrodeck/reference_lists/features.json..."
if ! bash developer_toolbox/lint_features.json.sh; then
echo "Linting failed. Please fix the issues and try again."
echo "Linting $file..."
if ! bash "developer_toolbox/lint_json.sh" "$file"; then
echo "Linting failed for \"$(basename $file)\". Please fix the issues and try again."
exit 1 # Exit with a non-zero status to block the commit
fi
fi
done
# Lint Manifest
# if git diff --cached --name-only | grep -q 'net.retrodeck.retrodeck.yml'; then

View file

@ -1,5 +0,0 @@
#!/bin/bash
features=config/retrodeck/reference_lists/features.json
jq . $features > $features.tmp && mv -f $features.tmp $features

5
developer_toolbox/lint_json.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
json=$1
jq . $json > $json.tmp && mv -f $json.tmp $json