Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
872 views
in Technique[技术] by (71.8m points)

json - Github API create commit

I need help with Github API,

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

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

with data

{
    "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?

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

Thank you!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I puzzled over this one too!

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...