UpdateComment now takes in a RepositoryComment instead of a string for a
parameter. This makes it easier to support more data types if/when the API
changes.
This provides somewhat reasonable string representations of GitHub
structs. This is specifically designed for this library and takes a
number of shortcuts where it can, so is not suitable as a general
purpose solution. That said, I am exporting this function because it is
useful for things like printing out slices of GitHub structs, as can be
seen in examples/example.go.
I am certainly open to suggestions for what exactly the stringified
output should look like. Currently, I think I've found a reasonable
compromise between fmt's "%v" and "%s" output.
Like a51d6b4303, this change makes me sad, mainly because it is a
breaking change for all clients, and makes common tasks like reading
data out of structs slightly more work, with no direct benefit. Notably,
developers will need to make sure and check for nil values before trying
to dereference these pointers. Sadly, the change is still necessary, as
is more fully explained in issue #19. We can make the nil pointer
checks a little easier by adding some Get* funcs like goprotobuf does.
I spent a lot of time over the last few weeks exploring this change
(switching fields to pointers) versus the much larger change of using
protocol buffers for all GitHub data types. While the goprotobuf
library is very mature and feature-rich (it's used heavily inside of
Google), it's the wrong tool for this task, since we're not actually
using the proto wire format. While it does address the immediate
concern in #19, it makes way too many other things terribly awkward.
One of the biggest drawbacks of this change is that it will make the
string output from fmt.Printf("%v") next to useless, since all pointer
values are displayed as their memory address. To handle that, I'll be
writing a custom String() function for these structs that is heavily
inspired by goprotobuf and internals from go's fmt package.
our package docs are too long yet to really need to be in their own
file, but I'd like to flesh them out a bit more, particularly once #19
is resolved.
when initializing a slice of concrete structs, it's not necessary to
declare the type of each item in the slice, since the compiler knows
what you mean.
The truth is, this change makes me sad. It's a breaking change
for all clients and it adds more complexity to the library surface. In
most cases, clients will simply drop the Response object on the floor
(which is actually all the library itself was doing before this
change... now we're just pushing that off to the client).
Initially, the Response object will be primarily of interest for
functions that return paginated result sets, since the Response.NextPage
field is the only way to know for sure if there are more pages that
should be fetched. And this is really the cleanest way to get at that
data, so in that respect this change isn't so bad.
It's also worth noting that returning the raw Response object makes a
lot more since in a GitHub library than it may in others, given how
GitHub makes liberal (read: proper) use of HTTP request and response
headers. Other APIs, like Google's various APIs for example, tend to
push things like pagination links into the response body. While this is
certainly less of a purist view in terms of REST, it does make the lives
of client developers a lot easier, since then the response body contains
everything you need to know. But whatever; this is how GitHub rolls, so
we'll roll right along with them. (Somewhat ironically we are ignoring
the RESTful links in the GitHub response bodies, since we're actually
calling the API in an RPC style and don't do anything with those links.)
We still don't have an easy way to set arbitrary request headers, but
that's a problem for another day.
Fixes#22
This allows use to provide convenience methods for accessing the
paginations links that are returned in HTTP Link headers. To expose
that, we'll need to return the Response from all API methods, which will
also allow users of the client to do any other kind of inspection of the
response. This adds additional complexity to the API and will be a
breaking change, but seems to be the cleanest way to enable this sort of
thing.
Refs #22
This was done so that timestamp_test.go would have a corresponding file that
could easily be found. It did not make sense to move timestamp_test.go into
github_test.go if we are trying to move to a more specific source structure.
Repository service:
ListLanguages : Allows a user to list the languages for a repository
Activity service:
ListStarred : Allows a user to list the starred repositories for a user
This provides the structs needed to unmarshal the "old-style" post
receive hooks that are sent for push events. Because the formats
differ in sometimes subtle ways from the rest of the API, some types are
duplicated. I suspect we may also need to duplicate the Repository
type at some point, since there are some differences there as well. For
now this is just using the normal Repository type.
Thanks to both @wlynch92 and @imjasonh who kept pushing on this and
provided the original patches that this is based on.
Added a timestamp struct to handle different incoming time formats from
GitHub. Only modified the repo struct to reflect this new time struct
for now since it is currently the only location I am currently aware of
where this is an issue.
Issue: #1
The main purpose of adding this (aside from simply implementing the full
GitHub API) is to establish the basic Commit type, so that we can build
around it for things like Events (see #4) and WebHooks (see #20).
- complete the rename from TreesService to GitService. For example,
renaming Get to GetTree, and Create to CreateTree.
- rename GitTree to TreeEntry. I really have no idea why GitHub chose
to use the field name "tree" for this, since these aren't necessarily
trees in the git sense. Looking at it more closely, these are really
just the entries within a tree, hence the rename.
- simplify several tests and shuffle some things for consistency with
the rest of the library