Skip to content

[plan] Fix commit ordering (--topo-order) and add merge commit handling in push_signed_commits.cjs #26255

Description

@github-actions

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 ·

  • expires on Apr 16, 2026, 4:34 PM UTC

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions