The Get a Reference "GET /repos/:owner/:repo/git/refs/:ref" endpoint,
documented at https://developer.github.com/v3/git/refs/#get-a-reference,
can return multiple references if there is no exact match for ref.
This change adds GitService.GetRefs method that is a more 1:1 mapping
to that GitHub API endpoint. It returns a slice of references.
The slice contains 1 reference if there was an exact match, otherwise
multiple references that begin with ref. If there are no such
references, a not found error is returned.
The current behavior and signature of GitService.GetRef method is
unmodified. Its purpose is to fetch a single exact match for a
reference, or return a not found error if there's no exact match.
The returned error text is improved for situations when there's no
exact match but GitHub API returns an array containing multiple refs
that have ref as prefix. Previously, it was a JSON decoding error,
now it says "no exact match found for this ref".
Fixes#588.
This is a large breaking API change. It is unavoidable and necessary
to resolve#526. This breaking change is part of bump to libraryVersion 3.
It adds ctx context.Context as first parameter to all endpoint methods,
including Do.
Updating for this API change should be easy and the compiler will help
catch instances that need to be updated. For example:
main.go:193: not enough arguments in call to gh.Activity.MarkRepositoryNotificationsRead
have (string, string, time.Time)
want (context.Context, string, string, time.Time)
...
You should pass the available context as first parameter. If your code
does not have context.Context available and you want to maintain previous
normal behavior, use context.Background(). Don't pass nil context; use
context.TODO() instead if you wish to delay figuring out the best context
to use. Then you can address the TODO at a later time.
Refer to documentation of package context at https://godoc.org/context
for more information.
This commit also changes ./tests/fields to use context.Background()
instead of deprecated oauth2.NoContext.
Resolves#526.
Note that this is an API-breaking change but should have minimal
impact on users of this package due to the nice inference
properties of the Go programming language.
Bumped `libraryVersion` to `2` due to API-breaking change as
discussed in #376.
Fixes#180.
Change-Id: Ib386135e6b8f306d1f54278968c576f3ceccc4e7
The git ref methods were mostly written to not expect the 'refs/' prefix
on ref names, even though it is included the ref.Ref value returned by
GitHub. This resulted in ref values returned from some methods that
couldn't be passed to other methods. In reality, ref names passed to
these methods should normally include the prefix, but this change
supports either form for backwards compatibility.
Fixes#133
This includes all of the methods mentioned in this blog post:
https://developer.github.com/changes/2014-03-18-paginating-method-changes/
as well as a handful of others I found. Sadly, this is a breaking
change for many of these methods because it changes the method
signature, but with yesterday's API change these methods are now broken
anyway. :(
this is a breaking change, but this was only recently added so I'm not
too worried. This also seems the best way to handle sub-namespaces on
this method.