Repository navigation
feat(push_files): use createCommitOnBranch GraphQL mutation for signed commits - #3895
Open
Asubtlecoderrr wants to merge 2 commits into
Open
Asubtlecoderrr wants to merge 2 commits into
Asubtlecoderrr wants to merge 2 commits into
Conversation
…d commits Replace the five-step REST Git Data API flow (GetCommit + CreateTree + CreateCommit + UpdateRef) in PushFiles with a single GraphQL createCommitOnBranch mutation. The motivation is enterprise GitHub organisations that enforce "require signed commits" branch protection rules. The REST Git Data API creates unsigned commits, which are rejected by that policy, making push_files completely unusable in those environments. The createCommitOnBranch GraphQL mutation produces web-flow signed commits, satisfying the policy without any special key management on the caller side. The change is fully backwards-compatible: the mutation works on repos whether or not the signed-commit requirement is enabled. Updated test suite: - Replaced tree/commit/updateref REST mocks with a GQL mutation mock - Added a "fails to create signed commit" error path test - Fixed TypedRepositoryOutputs GQL handler to dispatch by query type
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The returned reference updates the SHA but leaves object.url pointing to the previous commit, causing legacy clients to retrieve stale commit data after a successful push.
1 open issue
What changed in this PR
This PR moves push_files commit creation to GraphQL’s createCommitOnBranch mutation, enabling GitHub-signed commits for repositories that require signed commits.
Changes:
- Replace REST tree, commit, and reference-update operations with a GraphQL mutation using base64-encoded file contents.
- Retain REST-based branch lookup, branch creation, and empty-repository initialization.
- Update behavioral tests and shared GraphQL mocks for the new commit flow.
| File | Description |
|---|---|
pkg/github/typed_repository_outputs_test.go |
Dispatch GraphQL mock responses by query type. |
pkg/github/repositories.go |
Implement signed commit creation through GraphQL. |
pkg/github/repositories_test.go |
Replace REST commit mocks with GraphQL success and failure cases. |
Review effort: Balanced (adaptive)
The URL was still pointing at the previous commit after updating the SHA. Update it in-place so legacy clients following object.url get the new commit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Replace the five-step REST Git Data API flow in
push_fileswith a singlecreateCommitOnBranchGraphQL mutation so that the tool works in GitHub Enterprise environments that enforce require signed commits branch protection rules.Why
Enterprise GitHub organisations can enable "Require signed commits" on branches. The existing implementation calls
CreateTree+CreateCommit+UpdateRefvia the REST Git Data API, which creates unsigned commits — these are silently rejected by that policy, makingpush_filescompletely unusable in those orgs.The
createCommitOnBranchGraphQL mutation creates web-flow signed commits (the same mechanism GitHub's own web UI uses), satisfying the enterprise policy without any special key management or GPG setup on the caller side. The change is fully backwards-compatible: the mutation works on repos whether or not the signed-commit requirement is enabled.Verified working on GitHub Enterprise Server — the mutation is supported and produces verified commits.
What changed
CreateTree+GetCommit+CreateCommit+UpdateRefREST calls with a singlecreateCommitOnBranchGraphQL mutation inPushFilesFileAddition.Contentsin the mutation inputGetRef(andinitializeRepositoryfor empty repos) REST calls are retained — only the commit creation step changedTest_PushFiles: replaced tree/commit/updateref REST mocks with a GQL mutation mock; added "fails to create signed commit" error path testtypedRepositoryDepsGQL handler intyped_repository_outputs_test.goto dispatch responses by query typeMCP impact
The
push_filestool now creates web-flow signed commits instead of unsigned commits. Callers on standard GitHub.com see no functional difference; callers in orgs with "require signed commits" now get a working tool instead of a silent failure.Prompts tested (tool changes only)
createCommitOnBranchmutation works end-to-end on GitHub Enterprise ServerSecurity / limits
The GraphQL mutation respects the same OAuth scopes as the REST approach (
repo). No new permissions are required. Commits are web-flow signed by GitHub server-side after authenticating the caller's token — the same mechanism used by GitHub's own web editor.Tool renaming
Lint & tests
./script/lint— 0 issues./script/test— all 32 packages passDocs
Skills