Update 2026-09-04 14:58

This commit is contained in:
2026-09-04 14:58:40 +10:00
parent 3278890491
commit 5afccaffa8
2 changed files with 116 additions and 32 deletions
+66 -20
View File
@@ -1,42 +1,88 @@
# Pushes this folder into the Gitea repo created for it. # Pushes this folder to the Gitea repo.
# Run from PowerShell, inside the visitor-signin folder: #
# Run from PowerShell inside the visitor-signin folder:
# .\push-to-gitea.ps1 # .\push-to-gitea.ps1
# If Windows blocks it: powershell -ExecutionPolicy Bypass -File .\push-to-gitea.ps1 # If Windows blocks it:
# powershell -ExecutionPolicy Bypass -File .\push-to-gitea.ps1
$ErrorActionPreference = 'Stop'
$Remote = 'https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin.git' $Remote = 'https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin.git'
if (-not (Test-Path 'package.json')) { # git reports failure through its exit code, not as a PowerShell error, so every
Write-Error 'Run this from inside the visitor-signin folder.' # call has to be checked. Without this the script reports success after a
# rejected push, which is exactly what it used to do.
function Invoke-Git {
param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Arguments)
& git @Arguments
return $LASTEXITCODE
}
function Fail($message) {
Write-Host ''
Write-Host $message -ForegroundColor Red
exit 1 exit 1
} }
if (-not (Test-Path 'package.json')) { Fail 'Run this from inside the visitor-signin folder.' }
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Error 'Git is not installed or not on PATH. Install it from https://git-scm.com/download/win' Fail 'Git is not installed or not on PATH. Get it from https://git-scm.com/download/win'
exit 1
} }
# Keep line endings sane between Windows and the Ubuntu docker host. # Keeps line endings sane between Windows and the Ubuntu docker host.
git config --global core.autocrlf input | Out-Null git config --global core.autocrlf input | Out-Null
if (-not (Test-Path '.git')) { if (-not (Test-Path '.git')) {
git init -b main Write-Host 'Setting up a new local repository...'
} else { if ((Invoke-Git init -b main) -ne 0) { Fail 'git init failed.' }
Write-Host 'This folder is already a git repo, adding a commit to it.'
} }
git add . if ((git remote) -match '^origin$') {
$message = 'Visitor sign in kiosk: multi-site, badge printing, WWCC expiry warnings, admin accounts with 2FA'
git commit -m $message
if (git remote | Select-String -Quiet '^origin$') {
git remote set-url origin $Remote git remote set-url origin $Remote
} else { } else {
git remote add origin $Remote git remote add origin $Remote
} }
git push -u origin main # ---------------------------------------------------------------- commit
git add -A
$pending = git status --porcelain
if ($pending) {
$message = Read-Host 'Describe this change (press enter for a dated default)'
if (-not $message) { $message = "Update $(Get-Date -Format 'yyyy-MM-dd HH:mm')" }
if ((Invoke-Git commit -m $message) -ne 0) { Fail 'git commit failed.' }
Write-Host 'Committed.' -ForegroundColor Green
} else {
Write-Host 'No file changes to commit. Checking for anything unpushed...' -ForegroundColor Yellow
}
# ------------------------------------------------------- catch up, then push
Write-Host 'Checking what is on the server...'
if ((Invoke-Git fetch origin) -ne 0) {
Fail 'Could not reach Gitea. Check the network and your sign in details.'
}
if (git ls-remote --heads origin main) {
$behind = (git rev-list --count HEAD..origin/main 2>$null)
if ($behind -and [int]$behind -gt 0) {
Write-Host "The server has $behind commit(s) this folder does not. Replaying your work on top..."
if ((Invoke-Git pull --rebase origin main) -ne 0) {
Write-Host ''
Write-Host 'The two histories could not be joined automatically.' -ForegroundColor Red
Write-Host ''
Write-Host 'See what is on the server that you do not have:' -ForegroundColor Yellow
Write-Host ' git log --oneline HEAD..origin/main'
Write-Host ''
Write-Host 'If that is nothing you need, and this folder is the good copy:' -ForegroundColor Yellow
Write-Host ' git push --force-with-lease origin main'
exit 1
}
}
}
if ((Invoke-Git push -u origin main) -ne 0) {
Fail 'The push was rejected. Read the message above. Nothing was sent.'
}
Write-Host '' Write-Host ''
Write-Host 'Pushed. Repo: https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin' -ForegroundColor Green Write-Host 'Pushed successfully.' -ForegroundColor Green
Write-Host 'Sign in with your Gitea username and password, or a token as the password.' Write-Host 'https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin'
+50 -12
View File
@@ -1,20 +1,58 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Pushes this folder into the (empty) Gitea repo created for it. # Pushes this folder to the Gitea repo. Run from inside the visitor-signin folder.
# Run once from inside the extracted visitor-signin folder: ./push-to-gitea.sh set -uo pipefail
set -euo pipefail
REMOTE="https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin.git" REMOTE="https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin.git"
if [ ! -f package.json ]; then fail() { printf '\n%s\n' "$1" >&2; exit 1; }
echo "Run this from inside the visitor-signin folder." >&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 fi
git init -b main git add -A
git add . if [ -n "$(git status --porcelain)" ]; then
git commit -m "Visitor sign in kiosk: multi-site, badge printing, WWCC expiry warnings, admin accounts with 2FA" read -r -p "Describe this change (enter for a dated default): " MSG
git remote add origin "$REMOTE" 2>/dev/null || git remote set-url origin "$REMOTE" [ -n "$MSG" ] || MSG="Update $(date '+%Y-%m-%d %H:%M')"
git push -u origin main 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
echo "Pushed. Repo: https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin" echo "Pushed successfully."
echo "https://gitea.hideawaygaming.com.au/jessikitty/visitor-signin"