Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions .github/scripts/test-v6-topup-autoresolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ case_all_known() {
echo v5bot > discord/bot.go
printf '# Changelog\n\n## Unreleased\n\n## 1.1.0 (v5)\n\n- v5 entry\n\n## 1.0.0\n\n- base\n' > CHANGELOG.md
echo v5 > src/scripts/b.sh
echo 'package config // v5 monolith edit' > src/pkg/config/config.go
echo A5 > src/pkg/dashboard/static-src/a.html
printf 'A5\nB\n' > src/pkg/dashboard/static/index.html
git add -A && git commit -qm v5 && finish_pin v5
Expand All @@ -79,7 +78,7 @@ case_all_known() {
bash "$RESOLVER"
git commit -q --no-edit
[ ! -e discord/bot.go ] || { echo "discord not deleted"; return 1; }
grep -q 'v6 slim' src/pkg/config/config.go || { echo "config.go not v6"; return 1; }
grep -q 'v6 slim' src/pkg/config/config.go || { echo "config.go lost v6's one-sided edit"; return 1; }
grep -q '6.1.0 (v6)' CHANGELOG.md && grep -q '1.1.0 (v5)' CHANGELOG.md || { echo "changelog lost a side"; return 1; }
! grep -qE '^(<<<<<<<|=======|>>>>>>>)' CHANGELOG.md .github/scripts/integration-governance.cjs || { echo "markers left"; return 1; }
[ "$(cat src/pkg/dashboard/static/index.html)" = "$(printf 'A5\nB6')" ] || { echo "index not regenerated"; return 1; }
Expand All @@ -106,7 +105,33 @@ case_pin_file_real_edit() {
bash "$RESOLVER"
}

# v5 adds a real field to the monolith config.go while v6 has split it. The
# resolver must refuse (keeping v6's side would drop the field silently) and
# must leave config.go unmerged for the human, even when every other conflict
# is a known pattern.
case_config_real_field() {
new_repo "$WORK/config" && cd "$WORK/config"
printf 'package config // base\n\ntype Config struct {\n\tMeetings MeetingsConfig `yaml:"meetings"`\n}\n' > src/pkg/config/config.go
printf '# Changelog\n\n## Unreleased\n\n## 1.1.0 (v5)\n\n- v5 entry\n\n## 1.0.0\n\n- base\n' > CHANGELOG.md
git commit -qam "v5 adds a config field"
git checkout -q v6
echo 'package config // v6 slim (structs moved to types.go)' > src/pkg/config/config.go
printf '# Changelog\n\n## Unreleased\n\n## 6.1.0 (v6)\n\n- v6 entry\n\n## 1.0.0\n\n- base\n' > CHANGELOG.md
git commit -qam "v6 splits config.go"
git merge --no-ff -q v5 -m merge >/dev/null 2>&1 && { echo "expected conflicts"; return 1; }
# Exit 0 here means the resolver accepted the conflict, which is the bug;
# `expect ... fail` turns that into a test failure.
local out rc=0
out="$(bash "$RESOLVER" 2>&1)" || rc=$?
printf '%s\n' "$out"
[ "$rc" -ne 0 ] || return 0
git status --porcelain | grep -q '^UU src/pkg/config/config.go$' || { echo "config.go was resolved"; return 0; }
printf '%s\n' "$out" | grep -q 'port v5.s change by hand' || { echo "no hand-port hint"; return 0; }
return 1
}

expect all-known-patterns-resolve ok case_all_known
expect config-go-real-field-refused fail case_config_real_field
expect unknown-conflict-refused fail case_unknown_conflict
expect pin-file-real-edit-refused fail case_pin_file_real_edit

Expand Down
29 changes: 21 additions & 8 deletions .github/scripts/v6-topup-autoresolve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
# Known patterns:
# - DU discord/** and DU/UD .github/workflows/discord-syntax.yml: v6 removed
# discord/ (#9277) while v5 still develops it. Keep v6's deletion.
# - UU src/pkg/config/config.go: v6 split the monolith into topical files
# (#9386, #9956). Keep v6's side.
# - UU CHANGELOG.md: both lines prepend their own release sections under
# "## Unreleased" on every release, so the top of the file conflicts on
# almost every top-up. Keep both sides' lines (v6's block first, then
Expand All @@ -25,6 +23,17 @@
# it as the byte-exact concatenation of static-src/manifest.txt (what
# webstatic.ConcatIndex and TestIndexHTMLIsGenerated do), provided no
# static-src file is itself conflicted.
#
# Deliberately NOT a known pattern:
# - UU src/pkg/config/config.go. v6 split the monolith into topical files
# (#9386, #9956), and an earlier version of this script kept v6's side of
# any config.go conflict. A conflict there means v5 changed config.go since
# the last top-up, and keeping v6's side drops that change without a trace:
# #18222's keystore sealing survived only because it was hand-ported into
# v6's load.go/save.go. A config.go conflict always goes to a human, who
# ports v5's change into the matching split file. Whether v6 already has an
# equivalent change cannot be decided mechanically (the code moved), so
# there is no "safe subset" to auto-resolve.
set -euo pipefail

PIN_FILE=.github/scripts/integration-governance.cjs
Expand All @@ -35,10 +44,14 @@ PIN_RE="^const TRUSTED_SCRIPTS_TREE = '[0-9a-f]{40}';\$"
unmerged="$(git status --porcelain | grep -E '^(DD|AU|UD|UA|DU|AA|UU) ' || true)"
[ -n "$unmerged" ] || { echo "v6-topup-autoresolve: no conflicts to resolve"; exit 1; }

known='^DU discord/|^(DU|UD) \.github/workflows/discord-syntax\.yml$|^UU src/pkg/config/config\.go$|^UU CHANGELOG\.md$|^UU \.github/scripts/integration-governance\.cjs$|^UU src/pkg/dashboard/static/index\.html$'
known='^DU discord/|^(DU|UD) \.github/workflows/discord-syntax\.yml$|^UU CHANGELOG\.md$|^UU \.github/scripts/integration-governance\.cjs$|^UU src/pkg/dashboard/static/index\.html$'
if unknown="$(printf '%s\n' "$unmerged" | grep -vE "$known")"; then
echo "v6-topup-autoresolve: conflicts outside the known patterns:"
printf '%s\n' "$unknown"
if printf '%s\n' "$unknown" | grep -q ' src/pkg/config/config\.go$'; then
echo "v6-topup-autoresolve: v5 changed src/pkg/config/config.go, which v6 split into topical files;"
echo " port v5's change by hand: git diff \$(git merge-base HEAD MERGE_HEAD) MERGE_HEAD -- src/pkg/config/config.go"
fi
exit 1
fi

Expand Down Expand Up @@ -70,10 +83,6 @@ while IFS= read -r entry; do
"DU "*|"UD "*)
git rm -q -- "$file"
;;
"UU src/pkg/config/config.go")
git checkout --ours -- "$file"
git add -- "$file"
;;
"UU CHANGELOG.md")
tmp="$(mktemp -d)"
git show ":1:$file" > "$tmp/base"
Expand Down Expand Up @@ -107,7 +116,11 @@ if [ "$regen_index" = 1 ]; then
while IFS= read -r line || [ -n "$line" ]; do
line="$(printf '%s' "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
case "$line" in ''|'#'*) continue ;; esac
case "$line" in /*|..*) echo "v6-topup-autoresolve: unsafe manifest path $line"; exit 1 ;; esac
# The same clean-relative-path rule as webstatic.ParseIndexManifest.
case "$line" in
/*|..*|./*|*/|*//*|*/./*|*/../*|*/.|*/..)
echo "v6-topup-autoresolve: unsafe manifest path $line"; exit 1 ;;
esac
cat "$STATIC_SRC/$line" >> "$INDEX_FILE"
done < "$STATIC_SRC/manifest.txt"
git add -- "$INDEX_FILE"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/v6-topup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ jobs:
# them with their history):
# - discord/ + discord-syntax.yml modify/delete: keep v6's
# deletion (#9277, #11551).
# - src/pkg/config/config.go: keep v6's split (#9386, #9956).
# - CHANGELOG.md: both lines prepend release sections, keep both.
# - integration-governance.cjs TRUSTED_SCRIPTS_TREE literal only:
# re-pin to the merged src/scripts tree.
# - static/index.html: regenerate from static-src/manifest.txt.
# When the ONLY conflicts match those patterns, resolve them and
# finish the merge. Anything else (other content conflicts, other
# deletions, other hunks in the pin file) still fails loudly below.
# src/pkg/config/config.go is deliberately NOT auto-resolved: v6
# split it, so keeping v6's side would silently drop v5's change.
# The resolver runs from the copy taken off the triggering ref
# before the checkout, not from v6's tree.
elif bash "$RUNNER_TEMP/v6-topup-autoresolve.sh"; then
Expand Down
Loading