-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Husky v8→v9 移行チェックを repo-maintenance に追加 #540
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 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -357,7 +357,61 @@ fi | |||||||||||||||
| - 🔧 core.hooksPath を修正しました(壊れたパス → `.husky`) | ||||||||||||||||
| - ❌ .husky ディレクトリ不在のため手動対応が必要 | ||||||||||||||||
|
|
||||||||||||||||
| ### 3.2.2 Check-file-length Setup Check | ||||||||||||||||
| ### 3.2.2 Husky v8 → v9 Migration Check | ||||||||||||||||
|
|
||||||||||||||||
| `.husky/_` 経由のフック実行(husky v8 スタイル)を v9 スタイルへ移行提案: | ||||||||||||||||
|
|
||||||||||||||||
| **確認ロジック:** | ||||||||||||||||
|
|
||||||||||||||||
| ```bash | ||||||||||||||||
| HOOKS_PATH=$(git config core.hooksPath 2>/dev/null || echo "") | ||||||||||||||||
| IS_V8_STYLE=false | ||||||||||||||||
| [ "$HOOKS_PATH" = ".husky/_" ] && IS_V8_STYLE=true | ||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| **v8 と v9 の違い:** | ||||||||||||||||
|
|
||||||||||||||||
| | 項目 | v8 スタイル | v9 スタイル | | ||||||||||||||||
| | ---------- | -------------------------------------------- | ------------------------------ | | ||||||||||||||||
| | hooksPath | `.husky/_` | `.husky` | | ||||||||||||||||
| | フック実行 | `_/h` 経由で `.husky/pre-commit` を呼ぶ | `.husky/pre-commit` を直接実行 | | ||||||||||||||||
| | 旧 shebang | `. "$(dirname -- "$0")/_/husky.sh"` 行が必要 | 不要(素のシェルスクリプト) | | ||||||||||||||||
|
|
||||||||||||||||
| **結果パターン:** | ||||||||||||||||
|
|
||||||||||||||||
| | 状態 | 対応 | | ||||||||||||||||
| | --------------------------- | ------------------------------------ | | ||||||||||||||||
| | `core.hooksPath = .husky` | ✅ v9スタイル済み | | ||||||||||||||||
| | `core.hooksPath = .husky/_` | ⚠️ v8スタイル → full mode で移行提案 | | ||||||||||||||||
| | 未設定 | ✅ スキップ | | ||||||||||||||||
|
|
||||||||||||||||
| **MODE が `full` かつ v8 スタイルの場合:** | ||||||||||||||||
|
|
||||||||||||||||
| ```bash | ||||||||||||||||
| # 1. hooksPath を v9 スタイルに更新 | ||||||||||||||||
| git config core.hooksPath ".husky" | ||||||||||||||||
|
|
||||||||||||||||
| # 2. 各フックファイルから旧 shebang を削除(存在する場合) | ||||||||||||||||
| for hook in .husky/pre-commit .husky/pre-push .husky/commit-msg; do | ||||||||||||||||
| [ ! -f "$hook" ] && continue | ||||||||||||||||
| if grep -q "_/husky.sh" "$hook"; then | ||||||||||||||||
| # 旧 husky v8 の source 行を削除 | ||||||||||||||||
| grep -v "_/husky.sh" "$hook" > "$hook.tmp" && mv "$hook.tmp" "$hook" | ||||||||||||||||
| # #!/usr/bin/env sh を #!/bin/sh に統一 | ||||||||||||||||
| sed -i "" "s|#!/usr/bin/env sh|#!/bin/sh|" "$hook" | ||||||||||||||||
|
Comment on lines
+399
to
+401
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
tmp="$(mktemp)"
printf '#!/usr/bin/env sh\n' > "$tmp"
echo "Testing BSD-style: sed -i \"\" ..."
if sed -i "" 's|#!/usr/bin/env sh|#!/bin/sh|' "$tmp" 2>/dev/null; then
echo "BSD-style in-place edit is supported here"
else
echo "BSD-style in-place edit is NOT supported here"
fi
echo "sed version:"
sed --version 2>/dev/null | head -n1 || echo "BSD sed (no --version output)"
rm -f "$tmp"Repository: keito4/config Length of output: 166 🏁 Script executed: fd "repo-maintenance.md" --type fRepository: keito4/config Length of output: 39 🏁 Script executed: # Search for repo-maintenance in any location
find . -name "*repo-maintenance*" -o -name "*.md" | grep -i "maintenance" | head -20Repository: keito4/config Length of output: 95 🏁 Script executed: # Check if .claude directory exists
ls -la .claude/ 2>/dev/null || echo ".claude directory not found"Repository: keito4/config Length of output: 815 🏁 Script executed: # Check total lines in the file
wc -l ./.claude/commands/repo-maintenance.mdRepository: keito4/config Length of output: 99 🏁 Script executed: # Read lines around 399-401 with context
sed -n '390,410p' ./.claude/commands/repo-maintenance.mdRepository: keito4/config Length of output: 616 🏁 Script executed: # Get exact lines 399-401
sed -n '399,401p' ./.claude/commands/repo-maintenance.mdRepository: keito4/config Length of output: 224 🏁 Script executed: # Get broader context around line 400 to understand the full section
sed -n '375,415p' ./.claude/commands/repo-maintenance.md | cat -nRepository: keito4/config Length of output: 1740 🏁 Script executed: # Check line 752 context
sed -n '745,760p' ./.claude/commands/repo-maintenance.mdRepository: keito4/config Length of output: 761 Use a portable in-place edit for hook rewrites.
Suggested fix- # #!/usr/bin/env sh を #!/bin/sh に統一
- sed -i "" "s|#!/usr/bin/env sh|#!/bin/sh|" "$hook"
+ # #!/usr/bin/env sh を #!/bin/sh に統一(GNU/BSD sed 両対応)
+ tmp_hook="$(mktemp)"
+ sed 's|#!/usr/bin/env sh|#!/bin/sh|' "$hook" > "$tmp_hook" && mv "$tmp_hook" "$hook"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| chmod +x "$hook" | ||||||||||||||||
| echo "🔧 $hook から旧 shebang を削除しました" | ||||||||||||||||
| fi | ||||||||||||||||
| done | ||||||||||||||||
|
Comment on lines
+395
to
+405
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 migration only updates three hook names. The text says Suggested fix-for hook in .husky/pre-commit .husky/pre-push .husky/commit-msg; do
- [ ! -f "$hook" ] && continue
+for hook in .husky/*; do
+ [ ! -f "$hook" ] && continue
+ [ "$(basename "$hook")" = "_" ] && continue
+ [ "$(basename "$hook")" = ".gitignore" ] && continue
if grep -q "_/husky.sh" "$hook"; then🤖 Prompt for AI Agents |
||||||||||||||||
| ``` | ||||||||||||||||
|
|
||||||||||||||||
| **結果:** | ||||||||||||||||
|
|
||||||||||||||||
| - ✅ v9スタイル(`.husky`)で設定済み | ||||||||||||||||
| - 🔧 v8 → v9 へ移行しました(hooksPath 更新 + 旧 shebang 削除) | ||||||||||||||||
| - ✅ スキップ(hooksPath 未設定) | ||||||||||||||||
|
|
||||||||||||||||
| ### 3.2.3 Check-file-length Setup Check | ||||||||||||||||
|
|
||||||||||||||||
| pre-commit フックに `check-file-length` が含まれているか確認・追加: | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -695,7 +749,7 @@ npm install -D @biomejs/biome knip | |||||||||||||||
|
|
||||||||||||||||
| ## Setup (2/4) | ||||||||||||||||
| ├── Team Protection: ✅ Branch protection enabled | ||||||||||||||||
| ├── Husky: ✅ Git hooks configured\n├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required) | ||||||||||||||||
| ├── Husky: ✅ Git hooks configured\n├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)\n├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ) | ||||||||||||||||
|
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. Split the sample summary into actual lines. この fenced block だと Suggested fix-├── Husky: ✅ Git hooks configured\n├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)\n├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)
+├── Husky: ✅ Git hooks configured
+├── hooksPath: ✅ Valid (.husky) (or 🔧 Fixed / ❌ Manual required)
+├── Husky v8→v9: ✅ v9スタイル済み (or 🔧 移行しました / ✅ スキップ)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| ├── check-file-length: ✅ Configured in pre-commit (or 🔧 Added / ⏭️ Skipped) | ||||||||||||||||
| ├── Pre-PR Checklist: ✅ CI workflow exists | ||||||||||||||||
| ├── CLAUDE.md: ✅ Symlink to AGENTS.md | ||||||||||||||||
|
|
||||||||||||||||
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.
The migration snippet uses
sed -i "" ..., which is BSD/macOS-specific; on GNU sed (the default in Linux devcontainers/Codespaces)-iexpects an optional suffix attached to the flag, so this form fails withsed: can't read ...instead of editing the hook file. In--mode fullon repositories still using Husky v8, this can abort or partially apply the migration, leaving hooks unconverted on the primary Linux execution environment.Useful? React with 👍 / 👎.