Files
xandClaude Opus 4.8 03defe48b0 chore(devops): doctor, branch auto-prune, and Dependabot
Boring-but-recurring quality-of-life:

- `npm run doctor` — one-command env triage: node>=22, node_modules,
  .env.local + DATABASE_URL, Postgres reachable, gh auth, box ssh, git
  auto-prune. ✓/⚠/✗ per check; hard failures exit non-zero. Answers
  "why is X broken" without a scavenger hunt.
- `npm run git:prune` (+ remote.origin.prune=true on this clone) —
  conservatively deletes local branches whose upstream is gone or that
  are merged into main; never touches current/main/unmerged. I hand-
  cleaned 8 branches this week; now it's one command.
- .github/dependabot.yml — weekly grouped minor/patch bumps for the web
  app, desktop app, and GitHub Actions (majors stay separate for review).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 13:24:27 +02:00

36 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# prune-merged.sh — tidy up local branches, conservatively.
#
# Deletes only branches that are SAFE to lose:
# 1. upstream gone — the remote branch was deleted (merged PR, cleanup)
# 2. ancestry-merged — fully merged into origin/main (git branch --merged)
# Never touches the current branch, main/master, or anything with unmerged
# commits. Content-merged-but-different-SHA branches (rare) are left for a human.
#
# Usage: bash scripts/git/prune-merged.sh (or: npm run git:prune)
set -uo pipefail
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
git fetch --prune origin -q 2>/dev/null || true
CURRENT=$(git branch --show-current 2>/dev/null || echo "")
deleted=0
# 1) upstream gone
while IFS= read -r b; do
[ -z "$b" ] && continue
[ "$b" = "$CURRENT" ] && continue
if git branch -D "$b" >/dev/null 2>&1; then
echo " deleted (upstream gone): $b"; deleted=$((deleted+1))
fi
done < <(git branch -vv | awk '/: gone\]/{print $1}' | sed 's/^[*+] *//')
# 2) fully merged into origin/main (ancestry) — safe delete
while IFS= read -r b; do
case "$b" in main|master|"$CURRENT"|"") continue ;; esac
if git branch -d "$b" >/dev/null 2>&1; then
echo " deleted (merged into main): $b"; deleted=$((deleted+1))
fi
done < <(git branch --merged origin/main --format='%(refname:short)' 2>/dev/null)
echo " git:prune — removed $deleted local branch(es)"