From e65e26202a148021d26632cd807b5b5b1ff39f31 Mon Sep 17 00:00:00 2001 From: Joshua Oosthuizen Date: Fri, 20 Nov 2026 15:55:07 +0200 Subject: [PATCH] crosscode script: Accounts' pre-deploy dumps don't stop a deploy The dump made before each Accounts deploy (apps/accounts/backend/backups/) counted as a file added by hand on Accounts below 1.3.0, which has no .gitignore for it, so the next deploy stopped. Untracked files in that folder no longer count (CROSSCODE_OWN_DIRS in lib/common.sh). Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 7 +++++++ docs/VERSIONS.md | 5 ++++- scripts/lib/common.sh | 22 ++++++++++++++++++---- scripts/tests/deploy.bats | 14 ++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46fad67..1afb2a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …). +## crosscode script - 2026-11-20 (no tag: servers run `main`) + +- **Fix:** the database dump made before each Accounts deploy (`apps/accounts/backend/backups/`) + counted as a file added by hand on Accounts below 1.3.0 (no `.gitignore` for it yet), so the + next deploy stopped with "changed or added by hand". Untracked files in that folder no longer + count (`CROSSCODE_OWN_DIRS` in `lib/common.sh`). + ## events@3.6.1 - 2026-11-20 - **Events 3.6.1 (fix):** uploading a logo or favicon failed with "uploaded, but the site can't diff --git a/docs/VERSIONS.md b/docs/VERSIONS.md index 629b039..e2b4c49 100644 --- a/docs/VERSIONS.md +++ b/docs/VERSIONS.md @@ -16,7 +16,7 @@ separately below; the two often differ. | Contracts | `crosscode-platform` (`packages/contracts`) | **1.14.0** | `contracts@1.14.0` | 2026-11-20 | | Cross Code Hub | `events-hub` | **2.10.0** | `v2.10.0` | 2026-11-20 | | crosscode.co.za | `crosscode-site` | **1.6.0** | `v1.6.0` | 2026-11-19 | -| `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-20 (last change: nginx `location ^~ /api/`) | +| `crosscode` script | `crosscode-platform` (`scripts/`) | `main` | none | 2026-11-20 (last change: Accounts' pre-deploy dumps don't stop a deploy) | The `crosscode` script has no version: every server's copy (`/opt/crosscode/tools`) pulls `main` on each run, so merging to `main` and pushing releases it. Its changes are listed in @@ -37,6 +37,9 @@ need their own tags until something outside this repo depends on them. ## What each latest release was for +- **`crosscode` script (2026-11-20, later):** the database dump made before each Accounts deploy + (`backend/backups/`) no longer stops the next deploy as "added by hand" on Accounts below 1.3.0. + Released by pushing `main`; the next Hub job pulls it. - **Hub 2.10.0:** every Hub email (job reports, alerts, emails to church admins, notices) laid out as Events' and Accounts' are. The FastPanel email gives `location ^~ /api/` to paste, and Proxy done refuses a site whose `/api` files reach the frontend. No migration. diff --git a/scripts/lib/common.sh b/scripts/lib/common.sh index 948e30e..dab37af 100644 --- a/scripts/lib/common.sh +++ b/scripts/lib/common.sh @@ -355,10 +355,24 @@ node_major() { node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo # Files changed or added by hand in a checkout (ignored files such as .env, uploads, backups and # the install's ecosystem.config.js never count). The PM2 configs this script makes for each # install never count either, also in checkouts of releases that don't ignore them yet (Accounts -# 1.0–1.1 has no .gitignore for its ecosystem.config.cjs). +# 1.0–1.1 has no .gitignore for its ecosystem.config.cjs). Nor do the files in the folders this +# script writes into (Accounts below 1.3.0 doesn't ignore the database dumps made before each +# deploy, so the dump would stop the very deploy that brings the .gitignore). CROSSCODE_OWN_FILES=(apps/events/ecosystem.config.js apps/accounts/ecosystem.config.cjs) +CROSSCODE_OWN_DIRS=(apps/accounts/backend/backups/) local_changes() { - git_in "$1" status --porcelain --untracked-files=all | awk -v own="${CROSSCODE_OWN_FILES[*]}" ' - BEGIN { n = split(own, f, " "); for (i = 1; i <= n; i++) skip[f[i]] = 1 } - !(substr($0, 1, 2) == "??" && substr($0, 4) in skip)' + git_in "$1" status --porcelain --untracked-files=all | + awk -v own="${CROSSCODE_OWN_FILES[*]}" -v dirs="${CROSSCODE_OWN_DIRS[*]}" ' + BEGIN { + n = split(own, f, " "); for (i = 1; i <= n; i++) skip[f[i]] = 1 + m = split(dirs, d, " ") + } + { + if (substr($0, 1, 2) == "??") { + path = substr($0, 4) + if (path in skip) next + for (i = 1; i <= m; i++) if (index(path, d[i]) == 1) next + } + print + }' } diff --git a/scripts/tests/deploy.bats b/scripts/tests/deploy.bats index aae368c..9e7d4ed 100644 --- a/scripts/tests/deploy.bats +++ b/scripts/tests/deploy.bats @@ -159,6 +159,20 @@ cc() { bash "$CROSSCODE_HOME/crosscode" "$@"; } [[ "$output" == *"apps/accounts/notes.txt"* ]] } +@test "the database dumps crosscode makes don't count as changes by hand" { + # Accounts below 1.3.0 has no .gitignore for backend/backups/. + mkdir -p "$CROSSCODE_SITES/hope/events/apps/accounts/backend/backups" + echo "dump" > "$CROSSCODE_SITES/hope/events/apps/accounts/backend/backups/accounts-20261119-221205.sql.gz" + run cc deploy hope events --version events@2.2.1 --check + [ "$status" -eq 0 ] + # A file merely named like the folder still counts. + echo "notes" > "$CROSSCODE_SITES/hope/events/apps/accounts/backend/backups.txt" + run cc deploy hope events --version events@2.2.1 --check + [ "$status" -eq 1 ] + [[ "$output" == *"apps/accounts/backend/backups.txt"* ]] + [[ "$output" != *"accounts-20261119-221205.sql.gz"* ]] +} + @test "--allow-local-changes deploys with a file added by hand" { echo "notes" > "$CROSSCODE_SITES/hope/events/apps/events/notes.txt" run cc deploy hope events --version events@2.2.1