From 3a04365e5d09c9875fcfe102bf02f0ce28b11174 Mon Sep 17 00:00:00 2001 From: tobiichi3227 Date: Mon, 17 Feb 2025 12:10:37 +0800 Subject: [PATCH 1/3] Chore(Fortune): add pre-commit to check special events --- .pre-commit-config.yaml | 20 ++++++++++++++++++++ scripts/check-events.sh | 7 +++++++ 2 files changed, 27 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100755 scripts/check-events.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..83b8038 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + +- repo: local + hooks: + - id: check-special-event + name: check-special-event + entry: bash scripts/check-events.sh + language: system + files: ^fortune_generator/json/.*_special\.json$ + types: [json] + pass_filenames: false diff --git a/scripts/check-events.sh b/scripts/check-events.sh new file mode 100755 index 0000000..6e9afe8 --- /dev/null +++ b/scripts/check-events.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +python3 scripts/check-events.py fortune_generator/json/custom_special.json custom +python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical +python3 scripts/check-events.py fortune_generator/json/static_special.json static -- 2.49.1 From c5e6dedfe429573e97cebf1f67b6b4a5045315a8 Mon Sep 17 00:00:00 2001 From: tobiichi3227 Date: Tue, 18 Feb 2025 10:41:25 +0800 Subject: [PATCH 2/3] Chore(Fortune): Update pre-commit hook version --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83b8038..9384187 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer -- 2.49.1 From 0b31ee45a802e5f200e3c7ee98f5e482584ec3d7 Mon Sep 17 00:00:00 2001 From: tobiichi3227 Date: Tue, 18 Feb 2025 10:44:10 +0800 Subject: [PATCH 3/3] Chore(Fortune): replace shell script with Python for better compatibility --- .pre-commit-config.yaml | 26 +++++++++++++++++++++----- scripts/check-events.sh | 7 ------- 2 files changed, 21 insertions(+), 12 deletions(-) delete mode 100755 scripts/check-events.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9384187..e01afb6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,10 +11,26 @@ repos: - repo: local hooks: - - id: check-special-event - name: check-special-event - entry: bash scripts/check-events.sh - language: system - files: ^fortune_generator/json/.*_special\.json$ + - id: check-cyclical-event + name: check-cyclical-event + entry: python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical + language: python + files: fortune_generator/json/cyclical_special.json + types: [json] + pass_filenames: false + + - id: check-custom-event + name: check-custom-event + entry: python3 scripts/check-events.py fortune_generator/json/custom_special.json custom + language: python + files: fortune_generator/json/custom_special.json + types: [json] + pass_filenames: false + + - id: check-static-event + name: check-static-event + entry: python3 scripts/check-events.py fortune_generator/json/static_special.json static + language: python + files: fortune_generator/json/static_special.json types: [json] pass_filenames: false diff --git a/scripts/check-events.sh b/scripts/check-events.sh deleted file mode 100755 index 6e9afe8..0000000 --- a/scripts/check-events.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -set -e - -python3 scripts/check-events.py fortune_generator/json/custom_special.json custom -python3 scripts/check-events.py fortune_generator/json/cyclical_special.json cyclical -python3 scripts/check-events.py fortune_generator/json/static_special.json static -- 2.49.1