Skip to content

Commit 6372feb

Browse files
authored
Merge pull request #377 from wallentx/codex/release-0149-authority
fix(checkpoint): auto-merge fallback PRs
2 parents 9eefe44 + 922a761 commit 6372feb

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

scripts/termux-create-checkpoint-pr.sh

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ resolve_source_version_conflicts() {
9999

100100
enable_checkpoint_automerge() {
101101
local pr_url="$1"
102-
local manual_resolution_required="${2:-false}"
103-
104-
if [[ "${manual_resolution_required}" == "true" ]]; then
105-
echo "Skipping checkpoint auto-merge for ${pr_url}; manual conflict resolution is required."
106-
return 0
107-
fi
108102

109103
local pr_info
110104
pr_info="$(
@@ -145,20 +139,15 @@ existing_pr="$(
145139
--repo "${GITHUB_REPOSITORY}" \
146140
--head "${checkpoint_branch}" \
147141
--state all \
148-
--json body,number,state,mergedAt,url \
142+
--json number,state,mergedAt,url \
149143
--jq '[.[] | select(.state == "OPEN" or .mergedAt != null)] | .[0] // empty'
150144
)"
151145
if [[ -n "${existing_pr}" ]]; then
152146
existing_url="$(jq -r '.url' <<< "${existing_pr}")"
153147
existing_state="$(jq -r '.state' <<< "${existing_pr}")"
154148
echo "Checkpoint PR already exists for ${checkpoint_branch}: ${existing_url} (${existing_state})."
155149
if [[ "${existing_state}" == "OPEN" ]]; then
156-
existing_body="$(jq -r '.body // ""' <<< "${existing_pr}")"
157-
if [[ "${existing_body}" == *"## Merge conflicts"* ]]; then
158-
enable_checkpoint_automerge "${existing_url}" true
159-
else
160-
enable_checkpoint_automerge "${existing_url}" false
161-
fi
150+
enable_checkpoint_automerge "${existing_url}"
162151
fi
163152
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
164153
echo "pr_url=${existing_url}" >> "${GITHUB_OUTPUT}"
@@ -294,7 +283,7 @@ body_path="${RUNNER_TEMP}/termux-checkpoint-pr.md"
294283
echo
295284
echo "GitHub Actions kept the destination branch versions of the conflicted paths so the PR remains a focused, mergeable checkpoint instead of exposing the entire source branch as a replacement tree."
296285
echo
297-
echo "Review these paths and manually carry over any source-side changes that the destination still needs. Auto-merge is disabled until that review is complete."
286+
echo "Destination versions of these paths are retained in the checkpoint. Any source-side changes that are still needed can be carried forward separately."
298287
echo
299288
echo "Conflicted paths from the failed merge attempt:"
300289
if [[ -n "${conflict_summary}" ]]; then
@@ -319,7 +308,7 @@ gh pr edit "${pr_url}" --repo "${GITHUB_REPOSITORY}" --add-reviewer "${REVIEWER}
319308
gh label create checkpoint --repo "${GITHUB_REPOSITORY}" --color c5def5 --description "Checkpoint merge" --force
320309
gh label create termux-release --repo "${GITHUB_REPOSITORY}" --color 0e8a16 --description "Termux release automation" --force
321310
gh pr edit "${pr_url}" --repo "${GITHUB_REPOSITORY}" --add-label "checkpoint" --add-label "termux-release"
322-
enable_checkpoint_automerge "${pr_url}" "${merge_conflicted}"
311+
enable_checkpoint_automerge "${pr_url}"
323312

324313
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
325314
echo "pr_url=${pr_url}" >> "${GITHUB_OUTPUT}"

scripts/test-termux-create-checkpoint-pr.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ origin="${tmp_dir}/origin.git"
5252
work="${tmp_dir}/work"
5353
runner_temp="${tmp_dir}/runner"
5454
github_output="${tmp_dir}/github-output"
55+
merge_log="${tmp_dir}/merge-log"
5556

5657
mkdir -p "${bin_dir}" "${runner_temp}"
5758

@@ -66,6 +67,7 @@ case "${1:-} ${2:-}" in
6667
printf '{"headRefOid":"checkpoint-head-sha","state":"OPEN","url":"%s"}\n' "${3:-}"
6768
;;
6869
"pr merge")
70+
printf '%s\n' "$*" >> "${TERMUX_TEST_MERGE_LOG:?}"
6971
[[ "${4:-}" == "--repo" ]] || {
7072
echo "expected --repo as fourth pr merge arg: $*" >&2
7173
exit 1
@@ -147,6 +149,7 @@ SOURCE_BRANCH="release/1.0.0" \
147149
REVIEWER="wallentx" \
148150
RUNNER_TEMP="${runner_temp}" \
149151
GITHUB_OUTPUT="${github_output}" \
152+
TERMUX_TEST_MERGE_LOG="${merge_log}" \
150153
GH_TOKEN="test-token" \
151154
bash "${script}" > "${tmp_dir}/stdout" 2> "${tmp_dir}/stderr" || {
152155
cat "${tmp_dir}/stdout" >&2
@@ -176,4 +179,9 @@ if [[ "$(cat "${github_output}")" != "pr_url=https://github.com/wallentx/codex-t
176179
fail "checkpoint PR URL was not written to GITHUB_OUTPUT"
177180
fi
178181

179-
echo "ok - checkpoint carries tested code and keeps conflicted paths on the destination baseline"
182+
if [[ "$(wc -l < "${merge_log}")" -ne 1 ]]; then
183+
cat "${merge_log}" >&2
184+
fail "checkpoint PR auto-merge was not enabled after fallback conflict resolution"
185+
fi
186+
187+
echo "ok - checkpoint carries tested code, keeps conflicted paths on the destination baseline, and enables auto-merge"

0 commit comments

Comments
 (0)