Files
FTStore/scripts/sync-upstream.sh
T
Felitendo a0ee8283f0 chore: track upstream Feather + add rebrand tooling
Establishes FTStore as a downstream fork of claration/Feather that tracks upstream. Adds .upstream-sync.json (last-merged upstream commit/version), an idempotent rebrand script (scripts/apply-rebrand.sh), a sync workflow (scripts/sync-upstream.sh), and CLAUDE.md documenting the merge + rebrand process.
2026-05-30 02:30:20 +02:00

78 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# sync-upstream.sh — pull changes from upstream Feather into FTStore.
#
# Workflow:
# 1. Fetch upstream and report how far behind we are (vs .upstream-sync.json).
# 2. Optionally merge upstream/main (pass --merge).
# 3. Re-apply the FTStore rebrand (scripts/apply-rebrand.sh).
# 4. Remind you to update .upstream-sync.json once the merge is committed.
#
# Run with no args for a read-only status report. Run with --merge to merge.
#
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
SYNC_FILE=".upstream-sync.json"
REMOTE="upstream"
BRANCH="main"
DO_MERGE=0
[ "${1:-}" = "--merge" ] && DO_MERGE=1
bold() { printf '\033[1m%s\033[0m\n' "$*"; }
# Ensure the upstream remote exists.
if ! git remote get-url "$REMOTE" >/dev/null 2>&1; then
bold "Adding '$REMOTE' remote -> claration/Feather"
git remote add "$REMOTE" https://github.com/claration/Feather.git
fi
bold "Fetching $REMOTE …"
git fetch "$REMOTE" --tags
LAST="$(jq -r '.lastMerged.commit' "$SYNC_FILE")"
HEAD_UP="$(git rev-parse "$REMOTE/$BRANCH")"
COUNT="$(git rev-list --count "${LAST}..${REMOTE}/${BRANCH}")"
echo
bold "Last merged upstream commit: $LAST (version $(jq -r '.lastMerged.upstreamVersion' "$SYNC_FILE"), synced $(jq -r '.lastMerged.syncedAt' "$SYNC_FILE"))"
bold "Upstream $REMOTE/$BRANCH HEAD: $HEAD_UP"
bold "FTStore is $COUNT commit(s) behind upstream."
echo
if [ "$COUNT" -eq 0 ]; then
echo "Up to date. Nothing to merge."
exit 0
fi
bold "New upstream commits:"
git log --oneline --no-decorate "${LAST}..${REMOTE}/${BRANCH}"
echo
if [ "$DO_MERGE" -eq 0 ]; then
echo "Read-only report. Re-run with: scripts/sync-upstream.sh --merge"
exit 0
fi
bold "Merging $REMOTE/$BRANCH …"
if ! git merge --no-edit "$REMOTE/$BRANCH"; then
echo
bold "Merge conflicts detected. Resolve them, then:"
echo " - keep FTStore branding in app-repo.json / README.md / project.pbxproj"
echo " - run: bash scripts/apply-rebrand.sh"
echo " - commit, then update $SYNC_FILE (commit=$HEAD_UP) and re-run validation"
exit 1
fi
bold "Re-applying FTStore rebrand …"
bash scripts/apply-rebrand.sh
echo
bold "Merge + rebrand complete. Next:"
echo " 1. Review: git status && git diff"
echo " 2. Update $SYNC_FILE:"
echo " lastMerged.commit = $HEAD_UP"
echo " lastMerged.upstreamVersion = <new upstream version>"
echo " lastMerged.syncedAt = $(date +%F)"
echo " 3. Commit the merge + rebrand + sync-file bump."