mirror of
https://github.com/lobomfz/VIctory-xmem.git
synced 2026-12-06 05:48:38 +00:00
The tool discovers local/data/*, writes to saves-backup/, keeps the newest 10 per data directory, and update.sh stops if the backup fails. No home-directory or title-ID assumptions.
49 lines
1.5 KiB
Bash
Executable File
49 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# Merges the latest upstream main into the current branch, then builds.
|
|
# The title's saves are backed up first, outside local/.
|
|
# usage: ./update.sh (UPSTREAM=remote and BRANCH=name to change them)
|
|
set -euo pipefail
|
|
if (( EUID == 0 )); then
|
|
echo "run update.sh as your normal user, not with sudo"
|
|
exit 1
|
|
fi
|
|
cd "$(dirname "$(readlink -f "$0")")"
|
|
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
echo "not a git checkout; download the repository with git first"
|
|
exit 1
|
|
fi
|
|
|
|
upstream=${UPSTREAM:-origin}
|
|
branch=${BRANCH:-main}
|
|
|
|
current=$(git branch --show-current)
|
|
if [ -z "$current" ]; then echo "not on a branch: git switch <branch> first"; exit 1; fi
|
|
if ! git diff --quiet HEAD; then
|
|
echo "uncommitted changes; commit or stash them first:"
|
|
git status --short --untracked-files=no
|
|
exit 1
|
|
fi
|
|
|
|
echo "Fetching $upstream/$branch..."
|
|
git fetch "$upstream" "$branch"
|
|
new=$(git rev-list --count "HEAD..FETCH_HEAD")
|
|
if (( new == 0 )); then
|
|
echo "$current already has everything in $upstream/$branch."
|
|
else
|
|
echo "$new new commits:"
|
|
git log --format=' %h %an: %s' HEAD..FETCH_HEAD
|
|
if ! "$PWD/tools/backup-saves.sh"; then
|
|
echo "saves: backup failed; not updating" >&2
|
|
exit 1
|
|
fi
|
|
if ! git merge --no-edit FETCH_HEAD; then
|
|
git merge --abort
|
|
echo "conflicts: merge undone, $current is as before. Merge by hand: git merge $upstream/$branch"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "Building..."
|
|
./build.sh
|
|
echo "Done. Start the game with ./run.sh play"
|