|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Non-blocking nudge: when a push includes changes to first-party app source, |
| 4 | +# remind the author to run an architecture pass (the architecture-review skill / |
| 5 | +# REVIEW.md §10) before opening the PR. |
| 6 | +# |
| 7 | +# This is a REMINDER, not a gate — it always exits 0 and never blocks a push. |
| 8 | +# It stays silent unless the push actually touches first-party Kotlin/Java, so |
| 9 | +# docs-, test-, and vendored-only pushes produce no output. |
| 10 | + |
| 11 | +set -u |
| 12 | + |
| 13 | +cyan=$(tput setaf 6 2>/dev/null || true) |
| 14 | +yellow=$(tput setaf 3 2>/dev/null || true) |
| 15 | +reset=$(tput sgr0 2>/dev/null || true) |
| 16 | + |
| 17 | +# Determine the commits being pushed. Prefer the tracked upstream; fall back to |
| 18 | +# the integration branch (feature branches are based on stage). If neither is |
| 19 | +# resolvable, stay quiet rather than nag. |
| 20 | +if git rev-parse --abbrev-ref --symbolic-full-name '@{upstream}' >/dev/null 2>&1; then |
| 21 | + range="@{upstream}..HEAD" |
| 22 | +elif git rev-parse --verify -q origin/stage >/dev/null 2>&1; then |
| 23 | + range="origin/stage..HEAD" |
| 24 | +else |
| 25 | + exit 0 |
| 26 | +fi |
| 27 | + |
| 28 | +changed=$(git diff --name-only "$range" 2>/dev/null) || exit 0 |
| 29 | +[ -n "$changed" ] || exit 0 |
| 30 | + |
| 31 | +# Keep only first-party production Kotlin/Java: drop tests, generated build |
| 32 | +# output, and vendored subtrees (mirrors Spotless's commonTargetExcludes). |
| 33 | +firstparty=$(printf '%s\n' "$changed" \ |
| 34 | + | grep -E '\.(kt|java)$' \ |
| 35 | + | grep -vE '(^|/)(build|src/test|src/androidTest)/' \ |
| 36 | + | grep -vE '^(composite-builds/build-deps|termux/|eventbus/|LayoutEditor/|subprojects/(aaptcompiler|builder-model-impl|flashbar|xml-dom|llama\.cpp)/)' \ |
| 37 | + || true) |
| 38 | + |
| 39 | +[ -n "$firstparty" ] || exit 0 |
| 40 | + |
| 41 | +count=$(printf '%s\n' "$firstparty" | grep -c .) |
| 42 | + |
| 43 | +echo "" |
| 44 | +echo "${cyan}[architecture nudge]${reset} this push changes ${count} first-party source file(s)." |
| 45 | +echo "${yellow} Consider an architecture pass before opening the PR:${reset}" |
| 46 | +echo " - run the ${cyan}architecture-review${reset} skill (reads ARCHITECTURE.md + the ADRs, checks the diff), or" |
| 47 | +echo " - self-check against ${cyan}REVIEW.md section 10${reset} (UDF, sealed state, Koin, Room, module boundaries, Compose)." |
| 48 | +echo "${yellow} (Reminder only — your push continues.)${reset}" |
| 49 | +echo "" |
| 50 | + |
| 51 | +exit 0 |
0 commit comments