From 73e22267ecb346c056061fc7d94ecad20484f731 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 14:40:30 +0900 Subject: [PATCH 1/2] 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 From 1e84103059b7b2a3c13bdb397fb9cbd2561a9cde Mon Sep 17 00:00:00 2001 From: XargonWan Date: Tue, 10 Sep 2024 14:50:14 +0900 Subject: [PATCH 2/2] REPO: added lint manifest POC [skip ci] --- developer_toolbox/hooks/pre-commit | 10 ++++++++++ developer_toolbox/lint_manifest.sh | 3 +++ 2 files changed, 13 insertions(+) create mode 100755 developer_toolbox/lint_manifest.sh diff --git a/developer_toolbox/hooks/pre-commit b/developer_toolbox/hooks/pre-commit index 9cb4b48f..31210b0a 100755 --- a/developer_toolbox/hooks/pre-commit +++ b/developer_toolbox/hooks/pre-commit @@ -11,5 +11,15 @@ if git diff --cached --name-only | grep -q 'config/retrodeck/reference_lists/fea fi fi +# Lint Manifest +# if git diff --cached --name-only | grep -q 'net.retrodeck.retrodeck.yml'; then +# # Run the linting script +# echo "Linting net.retrodeck.retrodeck.yml..." +# if ! bash developer_toolbox/lint_manifest.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/lint_manifest.sh b/developer_toolbox/lint_manifest.sh new file mode 100755 index 00000000..9147e142 --- /dev/null +++ b/developer_toolbox/lint_manifest.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +yamllint net.retrodeck.retrodeck.yml