From 73e22267ecb346c056061fc7d94ecad20484f731 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 14:40:30 +0900 Subject: [PATCH] REPO: added lint hooks and hooks installer [skip ci] --- developer_toolbox/hooks/pre-commit | 15 +++++++++++++++ developer_toolbox/install_hooks.sh | 4 ++++ 2 files changed, 19 insertions(+) create mode 100755 developer_toolbox/hooks/pre-commit create mode 100755 developer_toolbox/install_hooks.sh diff --git a/developer_toolbox/hooks/pre-commit b/developer_toolbox/hooks/pre-commit new file mode 100755 index 00000000..9cb4b48f --- /dev/null +++ b/developer_toolbox/hooks/pre-commit @@ -0,0 +1,15 @@ +#!/bin/bash +# A pre-commit hook to lint features.json if it is edited + +# Check if any path contains 'features.json' +if git diff --cached --name-only | grep -q 'config/retrodeck/reference_lists/features.json'; 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." + exit 1 # Exit with a non-zero status to block the commit + fi +fi + +# Continue with the commit if all checks passed +exit 0 diff --git a/developer_toolbox/install_hooks.sh b/developer_toolbox/install_hooks.sh new file mode 100755 index 00000000..d2510ce0 --- /dev/null +++ b/developer_toolbox/install_hooks.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +mkdir -p .git/hooks +cp -f developer_toolbox/hooks/* .git/hooks \ No newline at end of file