Repository navigation
feat: repo-maintenanceにcheck-file-length自動追加を組み込む #537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,6 +308,81 @@ Git hooks(pre-commit)の設定状況を確認: | |
| - ⚠️ Husky 未設定 → セットアップを提案 | ||
| - 📝 設定内容: pre-commit, commit-msg | ||
|
|
||
| ### 3.2.1 Check-file-length Setup Check | ||
|
|
||
| pre-commit フックに `check-file-length` が含まれているか確認・追加: | ||
|
|
||
| **確認ロジック:** | ||
|
|
||
| ```bash | ||
| PRECOMMIT=".husky/pre-commit" | ||
| SCRIPT_DEST="script/check-file-length.sh" | ||
| SCRIPT_SRC_DEVCONTAINER="/usr/local/script/check-file-length.sh" | ||
| SCRIPT_RAW_URL="https://raw.githubusercontent.com/keito4/config/main/script/check-file-length.sh" | ||
|
|
||
| has_precommit=false | ||
| has_file_length=false | ||
|
|
||
| [ -f "$PRECOMMIT" ] && has_precommit=true | ||
| grep -q "check-file-length" "$PRECOMMIT" 2>/dev/null && has_file_length=true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The check marks Useful? React with 👍 / 👎. |
||
| ``` | ||
|
|
||
| **結果パターン:** | ||
|
|
||
| | 状態 | 対応 | | ||
| | ---------------------------------------- | ----------------------------- | | ||
| | pre-commit あり + check-file-length あり | ✅ スキップ | | ||
| | pre-commit あり + check-file-length なし | ⚠️ → full mode で自動追加 | | ||
| | pre-commit なし | ⏭️ Husky 未設定のためスキップ | | ||
|
|
||
| **MODE が `full` かつ追加が必要な場合の実行内容:** | ||
|
|
||
| 1. スクリプトを取得(優先順位順): | ||
|
|
||
| ```bash | ||
| mkdir -p script | ||
| if [ -f "$SCRIPT_SRC_DEVCONTAINER" ]; then | ||
| # DevContainer 環境: コンテナ内スクリプトをコピー | ||
| cp "$SCRIPT_SRC_DEVCONTAINER" "$SCRIPT_DEST" | ||
| elif [ ! -f "$SCRIPT_DEST" ]; then | ||
| # ローカル環境: GitHub から取得 | ||
| curl -fsSL "$SCRIPT_RAW_URL" -o "$SCRIPT_DEST" | ||
| fi | ||
| chmod +x "$SCRIPT_DEST" | ||
| ``` | ||
|
|
||
| 2. pre-commit フックに追記: | ||
|
|
||
| ```bash | ||
| # すでに lint-staged を呼んでいる行の後に追加 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Comment doesn't match implementation. Line 357's comment states "すでに lint-staged を呼んでいる行の後に追加" (add after the line that calls lint-staged), but the actual code on lines 358-360 simply appends to the end of the pre-commit file without any logic to locate or insert after the lint-staged invocation. Either implement intelligent insertion or update the comment to reflect the actual behavior. ♻️ Option 1: Update comment to match implementation-# すでに lint-staged を呼んでいる行の後に追加
+# pre-commit の末尾に追加♻️ Option 2: Implement intelligent insertion# Insert after lint-staged line if it exists, otherwise append to end
if grep -q "lint-staged" "$PRECOMMIT" 2>/dev/null; then
# Insert after the last lint-staged line
sed -i '/lint-staged/a\\n# check-file-length\necho "[husky] Running file length check..."\nbash scripts/check-file-length.sh || exit 1' "$PRECOMMIT"
else
# Append to end
...
fi🤖 Prompt for AI Agents |
||
| echo "" >> "$PRECOMMIT" | ||
| echo "# check-file-length" >> "$PRECOMMIT" | ||
| echo "bash script/check-file-length.sh" >> "$PRECOMMIT" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This appends the new hook lines to the end of Useful? React with 👍 / 👎.
Comment on lines
+358
to
+360
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Major: Hook invocation format inconsistent with existing setup script. Lines 358-360 append a hook invocation without error handling ( echo "echo \"[husky] Running file length check...\""
echo "bash scripts/check-file-length.sh || exit 1"Without 🔧 Proposed fix to align with existing setup script-echo "" >> "$PRECOMMIT"
-echo "# check-file-length" >> "$PRECOMMIT"
-echo "bash script/check-file-length.sh" >> "$PRECOMMIT"
+{
+ echo ""
+ echo "echo \"[husky] Running file length check...\""
+ echo "bash scripts/check-file-length.sh || exit 1"
+} >> "$PRECOMMIT"Based on relevant code snippet from script/setup-file-length-check.sh:65-80 showing the ACTUAL hook format produced by the existing setup script. 🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
||
| 3. `.filelengthignore` がなければテンプレートから生成: | ||
|
|
||
| ```bash | ||
| IGNORE_TEMPLATE="/usr/local/share/config-templates/.filelengthignore.template" | ||
| if [ ! -f ".filelengthignore" ]; then | ||
| if [ -f "$IGNORE_TEMPLATE" ]; then | ||
| cp "$IGNORE_TEMPLATE" .filelengthignore | ||
| else | ||
| cat > .filelengthignore << 'EOF' | ||
| # 自動生成ファイル | ||
| **/*.generated.* | ||
| **/database.types.ts | ||
| EOF | ||
| fi | ||
| fi | ||
| ``` | ||
|
|
||
| **結果:** | ||
|
|
||
| - ✅ check-file-length が pre-commit に設定済み | ||
| - 🔧 check-file-length を pre-commit に追加しました | ||
| - ⏭️ Husky 未設定のためスキップ | ||
|
|
||
| ### 3.3 Pre-PR Checklist Validation | ||
|
|
||
| PR 作成前のチェック項目を検証: | ||
|
|
@@ -572,6 +647,7 @@ npm install -D @biomejs/biome knip | |
| ## Setup (2/4) | ||
| ├── Team Protection: ✅ Branch protection enabled | ||
| ├── Husky: ✅ Git hooks configured | ||
| ├── check-file-length: ✅ Configured in pre-commit (or 🔧 Added / ⏭️ Skipped) | ||
| ├── Pre-PR Checklist: ✅ CI workflow exists | ||
| ├── CLAUDE.md: ✅ Symlink to AGENTS.md | ||
| └── CI/CD: ✅ Standard level configured | ||
|
|
@@ -762,6 +838,7 @@ Run this command regularly to maintain repository health: | |
| | Environment | `/codespaces-secrets` | Codespaces シークレット同期 | | ||
| | Setup | `/setup-team-protection` | GitHub保護ルール設定 | | ||
| | Setup | `/setup-husky` | Git hooks設定 | | ||
| | Setup | (check-file-length auto-setup) | ファイル行数チェック追加 | | ||
| | Setup | `/pre-pr-checklist` | PR前チェックリスト | | ||
| | Setup | (CLAUDE.md symlink check) | CLAUDE.md シンボリックリンク | | ||
| | Setup | `/setup-ci` | CI/CDワークフロー設定 | | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Path mismatch with existing setup script.
Line 319 specifies
script/check-file-length.sh(singular), and line 360 appends this path to the pre-commit hook. However, the existingscript/setup-file-length-check.shcopies the script toscripts/check-file-length.sh(plural, see context snippet 1 lines 24-36). This inconsistency means:scripts/check-file-length.shscript/check-file-length.sh🔧 Proposed fix
Align with the existing setup script by using
scripts/(plural):And update the hook invocation:
Also update line 343:
Based on relevant code snippet from script/setup-file-length-check.sh:24-36 showing the existing setup script uses "scripts/" directory.
Also applies to: 360-360
🤖 Prompt for AI Agents