cd /Users/rbutare/websites/apps/aiwizard
cat > tools/git.menu.sh <<'SH'
#!/bin/bash
BASE="/Users/rbutare/websites/apps/aiwizard"; cd $BASE
show_status(){ echo "=== STATUS ==="; echo "Branch: $(git branch --show-current)"; echo "Last: $(git log --oneline -1)"; echo "Tag: $(git describe --tags --abbrev=0 2>/dev/null || echo no tag)"; echo "Owner: $(ls -ld . | awk '{print $3}')"; ./tools/test.all.sh all 2>&1 | tail -6; ./tools/code.count.sh 2>/dev/null; }
show_versions(){ git tag --sort=-v:refname | head -20; echo ""; git branch -a; echo ""; git log --oneline --graph --all --decorate -12; }
what_changed(){ LAST=$(git describe --tags --abbrev=0 2>/dev/null || echo HEAD~1); echo "Last tag: $LAST"; git diff $LAST --stat; echo ""; git log $LAST..HEAD --oneline; echo ""; echo "Suggested msg: vX.Y - $(git diff $LAST --stat | tail -1)"; }
while true; do
 echo ""; echo "===== GIT MENU rbutareOld ====="
 echo "1) Current status  2) Versions/tags/log  3) What changed (for msg)"
 echo "4) Update to next version  5) Go back to previous  6) Quick commit  7) Fix owner  8) Test  9) Exit"
 read -p "Choice [1-9]: " C
 case $C in
  1) show_status;;
  2) show_versions;;
  3) what_changed;;
  4) read -p "Next ver (1.8): " V; read -p "What did you do?: " M; git add -A; git status --short; read -p "Commit? y/n: " Y; [ "$Y" = "y" ] && git commit -m "v$V - $M" && git tag -a v$V -m "v$V $M" && git log --oneline -2;;
  5) git tag --sort=-v:refname; read -p "Tag to go back to (v1.6): " T; read -p "New branch name (v1.6-fix): " B; git checkout -b $B $T; ./tools/test.all.sh all;;
  6) git status --short; git diff --stat; read -p "msg: " M; git add -A; git commit -m "$M";;
  7) sudo chown -R $(whoami):staff .; sudo xattr -cr .; git config --global --add safe.directory $BASE; echo "fixed $(whoami)";;
  8) ./tools/test.all.sh all;;
  9) exit 0;;
 esac
 read -p "ENTER..."
done
SH
chmod +x tools/git.menu.sh
./tools/git.menu.sh
