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
Client.Rate() method is unreliable in situations when API calls are made
by others that may hit different rate limit categories (core and search).
Each API call already returns a Response struct that contains an accurate
Rate, so that's a better mechanism to access this information.
See relevant discussion at https://github.com/google/go-github/pull/347#discussion_r61920849.
When possible to do so reliably, i.e., the client knows that the rate
limit is exceeded and reset time is in the future, immediately return
*RateLimitError without making network calls to GitHub API.
Add a unit test covering RateLimits method populating client.rateLimits.
Remove commented out code.
Helps #152 and #153.
In GitHub API, there are currently two categories of rate limits: core
and search. Previously, the client only tracked the rate limit from the
most recent API call. This change makes it track both rate limit
categories.
This will be useful in the following commit.
On successful queries (on errors ReadAll runs in CheckResponse), the
Response.Body is not read all the way to the EOF as json.Decoder is used,
which stops at the end of the object, which is probably followed by a \n.
Then, Response.Body.Close() is called. When that happens with a non-drained
Body, the TCP/TLS connection is closed (which makes sense, in case there was
still a lot to read from the network), stopping the Transport from reusing
it. Also, a library user can't drain the Body themselves because Close() is
called before passing the Response to the user.
Since we know GitHub API responses only carry a single JSON object, draining
before closing is free, and saving all those handshakes causes huge savings
in latency, bandwidth and CPU for both the client and the poor GitHub
servers.
Here's the result of running the benchmark below on a ADSL connection:
before: 2m3.001599093s
after: 33.753543928s
func main() {
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
)
tc := oauth2.NewClient(oauth2.NoContext, ts)
gh := github.NewClient(tc)
start := time.Now()
for i := 0; i < 100; i++ {
gh.Repositories.Get("FiloSottile", "gvt")
fmt.Print(".")
}
fmt.Printf("\n%s\n", time.Now().Sub(start))
}
If a redirect to AWS occurs, then the redirect will be canceled and
the redirect Location will be returned in redirectURL and the
io.ReadCloser will be nil. At this point, the user would need to
perform the http.Get with the redirectURL in a different http.Client
(without the GitHub authentication transport).
Note that this is a breaking API change.
Fixes#246.
Change-Id: I4fe2dfc9cd0ce81934a07f11a6296e71c7dd51a0
Rate is now a method, not a field.
Mention RateLimits rather than RateLimit since the latter is deprecated.
Use Go convention for marking deprecated identifiers. See
257114af91.
For more information about the preview see here:
https://developer.github.com/changes/2015-11-11-protected-branches-api/
This adds only retrieving the information and not setting it. Setting
will come in a later commit (if that one here is okay).
I tried to follow the naming guidelines as much as possible and
hopefully I made it right the first time. :-)
Add a new error type, TwoFactorAuthError, which identifies the need to
include a one-time password when using Basic Auth for a user with
two-factor auth enabled.
An example of using both the new transport and error type can be seen in
examples/basicauth/main.go.
fixes#258
- allow setting permission when adding a team repository
- update IsTeamRepo to return a *Repository instead of a bool, since the
Repository contains the permission data for the team. This is a
BREAKING CHANGE, however I don't think this is an often used method.
- update docs for setting the team permission when creating or editing a
team.
Ref #187
These changes are now official, so the custom media type is no longer
needed. This does go ahead and remove RepositoryListOptions.IncludeOrg
which was being used to trigger the custom media type. Even though this
is a breaking change, it was only in for a month and I don't think it
was too widely used during that time.
Fixes#219
/cc @captncraig who may have been using this
Change-Id: Ib54ced78c51a9c4e54e470136d36f91bf4716e8c
Supports the updated starring API as mentioned in issue #188.
There is now a new struct called StarredRepository which holds a Repository and the new `starred_at` timestamp.
For now there is a special media type to request the new API. I've added a TODO for it to be deleted when the new API fully launches.
The client_id and client_secret URL variables,
containing sensitive app information, are leaked
to users if the Go error is returned to them. To
prevent this, sanitizeURL redacts the fields from
ErrorResponse's Error method. Therefore making the
error message safe to expose to users.