From 8f94dcff7473cbeb09c9542491ff27bdd9b3ff95 Mon Sep 17 00:00:00 2001 From: Bryan Deng Date: Fri, 15 May 2026 23:56:07 +0800 Subject: [PATCH] docs: add branch protection setup script and stacking workflow guide --- .github/scripts/setup-branch-protection.sh | 47 +++++++++++++ dev-docs/stacking-workflow.md | 78 ++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100755 .github/scripts/setup-branch-protection.sh create mode 100644 dev-docs/stacking-workflow.md diff --git a/.github/scripts/setup-branch-protection.sh b/.github/scripts/setup-branch-protection.sh new file mode 100755 index 0000000..2b4a6e7 --- /dev/null +++ b/.github/scripts/setup-branch-protection.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# sets up branch protection for the main branch. +# prerequisites: gh CLI authenticated, run from repo root. +# usage: bash .github/scripts/setup-branch-protection.sh [branch] + +set -euo pipefail + +GREEN='\033[0;32m' +CYAN='\033[0;36m' +RESET='\033[0m' + +BRANCH="${1:-main}" +REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner) + +echo "Configuring branch protection for '$BRANCH' in $REPO..." + +gh api \ + --method PUT \ + "repos/$REPO/branches/$BRANCH/protection" \ + --input - <` | start new branch off main | +| `git town append ` | add branch on top of current branch | +| `git town prepend ` | insert branch below current branch | +| `git town sync` | sync current branch only | +| `git town sync --stack` | sync entire stack | +| `git town propose` | open or update PR with correct target | +| `git town switch` | interactive branch switcher | +| `git town compress` | squash all commits on current branch into one | +| `git town kill` | delete current branch and its PR | +| `git town diff` | show diff for current branch only (not parent) | +| `git town branch` | show current branch and position in stack | + +## Rules + +- Stack only branches that depend on each other. Independent work goes on separate top-level branches. +- Always ship oldest-first (bottom of stack before top). +- Never force-push to `main` or other perennial branches.