|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Builds a throwaway repo + bare "origin" so git_pruner has realistic branch |
| 3 | +# state to render: merged branches, gone upstreams, unmerged work, no-upstream. |
| 4 | +# |
| 5 | +# macOS only: the date arithmetic below uses BSD `date -v`. |
| 6 | +set -euo pipefail |
| 7 | + |
| 8 | +ROOT="${1:?usage: make-demo-repo.sh <dir>}" |
| 9 | +rm -rf "$ROOT" |
| 10 | +mkdir -p "$ROOT" |
| 11 | +REMOTE="$ROOT/origin.git" |
| 12 | +WORK="$ROOT/orbital" |
| 13 | + |
| 14 | +git init --quiet --bare -b main "$REMOTE" |
| 15 | +git init --quiet -b main "$WORK" |
| 16 | +cd "$WORK" |
| 17 | + |
| 18 | +git config user.name "Ada Reyes" |
| 19 | +git config user.email "ada@example.com" |
| 20 | +git config commit.gpgsign false |
| 21 | +git remote add origin "$REMOTE" |
| 22 | + |
| 23 | +# Every commit gets an explicit date so the relative-time column reads naturally. |
| 24 | +commit() { # commit <days-ago> <subject> <file> |
| 25 | + local days="$1" subject="$2" file="$3" |
| 26 | + local when |
| 27 | + when=$(date -u -v-"${days}"d +"%Y-%m-%dT%H:%M:%S") |
| 28 | + mkdir -p "$(dirname "$file")" |
| 29 | + printf '// %s\npackage orbital\n' "$subject" >> "$file" |
| 30 | + git add -A |
| 31 | + GIT_AUTHOR_DATE="$when" GIT_COMMITTER_DATE="$when" git commit --quiet -m "$subject" |
| 32 | +} |
| 33 | + |
| 34 | +branch_from_main() { git checkout --quiet -B "$1" main; } |
| 35 | + |
| 36 | +merge() { # merge <days-ago> <branch> |
| 37 | + local when |
| 38 | + when=$(date -u -v-"$1"d +"%Y-%m-%dT%H:%M:%S") |
| 39 | + GIT_AUTHOR_DATE="$when" GIT_COMMITTER_DATE="$when" \ |
| 40 | + git merge --quiet --no-ff -m "Merge branch '$2'" "$2" |
| 41 | +} |
| 42 | + |
| 43 | +# --- main line ------------------------------------------------------------- |
| 44 | +commit 210 "Initial commit: orbital service skeleton" README.md |
| 45 | +commit 190 "Add HTTP router and health endpoint" src/router.go |
| 46 | +commit 150 "Wire Postgres connection pool" src/store/pool.go |
| 47 | +commit 96 "Add structured logging middleware" src/middleware/log.go |
| 48 | +commit 61 "Support cursor pagination on /events" src/api/events.go |
| 49 | +git push --quiet -u origin main |
| 50 | + |
| 51 | +# --- merged into main, remote still present (safe -d) ---------------------- |
| 52 | +branch_from_main feature/rate-limiter |
| 53 | +commit 44 "Add token-bucket rate limiter" src/middleware/ratelimit.go |
| 54 | +commit 43 "Rate limiter: per-tenant buckets" src/middleware/ratelimit.go |
| 55 | +git push --quiet -u origin feature/rate-limiter |
| 56 | + |
| 57 | +branch_from_main chore/bump-deps |
| 58 | +commit 38 "Bump golang.org/x/net to 0.38.0" go.mod |
| 59 | +git push --quiet -u origin chore/bump-deps |
| 60 | + |
| 61 | +branch_from_main fix/timezone-parsing |
| 62 | +commit 30 "Parse RFC3339 offsets without truncating" src/api/time.go |
| 63 | +git push --quiet -u origin fix/timezone-parsing |
| 64 | + |
| 65 | +git checkout --quiet main |
| 66 | +merge 23 feature/rate-limiter |
| 67 | +merge 22 chore/bump-deps |
| 68 | +merge 21 fix/timezone-parsing |
| 69 | +commit 20 "Cache tenant lookups for 30s" src/store/tenant.go |
| 70 | +git push --quiet origin main |
| 71 | + |
| 72 | +# --- upstream deleted on the remote (shows as "gone" after p) -------------- |
| 73 | +branch_from_main feature/webhook-retries |
| 74 | +commit 27 "Retry webhooks with exponential backoff" src/webhook/retry.go |
| 75 | +commit 26 "Cap webhook retries at 5 attempts" src/webhook/retry.go |
| 76 | +git push --quiet -u origin feature/webhook-retries |
| 77 | + |
| 78 | +branch_from_main fix/session-leak |
| 79 | +commit 24 "Close idle sessions on shutdown" src/store/session.go |
| 80 | +git push --quiet -u origin fix/session-leak |
| 81 | + |
| 82 | +branch_from_main release/v2.4.0 |
| 83 | +commit 18 "Release v2.4.0" CHANGELOG.md |
| 84 | +git push --quiet -u origin release/v2.4.0 |
| 85 | + |
| 86 | +# Merge them so they carry no unique work, then delete the remote refs: this is |
| 87 | +# exactly the state `p` (fetch --prune) is meant to surface. |
| 88 | +git checkout --quiet main |
| 89 | +merge 17 feature/webhook-retries |
| 90 | +merge 16 fix/session-leak |
| 91 | +merge 15 release/v2.4.0 |
| 92 | +git push --quiet origin main |
| 93 | + |
| 94 | +# Delete the upstreams inside the bare repo rather than with `push --delete`, |
| 95 | +# which would also drop the local remote-tracking refs and make the branches read |
| 96 | +# as gone before the demo ever runs. This way they stay "stale but not yet |
| 97 | +# pruned" — the state pressing `p` is there to resolve. |
| 98 | +git -C "$REMOTE" branch -q -D feature/webhook-retries fix/session-leak release/v2.4.0 |
| 99 | + |
| 100 | +# --- unmerged work, upstream alive (ahead > 0, needs -D) ------------------- |
| 101 | +branch_from_main feature/oauth-device-flow |
| 102 | +commit 9 "Add device authorization grant" src/auth/device.go |
| 103 | +commit 7 "Poll token endpoint with backoff" src/auth/device.go |
| 104 | +git push --quiet -u origin feature/oauth-device-flow |
| 105 | +commit 3 "WIP: verification_uri_complete" src/auth/device.go |
| 106 | + |
| 107 | +branch_from_main feature/audit-log |
| 108 | +commit 12 "Append-only audit log writer" src/audit/writer.go |
| 109 | +git push --quiet -u origin feature/audit-log |
| 110 | +commit 5 "Redact PII from audit entries" src/audit/redact.go |
| 111 | + |
| 112 | +# --- no upstream at all ---------------------------------------------------- |
| 113 | +branch_from_main spike/graphql-gateway |
| 114 | +commit 34 "Spike: graphql gateway in front of REST" src/gateway/schema.go |
| 115 | + |
| 116 | +branch_from_main refactor/storage-adapter |
| 117 | +commit 2 "Extract storage behind an adapter interface" src/store/adapter.go |
| 118 | + |
| 119 | +git checkout --quiet main |
| 120 | +commit 1 "Emit request IDs on every response header" src/middleware/reqid.go |
| 121 | +git push --quiet origin main |
| 122 | +# Deliberately no `fetch --prune` here: the deleted upstreams must stay |
| 123 | +# unpruned so pressing `p` in the demo is what reveals them as gone. |
| 124 | +echo "demo repo ready: $WORK" |
0 commit comments