12 lines
355 B
Bash
Executable File
12 lines
355 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
BASE=/srv/prime-core
|
|
COMMIT="${1:-}"
|
|
[[ -n "$COMMIT" ]] || { echo "Usage: restore.sh <commit-id>"; exit 1; }
|
|
cd "$BASE"
|
|
git rev-parse --verify "$COMMIT^{commit}" >/dev/null
|
|
SNAP="pre-restore-$(date -u +%Y%m%dT%H%M%SZ)"
|
|
git tag "$SNAP" HEAD
|
|
git checkout -f "$COMMIT"
|
|
echo "Restored workspace to $COMMIT (saved $SNAP)"
|