Objective
Fix push_signed_commits.cjs to gracefully handle submodule entries instead of silently corrupting them.
Context
Reported in issue #26156. Submodule updates appear in git diff --name-status as regular entries, but they point to a commit object (not a blob) in the tree, and are directories in the working area. The current code will fail or produce incorrect output when encountering them.
Additionally, the GitHub GraphQL createCommitOnBranch mutation does not support submodules.
Bug Details
- Submodules show up in
git diff-tree output like regular files but are of type commit in the tree
- Reading content via
git show <sha>:<path> on a submodule path will succeed but return a commit SHA, not file content
- Trying to add this as a file addition will silently create a wrong file or fail
Fix
In the diff-parsing loop, detect submodule entries by checking the mode in git diff-tree output. When using git diff-tree -r --name-status, also request the mode with --format or use the full diff output format.
Switch to git diff-tree -r -z --raw <sha> to get mode information alongside status, then:
- Detect submodule entries (mode
160000)
- When a submodule change is detected, log a warning and fall back to
git push for the entire series (since createCommitOnBranch doesn't support submodules)
// mode 160000 = gitlink (submodule)
if (srcMode === "160000" || dstMode === "160000") {
core.warning(`pushSignedCommits: submodule change detected in ${filePath}, falling back to git push`);
throw new Error("submodule change 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 gracefully handle submodule entries instead of silently corrupting them.Context
Reported in issue #26156. Submodule updates appear in
git diff --name-statusas regular entries, but they point to a commit object (not a blob) in the tree, and are directories in the working area. The current code will fail or produce incorrect output when encountering them.Additionally, the GitHub GraphQL
createCommitOnBranchmutation does not support submodules.Bug Details
git diff-treeoutput like regular files but are of typecommitin the treegit show <sha>:<path>on a submodule path will succeed but return a commit SHA, not file contentFix
In the diff-parsing loop, detect submodule entries by checking the mode in
git diff-treeoutput. When usinggit diff-tree -r --name-status, also request the mode with--formator use the full diff output format.Switch to
git diff-tree -r -z --raw <sha>to get mode information alongside status, then:160000)git pushfor the entire series (sincecreateCommitOnBranchdoesn't support submodules)Files to Modify
actions/setup/js/push_signed_commits.cjsAcceptance Criteria
160000in diff outputgit pushinstead of silently producing wrong commitsRelated to bug: multiple critical issues in push_signed_commits #26156