Files
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Has been cancelled
Deploy to Cloudflare Pages / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

1 line
8.7 KiB
JSON

{"content": "{\n \"description\": \"Complete Git Flow configuration with statusline, permissions, environment variables, and workflow enforcement. Displays real-time Git Flow status, prevents direct pushes to main/develop, allows feature/release/hotfix operations, and configures Git Flow branch naming conventions. Perfect for teams following Git Flow branching strategy.\",\n \"statusLine\": {\n \"type\": \"command\",\n \"command\": \"bash -c 'if ! git rev-parse --git-dir >/dev/null 2>&1; then echo \\\"Not a git repository\\\"; exit 0; fi; BRANCH=$(git branch --show-current 2>/dev/null); if [ -z \\\"$BRANCH\\\" ]; then echo \\\"Detached HEAD\\\"; exit 0; fi; ICON=\\\"📁\\\"; TARGET=\\\"\\\"; if [[ $BRANCH == feature/* ]]; then ICON=\\\"🌿\\\"; TARGET=\\\"→ develop\\\"; elif [[ $BRANCH == release/* ]]; then ICON=\\\"🚀\\\"; TARGET=\\\"→ main\\\"; elif [[ $BRANCH == hotfix/* ]]; then ICON=\\\"🔥\\\"; TARGET=\\\"→ main+develop\\\"; elif [[ $BRANCH == \\\"develop\\\" ]]; then ICON=\\\"🔀\\\"; elif [[ $BRANCH == \\\"main\\\" ]]; then ICON=\\\"🏠\\\"; fi; AHEAD=$(git rev-list --count @{u}..HEAD 2>/dev/null || echo \\\"0\\\"); BEHIND=$(git rev-list --count HEAD..@{u} 2>/dev/null || echo \\\"0\\\"); SYNC=\\\"\\\"; if [ \\\"$AHEAD\\\" -gt 0 ]; then SYNC=\\\" ↑$AHEAD\\\"; fi; if [ \\\"$BEHIND\\\" -gt 0 ]; then SYNC=\\\"$SYNC ↓$BEHIND\\\"; fi; MODIFIED=$(git status --porcelain 2>/dev/null | grep \\\"^ M\\\" | wc -l | tr -d \\\" \\\"); ADDED=$(git status --porcelain 2>/dev/null | grep \\\"^??\\\" | wc -l | tr -d \\\" \\\"); DELETED=$(git status --porcelain 2>/dev/null | grep \\\"^ D\\\" | wc -l | tr -d \\\" \\\"); CHANGES=\\\"\\\"; if [ \\\"$MODIFIED\\\" -gt 0 ]; then CHANGES=\\\" ●$MODIFIED\\\"; fi; if [ \\\"$ADDED\\\" -gt 0 ]; then CHANGES=\\\"$CHANGES ✚$ADDED\\\"; fi; if [ \\\"$DELETED\\\" -gt 0 ]; then CHANGES=\\\"$CHANGES ✖$DELETED\\\"; fi; if [ -n \\\"$TARGET\\\" ]; then echo \\\"$ICON $BRANCH$SYNC$CHANGES | 🎯 $TARGET\\\"; else echo \\\"$ICON $BRANCH$SYNC$CHANGES\\\"; fi'\"\n },\n \"permissions\": {\n \"deny\": [\n \"Bash(git push origin main:*)\",\n \"Bash(git push origin develop:*)\",\n \"Bash(git push --force:*)\",\n \"Bash(git push -f:*)\",\n \"Bash(git reset --hard:*)\",\n \"Bash(git rebase -i:*)\"\n ],\n \"allow\": [\n \"Bash(git status:*)\",\n \"Bash(git diff:*)\",\n \"Bash(git add:*)\",\n \"Bash(git commit:*)\",\n \"Bash(git log:*)\",\n \"Bash(git branch:*)\",\n \"Bash(git checkout:*)\",\n \"Bash(git pull:*)\",\n \"Bash(git fetch:*)\",\n \"Bash(git merge:*)\",\n \"Bash(git tag:*)\",\n \"Bash(git push origin feature/*:*)\",\n \"Bash(git push origin release/*:*)\",\n \"Bash(git push origin hotfix/*:*)\",\n \"Bash(git push --tags:*)\",\n \"Bash(git push -u:*)\",\n \"Bash(git flow:*)\",\n \"Bash(gh pr:*)\",\n \"Bash(gh issue:*)\",\n \"Bash(npm test:*)\",\n \"Bash(npm run:*)\"\n ]\n },\n \"env\": {\n \"GIT_FLOW_MAIN_BRANCH\": \"main\",\n \"GIT_FLOW_DEVELOP_BRANCH\": \"develop\",\n \"GIT_FLOW_PREFIX_FEATURE\": \"feature/\",\n \"GIT_FLOW_PREFIX_RELEASE\": \"release/\",\n \"GIT_FLOW_PREFIX_HOTFIX\": \"hotfix/\",\n \"GIT_FLOW_VERSION_TAG_PREFIX\": \"v\"\n },\n \"hooks\": {\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"if echo \\\"$CLAUDE_TOOL_COMMAND\\\" | grep -q 'git checkout -b'; then BRANCH_NAME=$(echo \\\"$CLAUDE_TOOL_COMMAND\\\" | sed -n 's/.*git checkout -b \\\\([^ ]*\\\\).*/\\\\1/p'); if [[ -n \\\"$BRANCH_NAME\\\" ]] && [[ \\\"$BRANCH_NAME\\\" != \\\"main\\\" ]] && [[ \\\"$BRANCH_NAME\\\" != \\\"develop\\\" ]]; then if [[ ! \\\"$BRANCH_NAME\\\" =~ ^(feature|release|hotfix)/ ]]; then echo \\\"❌ Invalid Git Flow branch name: $BRANCH_NAME\\\"; echo \\\"\\\"; echo \\\"Git Flow branches must follow these patterns:\\\"; echo \\\" • feature/<descriptive-name>\\\"; echo \\\" • release/v<MAJOR>.<MINOR>.<PATCH>\\\"; echo \\\" • hotfix/<descriptive-name>\\\"; echo \\\"\\\"; echo \\\"Examples:\\\"; echo \\\" ✅ feature/user-authentication\\\"; echo \\\" ✅ release/v1.2.0\\\"; echo \\\" ✅ hotfix/critical-security-fix\\\"; echo \\\"\\\"; echo \\\"Invalid:\\\"; echo \\\" ❌ $BRANCH_NAME (missing Git Flow prefix)\\\"; echo \\\" ❌ feat/something (use 'feature/' not 'feat/')\\\"; echo \\\" ❌ fix/bug (use 'hotfix/' not 'fix/')\\\"; echo \\\"\\\"; echo \\\"💡 Use Git Flow commands instead:\\\"; echo \\\" /feature <name> - Create feature branch\\\"; echo \\\" /release <version> - Create release branch\\\"; echo \\\" /hotfix <name> - Create hotfix branch\\\"; exit 1; fi; if [[ \\\"$BRANCH_NAME\\\" =~ ^release/ ]] && [[ ! \\\"$BRANCH_NAME\\\" =~ ^release/v[0-9]+\\\\.[0-9]+\\\\.[0-9]+(-.+)?$ ]]; then echo \\\"❌ Invalid release version: $BRANCH_NAME\\\"; echo \\\"\\\"; echo \\\"Release branches must follow semantic versioning:\\\"; echo \\\" release/vMAJOR.MINOR.PATCH[-prerelease]\\\"; echo \\\"\\\"; echo \\\"Valid examples:\\\"; echo \\\" ✅ release/v1.0.0\\\"; echo \\\" ✅ release/v2.1.3\\\"; echo \\\" ✅ release/v1.0.0-beta.1\\\"; echo \\\"\\\"; echo \\\"Invalid:\\\"; echo \\\" ❌ release/1.0.0 (missing 'v' prefix)\\\"; echo \\\" ❌ release/v1.0 (incomplete version)\\\"; echo \\\" ❌ $BRANCH_NAME\\\"; echo \\\"\\\"; echo \\\"💡 Use: /release v1.2.0\\\"; exit 1; fi; fi; fi\"\n }\n ]\n },\n {\n \"matcher\": \"Bash(git commit:*)\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"COMMIT_MSG=$(echo \\\"$CLAUDE_TOOL_COMMAND\\\" | grep -oP '(?<=-m \\\")[^\\\"]+' | head -1); if [[ -n \\\"$COMMIT_MSG\\\" ]] && [[ ! \\\"$COMMIT_MSG\\\" =~ ^(feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert)(\\\\(.+\\\\))?:\\\\ ]]; then echo \\\"❌ Invalid commit message format\\\"; echo \\\"\\\"; echo \\\"Commit messages must follow Conventional Commits:\\\"; echo \\\" type(scope): description\\\"; echo \\\"\\\"; echo \\\"Types:\\\"; echo \\\" feat: New feature\\\"; echo \\\" fix: Bug fix\\\"; echo \\\" docs: Documentation changes\\\"; echo \\\" style: Code style changes (formatting)\\\"; echo \\\" refactor: Code refactoring\\\"; echo \\\" perf: Performance improvements\\\"; echo \\\" test: Adding or updating tests\\\"; echo \\\" chore: Maintenance tasks\\\"; echo \\\" ci: CI/CD changes\\\"; echo \\\" build: Build system changes\\\"; echo \\\" revert: Revert previous commit\\\"; echo \\\"\\\"; echo \\\"Examples:\\\"; echo \\\" ✅ feat: add user authentication\\\"; echo \\\" ✅ feat(auth): implement JWT tokens\\\"; echo \\\" ✅ fix: resolve memory leak in parser\\\"; echo \\\" ✅ fix(api): handle null responses\\\"; echo \\\" ✅ docs: update API documentation\\\"; echo \\\" ❌ Added new feature (no type)\\\"; echo \\\" ❌ feat:add feature (missing space)\\\"; echo \\\" ❌ feature: add login (wrong type)\\\"; echo \\\"\\\"; echo \\\"Your message: $COMMIT_MSG\\\"; exit 1; fi\"\n }\n ]\n },\n {\n \"matcher\": \"Bash(git push:*)\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"PUSH_CMD=\\\"$CLAUDE_TOOL_COMMAND\\\"; CURRENT_BRANCH=$(git branch --show-current 2>/dev/null); if [[ \\\"$PUSH_CMD\\\" =~ (origin[[:space:]]+main|origin[[:space:]]+develop|main|develop) ]] || [[ \\\"$CURRENT_BRANCH\\\" == \\\"main\\\" || \\\"$CURRENT_BRANCH\\\" == \\\"develop\\\" ]]; then if [[ \\\"$PUSH_CMD\\\" != *\\\"--force\\\"* ]] && ([[ \\\"$CURRENT_BRANCH\\\" == \\\"main\\\" ]] || [[ \\\"$CURRENT_BRANCH\\\" == \\\"develop\\\" ]] || [[ \\\"$PUSH_CMD\\\" =~ origin[[:space:]]main ]] || [[ \\\"$PUSH_CMD\\\" =~ origin[[:space:]]develop ]]); then echo \\\"❌ Direct push to main/develop is not allowed!\\\"; echo \\\"\\\"; echo \\\"Protected branches:\\\"; echo \\\" - main (production)\\\"; echo \\\" - develop (integration)\\\"; echo \\\"\\\"; echo \\\"Git Flow workflow:\\\"; echo \\\" 1. Create a feature branch:\\\"; echo \\\" /feature <name>\\\"; echo \\\"\\\"; echo \\\" 2. Make your changes and commit\\\"; echo \\\"\\\"; echo \\\" 3. Push feature branch:\\\"; echo \\\" git push origin feature/<name>\\\"; echo \\\"\\\"; echo \\\" 4. Create pull request:\\\"; echo \\\" gh pr create\\\"; echo \\\"\\\"; echo \\\" 5. After approval, merge with:\\\"; echo \\\" /finish\\\"; echo \\\"\\\"; echo \\\"For releases:\\\"; echo \\\" /release <version> → PR → /finish\\\"; echo \\\"\\\"; echo \\\"For hotfixes:\\\"; echo \\\" /hotfix <name> → PR → /finish\\\"; echo \\\"\\\"; echo \\\"Current branch: $CURRENT_BRANCH\\\"; exit 1; fi; fi\"\n }\n ]\n }\n ]\n }\n}\n"}