Github API 创建提交

编程入门 行业动态 更新时间:2024-10-14 08:26:20
本文介绍了Github API 创建提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我需要 Github API 方面的帮助,

I need help with Github API,

我需要通过 api 提交新版本的文件,我试图通过向

I need commit new version of file through api, I'm trying to achieve this by sending post request to

https://api.github/repos/:username/:repo:/git/commits/

有数据

{
    "login": "username",
    "token": "auth_token",
    "parent_commit": "sha",
    "message": "commit message.",
    "content": {
        "path": "full/path",
        "mode": "edit",
        "data": "new content"
    }
}

但结果失败 - 未找到.

But it fails with result - not found.

有谁知道该向何处发送此请求以及这种格式是否正确?

Have anyone idea where to send this request and if this format is right?

(格式的灵感来自 - http://swanson.github/blog/2011/07/23/digging-around-the-github-api-take-2.html)

(Format is inspired by - http://swanson.github/blog/2011/07/23/digging-around-the-github-api-take-2.html)

谢谢!

推荐答案

我也有这个疑惑!

提交新内容实际上是一个多步骤的过程,使用它们的低级和强大的 API.

Committing new content is actually a multi-step process, using their low level and powerful API.

这是我用来分享一个解决方案的要点.请注意,有些东西是硬编码的,例如分支名称master".

Here is a gist I made to share one solution. Note that a few things are hard coded, like the branch name "master".

请随意分叉并改进要点,或者如果您在运行时遇到问题,请告诉我.

Please feel free to fork and improve the gist, or let me know if you're having trouble getting this to run.

这篇关于Github API 创建提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 16:04:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/942176.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Github   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!