lilith-platform.live/scripts/run/git-sync-main.sh

25 lines
No EOL
841 B
Bash

#!/usr/bin/env bash
# Fast-forward the repo to origin/main before deploying.
# Sourced by scripts/run/deploy.sh and deploy scripts — do not execute directly.
#
# Requires a clean working tree (no uncommitted changes).
sync_main() {
local repo_root="${1:?repo root required}"
if ! git -C "$repo_root" rev-parse --is-inside-work-tree &>/dev/null; then
echo "ERROR: not a git repository: $repo_root" >&2
return 1
fi
if [[ -n "$(git -C "$repo_root" status --porcelain)" ]]; then
echo "ERROR: uncommitted changes — commit or discard before deploying" >&2
git -C "$repo_root" status --short >&2
return 1
fi
echo "==> Syncing with origin/main (ff-only)..."
git -C "$repo_root" fetch origin main
git -C "$repo_root" merge --ff-only origin/main
echo " at $(git -C "$repo_root" rev-parse --short HEAD)"
}