Public Access
Update 2026-09-04 14:58
This commit is contained in:
+50
-12
@@ -1,20 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pushes this folder into the (empty) Gitea repo created for it.
|
||||
# Run once from inside the extracted visitor-signin folder: ./push-to-gitea.sh
|
||||
set -euo pipefail
|
||||
# Pushes this folder to the Gitea repo. Run from inside the visitor-signin folder.
|
||||
set -uo pipefail
|
||||
|
||||
REMOTE="https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin.git"
|
||||
|
||||
if [ ! -f package.json ]; then
|
||||
echo "Run this from inside the visitor-signin folder." >&2
|
||||
exit 1
|
||||
fail() { printf '\n%s\n' "$1" >&2; exit 1; }
|
||||
|
||||
[ -f package.json ] || fail "Run this from inside the visitor-signin folder."
|
||||
command -v git >/dev/null || fail "Git is not installed."
|
||||
|
||||
git config --global core.autocrlf input >/dev/null 2>&1 || true
|
||||
|
||||
[ -d .git ] || git init -b main || fail "git init failed."
|
||||
|
||||
if git remote | grep -qx origin; then
|
||||
git remote set-url origin "$REMOTE"
|
||||
else
|
||||
git remote add origin "$REMOTE"
|
||||
fi
|
||||
|
||||
git init -b main
|
||||
git add .
|
||||
git commit -m "Visitor sign in kiosk: multi-site, badge printing, WWCC expiry warnings, admin accounts with 2FA"
|
||||
git remote add origin "$REMOTE" 2>/dev/null || git remote set-url origin "$REMOTE"
|
||||
git push -u origin main
|
||||
git add -A
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
read -r -p "Describe this change (enter for a dated default): " MSG
|
||||
[ -n "$MSG" ] || MSG="Update $(date '+%Y-%m-%d %H:%M')"
|
||||
git commit -m "$MSG" || fail "git commit failed."
|
||||
echo "Committed."
|
||||
else
|
||||
echo "No file changes to commit. Checking for anything unpushed..."
|
||||
fi
|
||||
|
||||
git fetch origin || fail "Could not reach Gitea."
|
||||
|
||||
if git ls-remote --heads origin main | grep -q main; then
|
||||
BEHIND=$(git rev-list --count HEAD..origin/main 2>/dev/null || echo 0)
|
||||
if [ "$BEHIND" -gt 0 ]; then
|
||||
echo "The server has $BEHIND commit(s) this folder does not. Replaying your work on top..."
|
||||
if ! git pull --rebase origin main; then
|
||||
cat >&2 <<'MSG'
|
||||
|
||||
The two histories could not be joined automatically.
|
||||
|
||||
See what is on the server that you do not have:
|
||||
git log --oneline HEAD..origin/main
|
||||
|
||||
If that is nothing you need, and this folder is the good copy:
|
||||
git push --force-with-lease origin main
|
||||
MSG
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
git push -u origin main || fail "The push was rejected. Read the message above. Nothing was sent."
|
||||
|
||||
echo
|
||||
echo "Pushed. Repo: https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin"
|
||||
echo "Pushed successfully."
|
||||
echo "https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin"
|
||||
|
||||
Reference in New Issue
Block a user