Skip to content

bug: multiple critical issues in push_signed_commits #26156

Closed
5 of 5 issues completed
Closed

Description

@pgaskin

There are multiple bugs in actions/setup/js/push_signed_commits.cjs which will silently push incorrect content.

There's probably some more, but there are the ones I noticed while doing some research of existing code before I ended up making my own action for pushing signed commits.

copies in diffs are treated like renames

} else if (status.startsWith("R") || status.startsWith("C")) {
// Rename or Copy: parts[1] = old path, parts[2] = new path
deletions.push({ path: parts[1] });
const content = fs.readFileSync(path.join(cwd, parts[2]));
additions.push({ path: parts[2], contents: content.toString("base64") });
} else {

The old file is deleted, even if it's a copy. This needs to be surrounded by another check for if it's specifically a rename versus a copy.

git diff may double-quote filenames

// File changes for this commit (supports Add/Modify/Delete/Rename/Copy)
const { stdout: nameStatusOut } = await exec.getExecOutput("git", ["diff", "--name-status", `${sha}^`, sha], { cwd });
/** @type {Array<{path: string, contents: string}>} */
const additions = [];
/** @type {Array<{path: string}>} */
const deletions = [];
for (const line of nameStatusOut.trim().split("\n").filter(Boolean)) {
const parts = line.split("\t");
const status = parts[0];

That is not handled here. The git diff command may c-quote filenames with special characters. The code should check if the names start with double-quotes and unescape them if so.

Also, git diff-tree is better than git diff since it won't be affected by the git config.

the working tree content is always used

const content = fs.readFileSync(path.join(cwd, parts[2]));
additions.push({ path: parts[2], contents: content.toString("base64") });
} else {
// Added or Modified
const content = fs.readFileSync(path.join(cwd, parts[1]));

This is incorrect since the content in the last commit may not be the same as the working area, and the content in old commits will be incorrect.

The git show REV:PATH command or git ls-tree combined with git cat-files should be used instead.

merge commits are not handled

  • git rev-list will list commits from both parents
  • createCommitOnBranch doesn't support creating commits with multiple parents.

submodule updates will fail to be pushed

They appear as a single item in git diff, point to a commit object in the tree (rather than a blob), and will be a directory in the working area.

Furthermore, the GitHub GraphQL API createCommitOnBranch mutation doesn't support submodules (this is an easy fix though, see below).

git rev-list lists by commit date by default

const { stdout: revListOut } = await exec.getExecOutput("git", ["rev-list", "--reverse", `${baseRef}..HEAD`], { cwd });
const shas = revListOut.trim().split("\n").filter(Boolean);

Commits with out-of-order commit dates (e.g., ones rebased with --committer-date-is-author-date) will not be pushed in the correct order. The --topo-order option should be used to ensure they are listed in graph order.

non-100644 file modes are silently discarded

Things like shell scripts typically have 100755 permissions, but these will be silently dropped when the file is modified and pushed since the createCommitOnBranch mutation doesn't support them.

Symlinks will be silently converted to a regular file with the contents of the target, and will fail if it's a directory.

See https://github.com/orgs/community/discussions/191953.

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. locked and limited conversation to collaborators on Apr 14, 2026
  2. unlocked this conversation on Apr 14, 2026
  3. pelikhan commented on Apr 14, 2026

    @pelikhan
    Collaborator

    /plan

  4. github-actions commented on Apr 14, 2026

    @github-actions
    Contributor

    ✅ Plan Command completed successfully!

  5. added a commit that references this issue on Apr 14, 2026
    98b68bc
  6. dsyme commented on Apr 15, 2026

    @dsyme
    Collaborator

    @pgaskin Looks like this is all done now. A new release has been pushed and is available as latest. If you can give it a spin and report back any further problems you see that would be great.

  7. pgaskin commented on Apr 15, 2026

    @pgaskin
    Author

    Oh, I should have been clear that I never tested it as an agentic workflow. I did look at the code locally (after finding it while searching GitHub for createCommitOnBranch) while evaluating ways to push signed commits before I ended up just making my own since I wanted an ordinary action.

    I'll review the PRs in a little bit.

    Regarding the limitations for non-regular files, would it be possible to get that added to the API since it should be a relatively trivial change? I did post a discussion on the community repo, but I fear it's a black hole given the lack of engagement on all posts from the last few months. https://github.com/orgs/community/discussions/191953

  8. locked and limited conversation to collaborators on Apr 15, 2026
  9. unlocked this conversation on Apr 15, 2026
  10. pgaskin commented on Apr 15, 2026

    @pgaskin
    Author

    Reviewing the changes statically:

    #26259 is good , but missing gitlink (submodule) detection (mode 160000).

    #26277 looks good, but I didn't verify the unquote logic.

    #26287 looks good, though I'd personally use cat-file instead of show for simplicity and robustness since you already have the blob hashes from the changes in #26259.

    #26298 looks good, and adds the gitlink detection missed in #26259.

    #26306 looks good.

  11. pelikhan commented on Apr 15, 2026

    @pelikhan
    Collaborator

    Thanks for the review and the suggestions!

  12. locked and limited conversation to collaborators on Apr 15, 2026
  13. unlocked this conversation on Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions