-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·43 lines (37 loc) · 1.44 KB
/
Copy pathupdate.sh
File metadata and controls
executable file
·43 lines (37 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# backtalk — update to the newest version, showing what changed first.
# Copyright (C) 2026 Jared Rhodenizer
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# Your backtalk.json is yours: nothing in this script can touch or overwrite it.
# Safe to run any time; when nothing is new it just says so.
main() {
cd "$(dirname "$0")" || exit 1
CFG="backtalk.json"
if [ ! -d .git ]; then
# this folder arrived as a zip: wire it to updates, once, keeping the config
[ -f "$CFG" ] && cp "$CFG" "$CFG.mine"
git init -q -b main
git remote add origin https://github.com/jaredrhod/backtalk
git fetch -q origin
git reset -q --hard origin/main
git branch -q --set-upstream-to=origin/main main
[ -f "$CFG.mine" ] && mv "$CFG.mine" "$CFG"
echo "wired this folder to updates."
fi
git fetch -q origin
git log --oneline "..@{u}" 2>/dev/null | sed "s/^/ new: /"
# one-time migration: the config moved out of git tracking. If git here
# still tracks the old copy, lift yours aside, let the pull retire the
# tracked one, then put yours back exactly as it was.
MIGRATE=0
if git ls-files --error-unmatch "$CFG" >/dev/null 2>&1 && [ -f "$CFG" ]; then
cp "$CFG" "$CFG.mine" && git checkout -q -- "$CFG" && MIGRATE=1
fi
git pull --ff-only || echo " (couldn't fast-forward; your local edits win.)"
if [ "$MIGRATE" = 1 ] && [ -f "$CFG.mine" ]; then
mv "$CFG.mine" "$CFG"
fi
echo "update complete."
}
main "$@"