如何使用GitHub GraphQl API创建新提交?
我正在尝试使用github graphQl api创建新提交,并使用 createCommitonbranch 突变。 预期黑头应该使用什么值:“ ?????”? 如何从GraphQL API中获得此类值?
到目前为止,这是我的尝试:
{
mutation m1 {
createCommitOnBranch(
input: {
branch:
{repositoryNameWithOwner: "some_repo/some_owner",
branchName: "main"
},
message: {headline: "headline!"},
fileChanges: {
additions: {path: "README.md", contents: "SGVsbG8gV29ybGQ="}
}
expectedHeadOid: "?????"
}
)
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该是您要创建的新提交的父母提交。
因此,
“ Expectheadheadoid”:“ git rev-parse head”
在head> head
(head> head
head head )上您想使用一个突变createCommitonBranch
和其端点)。carl brasic 在他的要点中显示 createCommitonbranch错误示例“如果您传递了date date
expect> greenge> greenge> greenge> greation
值错误:
此示例 /code>)获取第二个参数值(
createCommitonBranchInput
),当您没有本地克隆的存储库时很有用:步骤2。使用称为“
createCommitonBranchInput
”的GraphQl突变,以创建使用新文件内容的提交:It should be the parent commit of the new commit you want to create.
Hence the
"expectedHeadOid": "git rev-parse HEAD"
which prints the SHA1 hash ofHEAD
(HEAD
of the remote repository on top of which you want to append a new commit using a mutationcreatecommitonbranch
, and its endpoint).In octokit, it is described as:
Carl Brasic shows in his gist "createCommitOnBranch error example" what happens if you pass an out of date
expectedHeadOid
valueError:
This example uses a first query (
defaultBranchRef
) to get the parameter value for the second one (CreateCommitOnBranchInput
), useful when you don't have a locally cloned repository:Step 2. Use graphQL mutation called "
CreateCommitOnBranchInput
" to create a commit with new file content: