Bump deps

This commit is contained in:
Jeff Mitchell
2017-07-18 10:15:54 -04:00
parent 88910d0b1c
commit 79c47b9433
378 changed files with 22305 additions and 14008 deletions

View File

@@ -315,6 +315,7 @@ type Response struct {
}
// newResponse creates a new Response for the provided http.Response.
// r must not be nil.
func newResponse(r *http.Response) *Response {
response := &Response{Response: r}
response.populatePageValues()
@@ -530,9 +531,9 @@ type RateLimitError struct {
}
func (r *RateLimitError) Error() string {
return fmt.Sprintf("%v %v: %d %v; rate reset in %v",
return fmt.Sprintf("%v %v: %d %v %v",
r.Response.Request.Method, sanitizeURL(r.Response.Request.URL),
r.Response.StatusCode, r.Message, r.Rate.Reset.Time.Sub(time.Now()))
r.Response.StatusCode, r.Message, formatRateReset(r.Rate.Reset.Time.Sub(time.Now())))
}
// AcceptedError occurs when GitHub returns 202 Accepted response with an
@@ -880,6 +881,31 @@ func cloneRequest(r *http.Request) *http.Request {
return r2
}
// formatRateReset formats d to look like "[rate reset in 2s]" or
// "[rate reset in 87m02s]" for the positive durations. And like "[rate limit was reset 87m02s ago]"
// for the negative cases.
func formatRateReset(d time.Duration) string {
isNegative := d < 0
if isNegative {
d *= -1
}
secondsTotal := int(0.5 + d.Seconds())
minutes := secondsTotal / 60
seconds := secondsTotal - minutes*60
var timeString string
if minutes > 0 {
timeString = fmt.Sprintf("%dm%02ds", minutes, seconds)
} else {
timeString = fmt.Sprintf("%ds", seconds)
}
if isNegative {
return fmt.Sprintf("[rate limit was reset %v ago]", timeString)
}
return fmt.Sprintf("[rate reset in %v]", timeString)
}
// Bool is a helper routine that allocates a new bool value
// to store v and returns a pointer to it.
func Bool(v bool) *bool { return &v }