Something went wrong. Try again.
Personal iOS fork of Witchsky (itself a fork of Bluesky social-app).
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227#!/usr/bin/env bash## Sync this personal Tigerfly build with its Witchsky upstream.## Runs the deterministic, mechanical parts of the "Updating from upstream"# process documented in AGENTS.md and STOPS wherever human judgment (merge# conflicts) or the physical device (Release build/install) is required.## It never pushes, never auto-resolves conflicts, and never reads or writes# .env.local.## Usage:# scripts/sync-upstream.sh [options]## Options:# --rebase Rebase onto upstream instead of merging. Rewrites local# history; avoid when main is already pushed to origin.# --prebuild After a clean sync, regenerate ios/ (needs Ruby via mise).# --post-merge Skip fetch/merge and only run the post-merge housekeeping# (install, intl, typecheck). Use this after resolving a# conflict and running `git merge --continue`.# --skip-install Skip `pnpm install --frozen-lockfile`.# --skip-intl Skip the locale extract/compile step.# --skip-typecheck Skip `pnpm typecheck:ios`.# --remote <name> Upstream remote to sync from (default: witchsky).# --branch <name> Upstream branch to sync from (default: main).# -h, --help Show this help and exit.
set -euo pipefail
UPSTREAM_REMOTE="witchsky"UPSTREAM_BRANCH="main"PUBLISH_REMOTE="origin"PM="pnpm@11.21.0"RUBY="ruby@2.7.6"
USE_REBASE=0DO_PREBUILD=0POST_MERGE_ONLY=0SKIP_INSTALL=0SKIP_INTL=0SKIP_TYPECHECK=0
# Paths where an upstream conflict needs deliberate, fork-aware resolution# (see the "Age-assurance" and "Current personal-build patch" notes in AGENTS.md).SENSITIVE_PATHS=( "app.config.js" "plugins/" "src/lib/notifications/" "src/ageAssurance/" "src/env/common.ts")
bold() { printf '\033[1m%s\033[0m\n' "$1"; }info() { printf '\033[36m›\033[0m %s\n' "$1"; }warn() { printf '\033[33m! %s\033[0m\n' "$1"; }die() { printf '\033[31m✗ %s\033[0m\n' "$1" >&2 exit 1}run() { printf '\033[2m$ %s\033[0m\n' "$*" "$@"}
usage() { sed -n '2,/^set -euo/p' "$0" | sed 's/^# \{0,1\}//; s/^#//; /^set -euo/d' exit "${1:-0}"}
while [ $# -gt 0 ]; do case "$1" in --rebase) USE_REBASE=1 ;; --prebuild) DO_PREBUILD=1 ;; --post-merge) POST_MERGE_ONLY=1 ;; --skip-install) SKIP_INSTALL=1 ;; --skip-intl) SKIP_INTL=1 ;; --skip-typecheck) SKIP_TYPECHECK=1 ;; --remote) shift; UPSTREAM_REMOTE="${1:?--remote needs a value}" ;; --branch) shift; UPSTREAM_BRANCH="${1:?--branch needs a value}" ;; -h|--help) usage 0 ;; *) die "Unknown option: $1 (see --help)" ;; esac shiftdone
cd "$(git rev-parse --show-toplevel)"
pnpm_run() { run mise exec "$PM" -- pnpm "$@"; }
post_merge() { bold "Post-merge housekeeping" command -v mise >/dev/null 2>&1 || die "mise not found; install it, then re-run with --post-merge."
if [ "$SKIP_INSTALL" -eq 0 ]; then info "Installing dependencies (frozen lockfile)" pnpm_run install --frozen-lockfile fi if [ "$SKIP_INTL" -eq 0 ]; then info "Refreshing locale catalogs" pnpm_run intl:extract pnpm_run intl:compile fi if [ "$SKIP_TYPECHECK" -eq 0 ]; then info "Type-checking iOS project" pnpm_run typecheck:ios fi if [ "$DO_PREBUILD" -eq 1 ]; then info "Regenerating ios/ (prebuild --clean)" run env EXPO_NO_GIT_STATUS=1 mise exec "$RUBY" "$PM" -- pnpm prebuild --platform ios fi}
next_steps() { bold "Next steps (not automated — need the device / your call)" cat <<EOF Verify the generated project, then build, install, and validate on device per AGENTS.md (bundle id me.malstrom.tigerfly, no aps-environment, scene manifest present, OAuth login, home feed, DMs, no age gate, etc.):
xcodebuild -workspace ios/Tigerfly.xcworkspace -scheme Tigerfly \\ -configuration Release -destination "platform=iOS,name=Mark’s iPhone Air" \\ -derivedDataPath build/ios-personal -allowProvisioningUpdates \\ CODE_SIGN_STYLE=Automatic build
Publish once validated:
git push $PUBLISH_REMOTE $(git symbolic-ref --short -q HEAD || echo main)EOF}
if [ "$POST_MERGE_ONLY" -eq 1 ]; then post_merge next_steps exit 0fi
# --- Preflight -------------------------------------------------------------bold "Preflight"
git remote get-url "$UPSTREAM_REMOTE" >/dev/null 2>&1 \ || die "Remote '$UPSTREAM_REMOTE' not found. Configure it or pass --remote."
BRANCH="$(git symbolic-ref --short -q HEAD || echo DETACHED)"[ "$BRANCH" != "DETACHED" ] || die "HEAD is detached; check out a branch first."info "On branch: $BRANCH"[ "$BRANCH" = "main" ] || warn "Not on 'main'; upstream will be integrated into '$BRANCH'."
if [ -e .git/MERGE_HEAD ] || [ -d .git/rebase-merge ] || [ -d .git/rebase-apply ]; then die "A merge/rebase is already in progress. Finish it (git merge --continue) or abort it, then re-run with --post-merge."fi
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then git status --short --untracked-files=no die "Working tree has uncommitted tracked changes. Commit or stash them first (the personal-build patch is already committed on this fork)."fi
[ -f .env.local ] || warn ".env.local is missing; the Release build will need it (bundle id / Apple team)."
BEFORE="$(git rev-parse HEAD)"
# --- Fetch -----------------------------------------------------------------bold "Fetching $UPSTREAM_REMOTE"run git fetch "$UPSTREAM_REMOTE" --prune
UPSTREAM_REF="$UPSTREAM_REMOTE/$UPSTREAM_BRANCH"git rev-parse --verify --quiet "$UPSTREAM_REF" >/dev/null \ || die "Ref '$UPSTREAM_REF' not found after fetch."
INCOMING="$(git rev-list --count "HEAD..$UPSTREAM_REF")"if [ "$INCOMING" -eq 0 ]; then info "Already up to date with $UPSTREAM_REF (at $(git rev-parse --short HEAD))." exit 0fi
bold "$INCOMING new upstream commit(s) from $UPSTREAM_REF"git --no-pager log -40 --oneline --no-decorate "HEAD..$UPSTREAM_REF"[ "$INCOMING" -le 40 ] || info "(showing first 40 of $INCOMING)"echogit diff --stat "HEAD...$UPSTREAM_REF" | tail -1
# --- Integrate -------------------------------------------------------------handle_conflicts() { local op="$1" local unmerged unmerged="$(git diff --name-only --diff-filter=U || true)" if [ -z "$unmerged" ]; then die "$op failed (no conflicts detected — see the git output above)." fi echo warn "$op stopped on conflicts. Resolve these, then run: git $op --continue" echo "$unmerged" | sed 's/^/ /' local hit while IFS= read -r f; do for s in "${SENSITIVE_PATHS[@]}"; do case "$f" in "$s"*) hit="${hit} $f (resolve deliberately — see AGENTS.md)\n" ;; esac done done <<< "$unmerged" if [ -n "${hit:-}" ]; then echo warn "Fork-critical files in this set — do NOT blindly take upstream:" printf "$hit" fi echo info "After 'git $op --continue', finish with: scripts/sync-upstream.sh --post-merge" info "To back out entirely: git $op --abort" exit 2}
if [ "$USE_REBASE" -eq 1 ]; then bold "Rebasing $BRANCH onto $UPSTREAM_REF" warn "Rebase rewrites local history; you will need to force-push if $BRANCH is already published." if ! run git rebase "$UPSTREAM_REF"; then handle_conflicts rebase; fielse bold "Merging $UPSTREAM_REF into $BRANCH" if ! run git merge --no-edit "$UPSTREAM_REF"; then handle_conflicts merge; fifi
info "Integrated cleanly: $(git rev-parse --short "$BEFORE") → $(git rev-parse --short HEAD)"
# --- Housekeeping + handoff ------------------------------------------------post_mergeechonext_steps