18 lines
861 B
Bash
18 lines
861 B
Bash
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# lib/clean-start.sh — single source of truth for the pre-session reset.
|
|
# Caller must already be INSIDE the genome checkout.
|
|
# Aligns the working tree to origin/<base>. Never force-pushes a shared branch.
|
|
# Tolerates a missing remote branch (first-setup scenario).
|
|
# NOTE: sourced library — no `set -euo pipefail` (would leak into the caller).
|
|
# =============================================================================
|
|
|
|
clean_start() {
|
|
local base="${INGEST_BASE:-main}"
|
|
git fetch -q origin || return 1
|
|
git switch -q "$base" 2>/dev/null || git checkout -q -b "$base" || return 1
|
|
if git ls-remote --exit-code --heads origin "$base" >/dev/null 2>&1; then
|
|
git reset -q --hard "origin/${base}" || return 1
|
|
fi
|
|
git clean -q -fd || return 1
|
|
}
|