Objective
Fix push_signed_commits.cjs to use topological ordering when listing commits, and add graceful handling for merge commits.
Context
Reported in issue #26156. Two related ordering/topology bugs affect multi-commit pushes.
Bugs to Fix
1. git rev-list uses commit-date order by default (line 40)
// WRONG: may return commits in wrong order if dates are out of sync (e.g. after rebase --committer-date-is-author-date)
const { stdout: revListOut } = await exec.getExecOutput("git", ["rev-list", "--reverse", `${baseRef}..HEAD`], { cwd });
Fix: Add --topo-order to ensure commits are always listed in graph/topology order:
await exec.getExecOutput("git", ["rev-list", "--topo-order", "--reverse", `${baseRef}..HEAD`], { cwd });
2. Merge commits are not handled
git rev-list will list commits from both parents of a merge commit. When the code tries to call createCommitOnBranch for a merge commit, it will produce incorrect results since:
- The diff
${sha}^ against a merge commit is ambiguous (uses first parent)
createCommitOnBranch does not support multiple parents
Fix: Detect merge commits (those with more than one parent) and skip the GraphQL path for the entire series, falling back to git push instead. Add a pre-flight check before the loop:
// Check if any commit in the series is a merge commit
for (const sha of shas) {
const { stdout } = await exec.getExecOutput("git", ["cat-file", "-p", sha], { cwd });
const parentCount = (stdout.match(/^parent /gm) || []).length;
if (parentCount > 1) {
core.warning(`pushSignedCommits: merge commit ${sha} detected, falling back to git push`);
// fall through to git push fallback
throw new Error("merge commit detected");
}
}
Files to Modify
actions/setup/js/push_signed_commits.cjs
Acceptance Criteria
Generated by Plan Command for issue #26156 · ● 383.5K · ◷
Objective
Fix
push_signed_commits.cjsto use topological ordering when listing commits, and add graceful handling for merge commits.Context
Reported in issue #26156. Two related ordering/topology bugs affect multi-commit pushes.
Bugs to Fix
1. git rev-list uses commit-date order by default (line 40)
Fix: Add
--topo-orderto ensure commits are always listed in graph/topology order:2. Merge commits are not handled
git rev-listwill list commits from both parents of a merge commit. When the code tries to callcreateCommitOnBranchfor a merge commit, it will produce incorrect results since:${sha}^against a merge commit is ambiguous (uses first parent)createCommitOnBranchdoes not support multiple parentsFix: Detect merge commits (those with more than one parent) and skip the GraphQL path for the entire series, falling back to
git pushinstead. Add a pre-flight check before the loop:Files to Modify
actions/setup/js/push_signed_commits.cjsAcceptance Criteria
--topo-orderis added togit rev-listcallgit pushwith a clear warning messageRelated to bug: multiple critical issues in push_signed_commits #26156