octokit / go-octokit

Simple Go wrapper for the GitHub API
https://github.com/octokit/go-octokit
MIT License
258 stars 79 forks source link

Adding commit APIs #66

Closed owenthereal closed 10 years ago

owenthereal commented 10 years ago

This is to support https://github.com/github/hub/pull/601

/cc @mislav

mislav commented 10 years ago

It still doesn't support getting a raw patch for a commit?

owenthereal commented 10 years ago

@mislav For raw patch, I'm thinking to achieve like this:

url, _ := octokit.CommitURL.Expand(xxx)
req := client.NewRequest(url)
req.Header.Add("Accept", "application/vnd.github.v3.patch")
resp, _ := req.Get()
ioutil.ReadAll(resp.Body) // patch

I'm still thinking whether we should expose it as an API to CommitsService. Similar situation for gist and pull request.

mislav commented 10 years ago

I'm still thinking whether we should expose it as an API to CommitsService. Similar situation for gist and pull request.

Making a dedicated API for this use case would be great for users because they shouldn't be concerned with implementation details of GitHub API such as custom MIME types in request.

However, if you're fine with a lower-level API like you've just demonstrated, it will work for our purposes as well.

owenthereal commented 10 years ago

Making a dedicated API for this use case would be great for users because they shouldn't be concerned with implementation details of GitHub API such as custom MIME types in request.

I think I'm convinced this would be best solution for now, although it seems the patching API is only useful for very particular use case.

mislav commented 10 years ago

On Tue, Jul 29, 2014 at 4:45 PM, Jingwen Owen Ou notifications@github.com wrote:

I think I'm convinced this would be best solution for now, although it seems the patching API is only useful for very particular use case.

DO ITTT :+1:

owenthereal commented 10 years ago

@mislav How does https://github.com/octokit/go-octokit/commit/88741d50a1219f8a321581ba82f63365285fd948 taste? CommitsService#Patch returns a IO for reading the patch.

mislav commented 10 years ago

Looks pretty good. Perfect abstraction level for this kind of stuff.