Files
claude-howto/ja/06-hooks/pre-commit.sh
T
JiangCheng 1d1df9235b feat(i18n): Add Japanese (ja/) translation (#105)
- Translate all 101 markdown files: P1 core, all 10 modules, examples,
  auxiliary docs (CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, CLAUDE.md, etc.),
  peripheral docs (.github/, docs/, resources/, scripts/)
- Translate comments and user-facing messages in 06-hooks/*.sh examples
- Copy 05-mcp/*.json examples (standard JSON, no comments)
- Update root README.md language switcher to include 日本語
- Add ja/TRANSLATION_NOTES.md (glossary + style guide)

All translations pass pre-commit quality gates (markdown-lint,
cross-references, mermaid-syntax, link-check, build-epub).
2026-04-30 00:16:46 +02:00

51 lines
1.4 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# コミット前にテストを実行する
# フック:PreToolUsematcher: Bash)— コマンドが git commit か判定する
# 注:「PreCommit」フックイベントは存在しない。PreToolUse と Bash matcher の組み合わせで
# コマンドを検査し、git commit を検出する。
echo "🧪 コミット前にテストを実行しています..."
# package.json の有無を確認(Node.js プロジェクト)
if [ -f "package.json" ]; then
if grep -q "\"test\":" package.json; then
npm test
if [ $? -ne 0 ]; then
echo "❌ テスト失敗。コミットをブロックします。"
exit 1
fi
fi
fi
# pytest が使えるか確認(Python プロジェクト)
if [ -f "pytest.ini" ] || [ -f "setup.py" ]; then
if command -v pytest &> /dev/null; then
pytest
if [ $? -ne 0 ]; then
echo "❌ テスト失敗。コミットをブロックします。"
exit 1
fi
fi
fi
# go.mod の有無を確認(Go プロジェクト)
if [ -f "go.mod" ]; then
go test ./...
if [ $? -ne 0 ]; then
echo "❌ テスト失敗。コミットをブロックします。"
exit 1
fi
fi
# Cargo.toml の有無を確認(Rust プロジェクト)
if [ -f "Cargo.toml" ]; then
cargo test
if [ $? -ne 0 ]; then
echo "❌ テスト失敗。コミットをブロックします。"
exit 1
fi
fi
echo "✅ 全テスト合格。コミットを続行します。"
exit 0