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 <noreply@anthropic.com>
This commit is contained in:
+18
-4
@@ -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
|
||||
}'
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user