octokit 4.6.2 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/lib/octokit/authentication.rb +8 -0
- data/lib/octokit/client.rb +15 -0
- data/lib/octokit/client/authorizations.rb +3 -3
- data/lib/octokit/client/gists.rb +2 -2
- data/lib/octokit/client/integrations.rb +77 -0
- data/lib/octokit/client/labels.rb +6 -6
- data/lib/octokit/client/organizations.rb +85 -4
- data/lib/octokit/client/projects.rb +6 -6
- data/lib/octokit/client/pull_requests.rb +2 -2
- data/lib/octokit/client/rate_limit.rb +2 -2
- data/lib/octokit/client/repositories.rb +16 -0
- data/lib/octokit/client/reviews.rb +174 -0
- data/lib/octokit/client/search.rb +8 -8
- data/lib/octokit/client/source_import.rb +1 -1
- data/lib/octokit/client/statuses.rb +1 -1
- data/lib/octokit/client/users.rb +2 -1
- data/lib/octokit/configurable.rb +5 -1
- data/lib/octokit/connection.rb +4 -1
- data/lib/octokit/default.rb +7 -1
- data/lib/octokit/error.rb +6 -2
- data/lib/octokit/gist.rb +1 -1
- data/lib/octokit/middleware/follow_redirects.rb +1 -1
- data/lib/octokit/preview.rb +4 -1
- data/lib/octokit/rate_limit.rb +3 -3
- data/lib/octokit/version.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24ad9c72b02054c430f10ff8614064cce38297b2
|
4
|
+
data.tar.gz: 11f0aebf4f5266212ebaa314702622f7fdf0d6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0067cbdcbdd2bd217622159bc716c5f2ba50b7ae2a6bcff8234ba0ec8a0dcd1c4d7f009d6391d6f70c8f7fb5ff907ed27e56c0ba9204edb021e8d5ef6422df16
|
7
|
+
data.tar.gz: d1c6ee18fcdbbcd0c0d2115e3bdf24c832e57d03a8454d1a3ad7f474733854d9992f4323a504256117ccc7769120971bb1634417a5d710ff49ee635187716a48
|
data/README.md
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby toolkit for the GitHub API.
|
4
4
|
|
5
|
-
![
|
6
|
-
[logo]: http://cl.ly/image/3Y013H0A2z3z/gundam-ruby.png
|
5
|
+
![logo](http://cl.ly/image/3Y013H0A2z3z/gundam-ruby.png)
|
7
6
|
|
8
7
|
Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
9
8
|
[major version][semver].
|
@@ -622,11 +621,14 @@ ENV Variable | Description |
|
|
622
621
|
`OCTOKIT_TEST_GITHUB_CLIENT_SECRET` | Test OAuth application client secret.
|
623
622
|
`OCTOKIT_TEST_GITHUB_REPOSITORY` | Test repository to perform destructive actions against, this should not be set to any repository of importance. **Automatically created by the test suite if nonexistent** Default: `api-sandbox`
|
624
623
|
`OCTOKIT_TEST_GITHUB_ORGANIZATION` | Test organization.
|
625
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_LOGIN` | GitHub Enterprise login name
|
626
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_TOKEN` | GitHub Enterprise token
|
627
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password
|
628
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT` | GitHub Enterprise hostname
|
629
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint
|
624
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_LOGIN` | GitHub Enterprise login name.
|
625
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_TOKEN` | GitHub Enterprise token.
|
626
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password.
|
627
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT` | GitHub Enterprise hostname.
|
628
|
+
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint.
|
629
|
+
`OCTOKIT_TEST_GITHUB_INTEGRATION` | [GitHub Integration](https://developer.github.com/early-access/integrations/) owned by your test organization.
|
630
|
+
`OCTOKIT_TEST_GITHUB_INTEGRATION_INSTALLATION` | Installation of the GitHub Integration specified above.
|
631
|
+
`OCTOKIT_TEST_INTEGRATION_PEM_KEY` | File path to the private key generated from your integration.
|
630
632
|
|
631
633
|
Since we periodically refresh our cassettes, please keep some points in mind
|
632
634
|
when writing new specs.
|
@@ -21,6 +21,14 @@ module Octokit
|
|
21
21
|
!!@access_token
|
22
22
|
end
|
23
23
|
|
24
|
+
# Indicates if the client was supplied a bearer token
|
25
|
+
#
|
26
|
+
# @see https://developer.github.com/early-access/integrations/authentication/#as-an-integration
|
27
|
+
# @return [Boolean]
|
28
|
+
def bearer_authenticated?
|
29
|
+
!!@bearer_token
|
30
|
+
end
|
31
|
+
|
24
32
|
# Indicates if the client was supplied an OAuth
|
25
33
|
# access token or Basic Auth username and password
|
26
34
|
#
|
data/lib/octokit/client.rb
CHANGED
@@ -22,6 +22,7 @@ require 'octokit/client/feeds'
|
|
22
22
|
require 'octokit/client/gists'
|
23
23
|
require 'octokit/client/gitignore'
|
24
24
|
require 'octokit/client/hooks'
|
25
|
+
require 'octokit/client/integrations'
|
25
26
|
require 'octokit/client/issues'
|
26
27
|
require 'octokit/client/labels'
|
27
28
|
require 'octokit/client/legacy_search'
|
@@ -42,6 +43,7 @@ require 'octokit/client/refs'
|
|
42
43
|
require 'octokit/client/releases'
|
43
44
|
require 'octokit/client/repositories'
|
44
45
|
require 'octokit/client/repository_invitations'
|
46
|
+
require 'octokit/client/reviews'
|
45
47
|
require 'octokit/client/say'
|
46
48
|
require 'octokit/client/search'
|
47
49
|
require 'octokit/client/service_status'
|
@@ -76,6 +78,7 @@ module Octokit
|
|
76
78
|
include Octokit::Client::Gists
|
77
79
|
include Octokit::Client::Gitignore
|
78
80
|
include Octokit::Client::Hooks
|
81
|
+
include Octokit::Client::Integrations
|
79
82
|
include Octokit::Client::Issues
|
80
83
|
include Octokit::Client::Labels
|
81
84
|
include Octokit::Client::LegacySearch
|
@@ -96,6 +99,7 @@ module Octokit
|
|
96
99
|
include Octokit::Client::Releases
|
97
100
|
include Octokit::Client::Repositories
|
98
101
|
include Octokit::Client::RepositoryInvitations
|
102
|
+
include Octokit::Client::Reviews
|
99
103
|
include Octokit::Client::Say
|
100
104
|
include Octokit::Client::Search
|
101
105
|
include Octokit::Client::ServiceStatus
|
@@ -126,6 +130,7 @@ module Octokit
|
|
126
130
|
# mask password
|
127
131
|
inspected = inspected.gsub! @password, "*******" if @password
|
128
132
|
inspected = inspected.gsub! @management_console_password, "*******" if @management_console_password
|
133
|
+
inspected = inspected.gsub! @bearer_token, '********' if @bearer_token
|
129
134
|
# Only show last 4 of token, secret
|
130
135
|
if @access_token
|
131
136
|
inspected = inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}"
|
@@ -186,6 +191,14 @@ module Octokit
|
|
186
191
|
@access_token = value
|
187
192
|
end
|
188
193
|
|
194
|
+
# Set Bearer Token for authentication
|
195
|
+
#
|
196
|
+
# @param value [String] JWT
|
197
|
+
def bearer_token=(value)
|
198
|
+
reset_agent
|
199
|
+
@bearer_token = value
|
200
|
+
end
|
201
|
+
|
189
202
|
# Set OAuth app client_id
|
190
203
|
#
|
191
204
|
# @param value [String] 20 character GitHub OAuth app client_id
|
@@ -212,6 +225,8 @@ module Octokit
|
|
212
225
|
http.basic_auth(@login, @password)
|
213
226
|
elsif token_authenticated?
|
214
227
|
http.authorization 'token', @access_token
|
228
|
+
elsif bearer_authenticated?
|
229
|
+
http.authorization 'Bearer', @bearer_token
|
215
230
|
end
|
216
231
|
http.headers['accept'] = options[:accept] if options.key?(:accept)
|
217
232
|
end
|
@@ -152,7 +152,7 @@ module Octokit
|
|
152
152
|
secret = opts.delete(:client_secret) || client_secret
|
153
153
|
|
154
154
|
as_app(key, secret) do |app_client|
|
155
|
-
app_client.get "
|
155
|
+
app_client.get "applications/#{client_id}/tokens/#{token}", opts
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -173,7 +173,7 @@ module Octokit
|
|
173
173
|
secret = opts.delete(:client_secret) || client_secret
|
174
174
|
|
175
175
|
as_app(key, secret) do |app_client|
|
176
|
-
app_client.post "
|
176
|
+
app_client.post "applications/#{client_id}/tokens/#{token}", opts
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -194,7 +194,7 @@ module Octokit
|
|
194
194
|
secret = opts.delete(:client_secret) || client_secret
|
195
195
|
|
196
196
|
as_app(key, secret) do |app_client|
|
197
|
-
app_client.delete "
|
197
|
+
app_client.delete "applications/#{client_id}/tokens/#{token}", opts
|
198
198
|
|
199
199
|
app_client.last_response.status == 204
|
200
200
|
end
|
data/lib/octokit/client/gists.rb
CHANGED
@@ -195,7 +195,7 @@ module Octokit
|
|
195
195
|
# @example
|
196
196
|
# @client.create_gist_comment('3528645', 'This is very helpful.')
|
197
197
|
def create_gist_comment(gist_id, comment, options = {})
|
198
|
-
options.merge
|
198
|
+
options = options.merge({:body => comment})
|
199
199
|
post "gists/#{gist_id}/comments", options
|
200
200
|
end
|
201
201
|
|
@@ -211,7 +211,7 @@ module Octokit
|
|
211
211
|
# @example
|
212
212
|
# @client.update_gist_comment('208sdaz3', '3528645', ':heart:')
|
213
213
|
def update_gist_comment(gist_id, gist_comment_id, comment, options = {})
|
214
|
-
options.merge
|
214
|
+
options = options.merge({:body => comment})
|
215
215
|
patch "gists/#{gist_id}/comments/#{gist_comment_id}", options
|
216
216
|
end
|
217
217
|
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Methods for the Integrations API
|
5
|
+
module Integrations
|
6
|
+
|
7
|
+
# Find all installations that belong to an Integration
|
8
|
+
#
|
9
|
+
# @param options [Hash] An customizable set of options
|
10
|
+
#
|
11
|
+
# @see https://developer.github.com/v3/integrations/#find-installations
|
12
|
+
#
|
13
|
+
# @return [Array<Sawyer::Resource>] A list of installations
|
14
|
+
def find_integration_installations(options = {})
|
15
|
+
opts = ensure_api_media_type(:integrations, options)
|
16
|
+
paginate "/integration/installations", opts
|
17
|
+
end
|
18
|
+
alias find_installations find_integration_installations
|
19
|
+
|
20
|
+
# Create a new installation token
|
21
|
+
#
|
22
|
+
# @param installation [Integer] The id of a a GitHub Integration Installation
|
23
|
+
# @param options [Hash] An customizable set of options
|
24
|
+
#
|
25
|
+
# @see https://developer.github.com/v3/integrations/#find-installations
|
26
|
+
#
|
27
|
+
# @return [<Sawyer::Resource>] An installation token
|
28
|
+
def create_integration_installation_access_token(installation, options = {})
|
29
|
+
opts = ensure_api_media_type(:integrations, options)
|
30
|
+
post "/installations/#{installation}/access_tokens", opts
|
31
|
+
end
|
32
|
+
alias create_installation_access_token create_integration_installation_access_token
|
33
|
+
|
34
|
+
# List repositories that are accessible to the authenticated installation
|
35
|
+
#
|
36
|
+
# @param options [Hash] An customizable set of options
|
37
|
+
# @see https://developer.github.com/v3/integrations/installations/#list-repositories
|
38
|
+
#
|
39
|
+
# @return [Array<Sawyer::Resource>] A list of repositories
|
40
|
+
def list_integration_installation_repositories(options = {})
|
41
|
+
opts = ensure_api_media_type(:integrations, options)
|
42
|
+
paginate "/installation/repositories", opts
|
43
|
+
end
|
44
|
+
alias list_installation_repos list_integration_installation_repositories
|
45
|
+
|
46
|
+
# Add a single repository to an installation
|
47
|
+
#
|
48
|
+
# @param installation [Integer] The id of a a GitHub Integration Installation
|
49
|
+
# @param repo [Integer] The id of the GitHub repository
|
50
|
+
# @param options [Hash] An customizable set of options
|
51
|
+
#
|
52
|
+
# @see https://developer.github.com/v3/integrations/installations/#add-repository-to-installation
|
53
|
+
#
|
54
|
+
# @return [Boolean] Success
|
55
|
+
def add_repository_to_integration_installation(installation, repo, options = {})
|
56
|
+
opts = ensure_api_media_type(:integrations, options)
|
57
|
+
boolean_from_response :put, "/installations/#{installation}/repositories/#{repo}", opts
|
58
|
+
end
|
59
|
+
alias add_repo_to_installation add_repository_to_integration_installation
|
60
|
+
|
61
|
+
# Remove a single repository to an installation
|
62
|
+
#
|
63
|
+
# @param installation [Integer] The id of a a GitHub Integration Installation
|
64
|
+
# @param repo [Integer] The id of the GitHub repository
|
65
|
+
# @param options [Hash] An customizable set of options
|
66
|
+
#
|
67
|
+
# @see https://developer.github.com/v3/integrations/installations/#remove-repository-from-installation
|
68
|
+
#
|
69
|
+
# @return [Boolean] Success
|
70
|
+
def remove_repository_from_integration_installation(installation, repo, options = {})
|
71
|
+
opts = ensure_api_media_type(:integrations, options)
|
72
|
+
boolean_from_response :delete, "/installations/#{installation}/repositories/#{repo}", opts
|
73
|
+
end
|
74
|
+
alias remove_repo_from_installation remove_repository_from_integration_installation
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -78,7 +78,7 @@ module Octokit
|
|
78
78
|
# This removes the label from the Issue
|
79
79
|
#
|
80
80
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
81
|
-
# @param number [
|
81
|
+
# @param number [Integer] Number ID of the issue
|
82
82
|
# @param label [String] String name of the label
|
83
83
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
84
84
|
# @see https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue
|
@@ -93,7 +93,7 @@ module Octokit
|
|
93
93
|
# This removes the label from the Issue
|
94
94
|
#
|
95
95
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
96
|
-
# @param number [
|
96
|
+
# @param number [Integer] Number ID of the issue
|
97
97
|
# @return [Boolean] Success of operation
|
98
98
|
# @see https://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue
|
99
99
|
# @example Remove all labels from Issue #23
|
@@ -105,7 +105,7 @@ module Octokit
|
|
105
105
|
# List labels for a given issue
|
106
106
|
#
|
107
107
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
108
|
-
# @param number [
|
108
|
+
# @param number [Integer] Number ID of the issue
|
109
109
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
110
110
|
# @see https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
|
111
111
|
# @example List labels for octokit/octokit.rb, issue # 1
|
@@ -117,7 +117,7 @@ module Octokit
|
|
117
117
|
# Add label(s) to an Issue
|
118
118
|
#
|
119
119
|
# @param repo [Integer, String, Repository, Hash] A Github repository
|
120
|
-
# @param number [
|
120
|
+
# @param number [Integer] Number ID of the issue
|
121
121
|
# @param labels [Array] An array of labels to apply to this Issue
|
122
122
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
123
123
|
# @see https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue
|
@@ -130,7 +130,7 @@ module Octokit
|
|
130
130
|
# Replace all labels on an Issue
|
131
131
|
#
|
132
132
|
# @param repo [Integer, String, Repository, Hash] A Github repository
|
133
|
-
# @param number [
|
133
|
+
# @param number [Integer] Number ID of the issue
|
134
134
|
# @param labels [Array] An array of labels to use as replacement
|
135
135
|
# @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
|
136
136
|
# @see https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue
|
@@ -143,7 +143,7 @@ module Octokit
|
|
143
143
|
# Get labels for every issue in a milestone
|
144
144
|
#
|
145
145
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
146
|
-
# @param number [
|
146
|
+
# @param number [Integer] Number ID of the milestone
|
147
147
|
# @return [Array<Sawyer::Resource>] A list of the labels across the milestone
|
148
148
|
# @see http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
|
149
149
|
# @example List all labels for milestone #2 on octokit/octokit.rb
|
@@ -31,6 +31,8 @@ module Octokit
|
|
31
31
|
# @option values [String] :email Publicly visible email address.
|
32
32
|
# @option values [String] :location Location of organization.
|
33
33
|
# @option values [String] :name GitHub username for organization.
|
34
|
+
# @option values [String] :default_repository_permission The default permission members have on organization repositories.
|
35
|
+
# @option values [Boolean] :members_can_create_repositories Set true to allow members to create repositories on the organization.
|
34
36
|
# @return [Sawyer::Resource] Hash representing GitHub organization.
|
35
37
|
# @see https://developer.github.com/v3/orgs/#edit-an-organization
|
36
38
|
# @example
|
@@ -96,7 +98,7 @@ module Octokit
|
|
96
98
|
#
|
97
99
|
# @return [Array<Sawyer::Resource>] List of GitHub organizations.
|
98
100
|
def all_organizations(options = {})
|
99
|
-
paginate "organizations"
|
101
|
+
paginate "organizations", options
|
100
102
|
end
|
101
103
|
alias :all_orgs :all_organizations
|
102
104
|
|
@@ -207,6 +209,69 @@ module Octokit
|
|
207
209
|
end
|
208
210
|
alias :org_public_member? :organization_public_member?
|
209
211
|
|
212
|
+
# List pending organization invitations
|
213
|
+
#
|
214
|
+
# Requires authenticated organization member.
|
215
|
+
#
|
216
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
217
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing invitations.
|
218
|
+
# @see https://developer.github.com/v3/orgs/members/#list-pending-organization-invitations
|
219
|
+
#
|
220
|
+
# @example
|
221
|
+
# @client.organization_invitations('github')
|
222
|
+
def organization_invitations(org, options = {})
|
223
|
+
options = ensure_api_media_type(:org_memberships, options)
|
224
|
+
get "#{Organization.path org}/invitations", options
|
225
|
+
end
|
226
|
+
alias :org_invitations :organization_invitations
|
227
|
+
|
228
|
+
# List outside collaborators for an organization
|
229
|
+
#
|
230
|
+
# Requires authenticated organization members.
|
231
|
+
#
|
232
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
233
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing users.
|
234
|
+
# @see https://developer.github.com/v3/orgs/outside-collaborators/#list-outside-collaborators
|
235
|
+
#
|
236
|
+
# @example
|
237
|
+
# @client.outside_collaborators('github')
|
238
|
+
def outside_collaborators(org, options={})
|
239
|
+
options = ensure_api_media_type(:org_memberships, options)
|
240
|
+
get "#{Organization.path org}/outside_collaborators", options
|
241
|
+
end
|
242
|
+
|
243
|
+
# Remove outside collaborator from an organization
|
244
|
+
#
|
245
|
+
# Requires authenticated organization members.
|
246
|
+
#
|
247
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
248
|
+
# @param user [String] GitHub username to be removed as outside collaborator
|
249
|
+
# @return [Boolean] Return true if outside collaborator removed from organization, false otherwise.
|
250
|
+
# @see https://developer.github.com/v3/orgs/outside-collaborators/#remove-outside-collaborator
|
251
|
+
#
|
252
|
+
# @example
|
253
|
+
# @client.remove_outside_collaborator('github', 'lizzhale')
|
254
|
+
def remove_outside_collaborator(org, user, options={})
|
255
|
+
options = ensure_api_media_type(:org_memberships, options)
|
256
|
+
boolean_from_response :delete, "#{Organization.path org}/outside_collaborators/#{user}", options
|
257
|
+
end
|
258
|
+
|
259
|
+
# Converts an organization member to an outside collaborator
|
260
|
+
#
|
261
|
+
# Requires authenticated organization members.
|
262
|
+
#
|
263
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
264
|
+
# @param user [String] GitHub username to be removed as outside collaborator
|
265
|
+
# @return [Boolean] Return true if outside collaborator removed from organization, false otherwise.
|
266
|
+
# @see https://developer.github.com/v3/orgs/outside-collaborators/#convert-member-to-outside-collaborator
|
267
|
+
#
|
268
|
+
# @example
|
269
|
+
# @client.convert_to_outside_collaborator('github', 'lizzhale')
|
270
|
+
def convert_to_outside_collaborator(org, user, options={})
|
271
|
+
options = ensure_api_media_type(:org_memberships, options)
|
272
|
+
boolean_from_response :put, "#{Organization.path org}/outside_collaborators/#{user}", options
|
273
|
+
end
|
274
|
+
|
210
275
|
# List teams
|
211
276
|
#
|
212
277
|
# Requires authenticated organization member.
|
@@ -230,6 +295,7 @@ module Octokit
|
|
230
295
|
# @param org [String, Integer] Organization GitHub login or id.
|
231
296
|
# @option options [String] :name Team name.
|
232
297
|
# @option options [Array<String>] :repo_names Repositories for the team.
|
298
|
+
# @option options [Array<String>] :maintainers Maintainers for the team.
|
233
299
|
# @return [Sawyer::Resource] Hash representing new team.
|
234
300
|
# @see https://developer.github.com/v3/orgs/teams/#create-team
|
235
301
|
# @example
|
@@ -361,12 +427,27 @@ module Octokit
|
|
361
427
|
# @see https://developer.github.com/v3/orgs/teams/#get-team-member
|
362
428
|
#
|
363
429
|
# @example Check if a user is in your team
|
364
|
-
# @client.team_member?(
|
430
|
+
# @client.team_member?(100000, 'pengwynn')
|
365
431
|
# => false
|
366
432
|
def team_member?(team_id, user, options = {})
|
367
433
|
boolean_from_response :get, "teams/#{team_id}/members/#{user}", options
|
368
434
|
end
|
369
435
|
|
436
|
+
# List pending team invitations
|
437
|
+
#
|
438
|
+
# Requires authenticated organization member.
|
439
|
+
#
|
440
|
+
# @param team_id [Integer] Team id.
|
441
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing invitations.
|
442
|
+
# @see https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations
|
443
|
+
#
|
444
|
+
# @example
|
445
|
+
# @client.team_invitations('github')
|
446
|
+
def team_invitations(team_id, options = {})
|
447
|
+
options = ensure_api_media_type(:org_memberships, options)
|
448
|
+
get "teams/#{team_id}/invitations", options
|
449
|
+
end
|
450
|
+
|
370
451
|
# List team repositories
|
371
452
|
#
|
372
453
|
# Requires authenticated organization member.
|
@@ -560,14 +641,14 @@ module Octokit
|
|
560
641
|
|
561
642
|
# Get an organization membership
|
562
643
|
#
|
563
|
-
# @param org [String]
|
644
|
+
# @param org [Integer, String] The GitHub Organization.
|
564
645
|
# @option options [String] :user The login of the user, otherwise authenticated user.
|
565
646
|
# @return [Sawyer::Resource] Hash representing the organization membership.
|
566
647
|
# @see https://developer.github.com/v3/orgs/members/#get-your-organization-membership
|
567
648
|
# @see https://developer.github.com/v3/orgs/members/#get-organization-membership
|
568
649
|
def organization_membership(org, options = {})
|
569
650
|
if user = options.delete(:user)
|
570
|
-
get "
|
651
|
+
get "#{Organization.path(org)}/memberships/#{user}", options
|
571
652
|
else
|
572
653
|
get "user/memberships/orgs/#{org}", options
|
573
654
|
end
|
@@ -81,7 +81,7 @@ module Octokit
|
|
81
81
|
# @return [Sawyer::Resource] Project
|
82
82
|
# @see https://developer.github.com/v3/projects/#get-a-project
|
83
83
|
# @example
|
84
|
-
# Octokit.project(
|
84
|
+
# Octokit.project(123942)
|
85
85
|
def project(id, options = {})
|
86
86
|
opts = ensure_api_media_type(:projects, options)
|
87
87
|
get "projects/#{id}", opts
|
@@ -123,7 +123,7 @@ module Octokit
|
|
123
123
|
# @return [Array<Sawyer::Resource>] List of project columns
|
124
124
|
# @see https://developer.github.com/v3/projects/columns/#list-project-columns
|
125
125
|
# @example
|
126
|
-
# @client.project_columns(
|
126
|
+
# @client.project_columns(123942)
|
127
127
|
def project_columns(id, options = {})
|
128
128
|
opts = ensure_api_media_type(:projects, options)
|
129
129
|
paginate "projects/#{id}/columns", opts
|
@@ -138,7 +138,7 @@ module Octokit
|
|
138
138
|
# @return [Sawyer::Resource] Newly created column
|
139
139
|
# @see https://developer.github.com/v3/projects/columns/#create-a-project-column
|
140
140
|
# @example
|
141
|
-
# @client.create_project_column(
|
141
|
+
# @client.create_project_column(123942, "To Dones")
|
142
142
|
def create_project_column(id, name, options = {})
|
143
143
|
opts = ensure_api_media_type(:projects, options)
|
144
144
|
opts[:name] = name
|
@@ -151,7 +151,7 @@ module Octokit
|
|
151
151
|
# @return [Sawyer::Resource] Project column
|
152
152
|
# @see https://developer.github.com/v3/projects/columns/#get-a-project-column
|
153
153
|
# @example
|
154
|
-
# Octokit.project_column(
|
154
|
+
# Octokit.project_column(30294)
|
155
155
|
def project_column(id, options = {})
|
156
156
|
opts = ensure_api_media_type(:projects, options)
|
157
157
|
get "projects/columns/#{id}", opts
|
@@ -198,7 +198,7 @@ module Octokit
|
|
198
198
|
# @return [Sawyer::Resource] Result
|
199
199
|
# @see https://developer.github.com/v3/projects/columns/#move-a-project-column
|
200
200
|
# @example
|
201
|
-
# @client.move_project_column(
|
201
|
+
# @client.move_project_column(30294, "last")
|
202
202
|
def move_project_column(id, position, options = {})
|
203
203
|
opts = ensure_api_media_type(:projects, options)
|
204
204
|
opts[:position] = position
|
@@ -213,7 +213,7 @@ module Octokit
|
|
213
213
|
# @return [Array<Sawyer::Resource>] Cards in the column
|
214
214
|
# @see https://developer.github.com/v3/projects/cards/#list-project-cards
|
215
215
|
# @example
|
216
|
-
# @client.column_cards(
|
216
|
+
# @client.column_cards(30294)
|
217
217
|
def column_cards(id, options = {})
|
218
218
|
opts = ensure_api_media_type(:projects, options)
|
219
219
|
paginate "projects/columns/#{id}/cards", opts
|
@@ -78,14 +78,14 @@ module Octokit
|
|
78
78
|
end
|
79
79
|
|
80
80
|
# Update a pull request
|
81
|
-
# @overload update_pull_request(repo,
|
81
|
+
# @overload update_pull_request(repo, number, title=nil, body=nil, state=nil, options = {})
|
82
82
|
# @deprecated
|
83
83
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
84
84
|
# @param number [Integer] Number of pull request to update.
|
85
85
|
# @param title [String] Title for the pull request.
|
86
86
|
# @param body [String] Body content for pull request. Supports GFM.
|
87
87
|
# @param state [String] State of the pull request. `open` or `closed`.
|
88
|
-
# @overload update_pull_request(repo,
|
88
|
+
# @overload update_pull_request(repo, number, options = {})
|
89
89
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
90
90
|
# @param number [Integer] Number of pull request to update.
|
91
91
|
# @option options [String] :title Title for the pull request.
|
@@ -21,7 +21,7 @@ module Octokit
|
|
21
21
|
# Get number of rate limted requests remaining
|
22
22
|
#
|
23
23
|
# @see https://developer.github.com/v3/rate_limit/#rate-limit
|
24
|
-
# @return [
|
24
|
+
# @return [Integer] Number of requests remaining in this period
|
25
25
|
def rate_limit_remaining(options = {})
|
26
26
|
octokit_warn "Deprecated: Please use .rate_limit.remaining"
|
27
27
|
rate_limit.remaining
|
@@ -41,7 +41,7 @@ module Octokit
|
|
41
41
|
# Refresh rate limit info and get number of rate limted requests remaining
|
42
42
|
#
|
43
43
|
# @see https://developer.github.com/v3/rate_limit/#rate-limit
|
44
|
-
# @return [
|
44
|
+
# @return [Integer] Number of requests remaining in this period
|
45
45
|
def rate_limit_remaining!(options = {})
|
46
46
|
octokit_warn "Deprecated: Please use .rate_limit!.remaining"
|
47
47
|
rate_limit!.remaining
|
@@ -277,6 +277,9 @@ module Octokit
|
|
277
277
|
# Requires authenticated client for private repos.
|
278
278
|
#
|
279
279
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
280
|
+
# @option options [String] :affiliation Filters the return array by affiliation.
|
281
|
+
# Can be one of: <tt>outside</tt> or <tt>all</tt>.
|
282
|
+
# If not specified, defaults to <tt>all</tt>
|
280
283
|
# @return [Array<Sawyer::Resource>] Array of hashes representing collaborating users.
|
281
284
|
# @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
|
282
285
|
# @example
|
@@ -346,6 +349,19 @@ module Octokit
|
|
346
349
|
boolean_from_response :get, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
347
350
|
end
|
348
351
|
|
352
|
+
# Get a user's permission level for a repo.
|
353
|
+
#
|
354
|
+
# Requires authenticated client
|
355
|
+
#
|
356
|
+
# @return [Sawyer::Resource] Hash representing the user's permission level for the given repository
|
357
|
+
# @see https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
|
358
|
+
# @example
|
359
|
+
# @client.permission_level('octokit/octokit.rb', 'lizzhale')
|
360
|
+
def permission_level(repo, collaborator, options={})
|
361
|
+
options = ensure_api_media_type(:org_memberships, options)
|
362
|
+
get "#{Repository.path repo}/collaborators/#{collaborator}/permission", options
|
363
|
+
end
|
364
|
+
|
349
365
|
# List teams for a repo
|
350
366
|
#
|
351
367
|
# Requires authenticated client that is an owner or collaborator of the repo.
|
@@ -0,0 +1,174 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Methods for the Reviews API
|
5
|
+
#
|
6
|
+
# @see https://developer.github.com/v3/reviews/
|
7
|
+
module Reviews
|
8
|
+
|
9
|
+
# List reviews on a pull request
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @param id [Integer] The id of the pull request
|
13
|
+
# @see https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# @client.pull_request_reviews('octokit/octokit.rb', 2)
|
17
|
+
#
|
18
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reviews
|
19
|
+
def pull_request_reviews(repo, id, options = {})
|
20
|
+
options = ensure_api_media_type(:reviews, options)
|
21
|
+
get "#{Repository.path repo}/pulls/#{id}/reviews", options
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get a single review
|
25
|
+
#
|
26
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
27
|
+
# @param number [Integer] The id of the pull request
|
28
|
+
# @param review [Integer] The id of the review
|
29
|
+
# @see https://developer.github.com/v3/pulls/reviews/#get-a-single-review
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# @client.pull_request_review('octokit/octokit.rb', 825, 6505518)
|
33
|
+
#
|
34
|
+
# @return [Sawyer::Resource] Hash representing the review
|
35
|
+
def pull_request_review(repo, number, review, options = {})
|
36
|
+
options = ensure_api_media_type(:reviews, options)
|
37
|
+
get "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
|
38
|
+
end
|
39
|
+
|
40
|
+
# Delete a pending review
|
41
|
+
#
|
42
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
43
|
+
# @param number [Integer] The id of the pull request
|
44
|
+
# @param review [Integer] The id of the review
|
45
|
+
# @see https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# @client.delete_pull_request_review('octokit/octokit.rb', 825, 6505518)
|
49
|
+
#
|
50
|
+
# @return [Sawyer::Resource] Hash representing the deleted review
|
51
|
+
def delete_pull_request_review(repo, number, review, options = {})
|
52
|
+
options = ensure_api_media_type(:reviews, options)
|
53
|
+
delete "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
|
54
|
+
end
|
55
|
+
|
56
|
+
# Get comments for a single review
|
57
|
+
#
|
58
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
59
|
+
# @param number [Integer] The id of the pull request
|
60
|
+
# @param review [Integer] The id of the review
|
61
|
+
# @see https://developer.github.com/v3/pulls/reviews/#get-comments-for-a-single-review
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# @client.pull_request_review_comments('octokit/octokit.rb', 825, 6505518)
|
65
|
+
#
|
66
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the review comments
|
67
|
+
def pull_request_review_comments(repo, number, review, options = {})
|
68
|
+
options = ensure_api_media_type(:reviews, options)
|
69
|
+
get "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/comments", options
|
70
|
+
end
|
71
|
+
|
72
|
+
# Create a pull request review
|
73
|
+
#
|
74
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
75
|
+
# @param id [Integer] The id of the pull request
|
76
|
+
# @param options [Hash] Method options
|
77
|
+
# @option options [String] :event The review action (event) to perform;
|
78
|
+
# can be one of APPROVE, REQUEST_CHANGES, or COMMENT.
|
79
|
+
# If left blank, the review is left PENDING.
|
80
|
+
# @option options [String] :body The body text of the pull request review
|
81
|
+
# @option options [Array<Hash>] :comments Comments part of the review
|
82
|
+
# @option comments [String] :path The path to the file being commented on
|
83
|
+
# @option comments [Integer] :position The position in the file to be commented on
|
84
|
+
# @option comments [String] :body Body of the comment
|
85
|
+
# @see https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review
|
86
|
+
#
|
87
|
+
# @example
|
88
|
+
# comments = [
|
89
|
+
# { path: '.travis.yml', position: 10, body: 'ruby-head is under development that is not stable.' },
|
90
|
+
# { path: '.travis.yml', position: 32, body: 'ruby-head is also required in thervm section.' },
|
91
|
+
# ]
|
92
|
+
# options = { event: 'REQUEST_CHANGES', comments: comments }
|
93
|
+
# @client.create_pull_request_review('octokit/octokit.rb', 844, options)
|
94
|
+
#
|
95
|
+
# @return [Sawyer::Resource>] Hash respresenting the review
|
96
|
+
def create_pull_request_review(repo, id, options = {})
|
97
|
+
options = ensure_api_media_type(:reviews, options)
|
98
|
+
post "#{Repository.path repo}/pulls/#{id}/reviews", options
|
99
|
+
end
|
100
|
+
|
101
|
+
# Submit a pull request review
|
102
|
+
#
|
103
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
104
|
+
# @param number [Integer] The id of the pull request
|
105
|
+
# @param review [Integer] The id of the review
|
106
|
+
# @param event [String] The review action (event) to perform; can be one of
|
107
|
+
# APPROVE, REQUEST_CHANGES, or COMMENT.
|
108
|
+
# @param options [Hash] Method options
|
109
|
+
# @option options [String] :body The body text of the pull request review
|
110
|
+
# @see https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# @client.submit_pull_request_review('octokit/octokit.rb', 825, 6505518,
|
114
|
+
# 'APPROVE', body: 'LGTM!')
|
115
|
+
#
|
116
|
+
# @return [Sawyer::Resource] Hash respresenting the review
|
117
|
+
def submit_pull_request_review(repo, number, review, event, options = {})
|
118
|
+
options = options.merge(event: event)
|
119
|
+
options = ensure_api_media_type(:reviews, options)
|
120
|
+
post "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/events", options
|
121
|
+
end
|
122
|
+
|
123
|
+
# Dismiss a pull request review
|
124
|
+
#
|
125
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
126
|
+
# @param number [Integer] The id of the pull request
|
127
|
+
# @param review [Integer] The id of the review
|
128
|
+
# @param message [String] The message for the pull request review dismissal
|
129
|
+
# @see https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review
|
130
|
+
#
|
131
|
+
# @example
|
132
|
+
# @client.dismiss_pull_request_review('octokit/octokit.rb', 825, 6505518)
|
133
|
+
#
|
134
|
+
# @return [Sawyer::Resource] Hash representing the dismissed review
|
135
|
+
def dismiss_pull_request_review(repo, number, review, message, options = {})
|
136
|
+
options = options.merge(message: message)
|
137
|
+
options = ensure_api_media_type(:reviews, options)
|
138
|
+
put "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/dismissals", options
|
139
|
+
end
|
140
|
+
|
141
|
+
# List review requests
|
142
|
+
#
|
143
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
144
|
+
# @param id [Integer] The id of the pull request
|
145
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#list-review-requests
|
146
|
+
#
|
147
|
+
# @example
|
148
|
+
# @client.pull_request_review_requests('octokit/octokit.rb', 2)
|
149
|
+
#
|
150
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the review requests
|
151
|
+
def pull_request_review_requests(repo, id, options = {})
|
152
|
+
options = ensure_api_media_type(:reviews, options)
|
153
|
+
get "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
|
154
|
+
end
|
155
|
+
|
156
|
+
# Create a review request
|
157
|
+
#
|
158
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
159
|
+
# @param id [Integer] The id of the pull request
|
160
|
+
# @param reviewers [Array<String>] An array of user logins that will be requested
|
161
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#create-a-review-request
|
162
|
+
#
|
163
|
+
# @example
|
164
|
+
# @client.request_pull_request_review('octokit/octokit.rb', 2, ['soudy'])
|
165
|
+
#
|
166
|
+
# @return [Sawyer::Resource>] Hash respresenting the pull request
|
167
|
+
def request_pull_request_review(repo, id, reviewers, options = {})
|
168
|
+
options = options.merge(reviewers: reviewers)
|
169
|
+
options = ensure_api_media_type(:reviews, options)
|
170
|
+
post "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
@@ -12,8 +12,8 @@ module Octokit
|
|
12
12
|
# @param options [Hash] Sort and pagination options
|
13
13
|
# @option options [String] :sort Sort field
|
14
14
|
# @option options [String] :order Sort order (asc or desc)
|
15
|
-
# @option options [
|
16
|
-
# @option options [
|
15
|
+
# @option options [Integer] :page Page of paginated results
|
16
|
+
# @option options [Integer] :per_page Number of items per page
|
17
17
|
# @return [Sawyer::Resource] Search results object
|
18
18
|
# @see https://developer.github.com/v3/search/#search-code
|
19
19
|
def search_code(query, options = {})
|
@@ -26,8 +26,8 @@ module Octokit
|
|
26
26
|
# @param options [Hash] Sort and pagination options
|
27
27
|
# @option options [String] :sort Sort field
|
28
28
|
# @option options [String] :order Sort order (asc or desc)
|
29
|
-
# @option options [
|
30
|
-
# @option options [
|
29
|
+
# @option options [Integer] :page Page of paginated results
|
30
|
+
# @option options [Integer] :per_page Number of items per page
|
31
31
|
# @return [Sawyer::Resource] Search results object
|
32
32
|
# @see https://developer.github.com/v3/search/#search-issues
|
33
33
|
def search_issues(query, options = {})
|
@@ -40,8 +40,8 @@ module Octokit
|
|
40
40
|
# @param options [Hash] Sort and pagination options
|
41
41
|
# @option options [String] :sort Sort field
|
42
42
|
# @option options [String] :order Sort order (asc or desc)
|
43
|
-
# @option options [
|
44
|
-
# @option options [
|
43
|
+
# @option options [Integer] :page Page of paginated results
|
44
|
+
# @option options [Integer] :per_page Number of items per page
|
45
45
|
# @return [Sawyer::Resource] Search results object
|
46
46
|
# @see https://developer.github.com/v3/search/#search-repositories
|
47
47
|
def search_repositories(query, options = {})
|
@@ -55,8 +55,8 @@ module Octokit
|
|
55
55
|
# @param options [Hash] Sort and pagination options
|
56
56
|
# @option options [String] :sort Sort field
|
57
57
|
# @option options [String] :order Sort order (asc or desc)
|
58
|
-
# @option options [
|
59
|
-
# @option options [
|
58
|
+
# @option options [Integer] :page Page of paginated results
|
59
|
+
# @option options [Integer] :per_page Number of items per page
|
60
60
|
# @return [Sawyer::Resource] Search results object
|
61
61
|
# @see https://developer.github.com/v3/search/#search-users
|
62
62
|
def search_users(query, options = {})
|
@@ -132,7 +132,7 @@ module Octokit
|
|
132
132
|
#
|
133
133
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
134
134
|
# @param options [Hash]
|
135
|
-
# @option options [
|
135
|
+
# @option options [Integer] :page Page of paginated results
|
136
136
|
# @return [Array<Sawyer::Resource>] Array of hashes representing files over 100MB.
|
137
137
|
# @see https://developer.github.com/v3/migration/source_imports/#get-large-files
|
138
138
|
#
|
@@ -39,7 +39,7 @@ module Octokit
|
|
39
39
|
# @return [Sawyer::Resource] A status
|
40
40
|
# @see https://developer.github.com/v3/repos/statuses/#create-a-status
|
41
41
|
def create_status(repo, sha, state, options = {})
|
42
|
-
options.merge
|
42
|
+
options = options.merge(:state => state)
|
43
43
|
post "#{Repository.path repo}/statuses/#{sha}", options
|
44
44
|
end
|
45
45
|
end
|
data/lib/octokit/client/users.rb
CHANGED
@@ -44,7 +44,7 @@ module Octokit
|
|
44
44
|
# @example
|
45
45
|
# Octokit.exchange_code_for_token('aaaa', 'xxxx', 'yyyy', {:accept => 'application/json'})
|
46
46
|
def exchange_code_for_token(code, app_id = client_id, app_secret = client_secret, options = {})
|
47
|
-
options.merge
|
47
|
+
options = options.merge({
|
48
48
|
:code => code,
|
49
49
|
:client_id => app_id,
|
50
50
|
:client_secret => app_secret,
|
@@ -53,6 +53,7 @@ module Octokit
|
|
53
53
|
:accept => 'application/json'
|
54
54
|
}
|
55
55
|
})
|
56
|
+
|
56
57
|
post "#{web_endpoint}login/oauth/access_token", options
|
57
58
|
end
|
58
59
|
|
data/lib/octokit/configurable.rb
CHANGED
@@ -10,6 +10,9 @@ module Octokit
|
|
10
10
|
# @return [String] Base URL for API requests. default: https://api.github.com/
|
11
11
|
# @!attribute auto_paginate
|
12
12
|
# @return [Boolean] Auto fetch next page of results until rate limit reached
|
13
|
+
# @!attribute [w] bearer_token
|
14
|
+
# @see https://developer.github.com/early-access/integrations/authentication/#as-an-integration
|
15
|
+
# @return [String] JWT bearer token for authentication
|
13
16
|
# @!attribute client_id
|
14
17
|
# @see https://developer.github.com/v3/oauth/
|
15
18
|
# @return [String] Configure OAuth app key
|
@@ -47,7 +50,7 @@ module Octokit
|
|
47
50
|
# @!attribute web_endpoint
|
48
51
|
# @return [String] Base URL for web URLs. default: https://github.com/
|
49
52
|
|
50
|
-
attr_accessor :access_token, :auto_paginate, :client_id,
|
53
|
+
attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
|
51
54
|
:client_secret, :default_media_type, :connection_options,
|
52
55
|
:middleware, :netrc, :netrc_file,
|
53
56
|
:per_page, :proxy, :user_agent
|
@@ -63,6 +66,7 @@ module Octokit
|
|
63
66
|
:access_token,
|
64
67
|
:api_endpoint,
|
65
68
|
:auto_paginate,
|
69
|
+
:bearer_token,
|
66
70
|
:client_id,
|
67
71
|
:client_secret,
|
68
72
|
:connection_options,
|
data/lib/octokit/connection.rb
CHANGED
@@ -76,7 +76,7 @@ module Octokit
|
|
76
76
|
# contains the latest response.
|
77
77
|
# @return [Sawyer::Resource]
|
78
78
|
def paginate(url, options = {}, &block)
|
79
|
-
opts = parse_query_and_convenience_headers(options
|
79
|
+
opts = parse_query_and_convenience_headers(options)
|
80
80
|
if @auto_paginate || @per_page
|
81
81
|
opts[:query][:per_page] ||= @per_page || (@auto_paginate ? 100 : nil)
|
82
82
|
end
|
@@ -110,6 +110,8 @@ module Octokit
|
|
110
110
|
http.basic_auth(@login, @password)
|
111
111
|
elsif token_authenticated?
|
112
112
|
http.authorization 'token', @access_token
|
113
|
+
elsif bearer_authenticated?
|
114
|
+
http.authorization 'Bearer', @bearer_token
|
113
115
|
elsif application_authenticated?
|
114
116
|
http.params = http.params.merge application_authentication
|
115
117
|
end
|
@@ -179,6 +181,7 @@ module Octokit
|
|
179
181
|
end
|
180
182
|
|
181
183
|
def parse_query_and_convenience_headers(options)
|
184
|
+
options = options.dup
|
182
185
|
headers = options.delete(:headers) { Hash.new }
|
183
186
|
CONVENIENCE_HEADERS.each do |h|
|
184
187
|
if header = options.delete(h)
|
data/lib/octokit/default.rb
CHANGED
@@ -57,6 +57,12 @@ module Octokit
|
|
57
57
|
ENV['OCTOKIT_AUTO_PAGINATE']
|
58
58
|
end
|
59
59
|
|
60
|
+
# Default bearer token from ENV
|
61
|
+
# @return [String]
|
62
|
+
def bearer_token
|
63
|
+
ENV['OCTOKIT_BEARER_TOKEN']
|
64
|
+
end
|
65
|
+
|
60
66
|
# Default OAuth app key from ENV
|
61
67
|
# @return [String]
|
62
68
|
def client_id
|
@@ -118,7 +124,7 @@ module Octokit
|
|
118
124
|
end
|
119
125
|
|
120
126
|
# Default pagination page size from ENV
|
121
|
-
# @return [
|
127
|
+
# @return [Integer] Page size
|
122
128
|
def per_page
|
123
129
|
page_size = ENV['OCTOKIT_PER_PAGE']
|
124
130
|
|
data/lib/octokit/error.rb
CHANGED
@@ -138,8 +138,12 @@ module Octokit
|
|
138
138
|
return nil unless data.is_a?(Hash) && !Array(data[:errors]).empty?
|
139
139
|
|
140
140
|
summary = "\nError summary:\n"
|
141
|
-
summary << data[:errors].map do |
|
142
|
-
|
141
|
+
summary << data[:errors].map do |error|
|
142
|
+
if error.is_a? Hash
|
143
|
+
error.map { |k,v| " #{k}: #{v}" }
|
144
|
+
else
|
145
|
+
" #{error}"
|
146
|
+
end
|
143
147
|
end.join("\n")
|
144
148
|
|
145
149
|
summary
|
data/lib/octokit/gist.rb
CHANGED
@@ -49,7 +49,7 @@ module Octokit
|
|
49
49
|
# Public: Initialize the middleware.
|
50
50
|
#
|
51
51
|
# options - An options Hash (default: {}):
|
52
|
-
# :limit - A
|
52
|
+
# :limit - A Integer redirect limit (default: 3).
|
53
53
|
def initialize(app, options = {})
|
54
54
|
super(app)
|
55
55
|
@options = options
|
data/lib/octokit/preview.rb
CHANGED
@@ -13,7 +13,10 @@ module Octokit
|
|
13
13
|
:issue_timelines => 'application/vnd.github.mockingbird-preview+json'.freeze,
|
14
14
|
:pages => 'application/vnd.github.mister-fantastic-preview+json'.freeze,
|
15
15
|
:projects => 'application/vnd.github.inertia-preview+json'.freeze,
|
16
|
-
:traffic => 'application/vnd.github.spiderman-preview'.freeze
|
16
|
+
:traffic => 'application/vnd.github.spiderman-preview'.freeze,
|
17
|
+
:org_membership => 'application/vnd.github.korra-preview'.freeze,
|
18
|
+
:reviews => 'application/vnd.github.black-cat-preview'.freeze,
|
19
|
+
:integrations => 'application/vnd.github.machine-man-preview+json'.freeze
|
17
20
|
}
|
18
21
|
|
19
22
|
def ensure_api_media_type(type, options)
|
data/lib/octokit/rate_limit.rb
CHANGED
@@ -3,13 +3,13 @@ module Octokit
|
|
3
3
|
# Class for API Rate Limit info
|
4
4
|
#
|
5
5
|
# @!attribute [w] limit
|
6
|
-
# @return [
|
6
|
+
# @return [Integer] Max tries per rate limit period
|
7
7
|
# @!attribute [w] remaining
|
8
|
-
# @return [
|
8
|
+
# @return [Integer] Remaining tries per rate limit period
|
9
9
|
# @!attribute [w] resets_at
|
10
10
|
# @return [Time] Indicates when rate limit resets
|
11
11
|
# @!attribute [w] resets_in
|
12
|
-
# @return [
|
12
|
+
# @return [Integer] Number of seconds when rate limit resets
|
13
13
|
#
|
14
14
|
# @see https://developer.github.com/v3/#rate-limiting
|
15
15
|
class RateLimit < Struct.new(:limit, :remaining, :resets_at, :resets_in)
|
data/lib/octokit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/octokit/client/gists.rb
|
78
78
|
- lib/octokit/client/gitignore.rb
|
79
79
|
- lib/octokit/client/hooks.rb
|
80
|
+
- lib/octokit/client/integrations.rb
|
80
81
|
- lib/octokit/client/issues.rb
|
81
82
|
- lib/octokit/client/labels.rb
|
82
83
|
- lib/octokit/client/legacy_search.rb
|
@@ -97,6 +98,7 @@ files:
|
|
97
98
|
- lib/octokit/client/releases.rb
|
98
99
|
- lib/octokit/client/repositories.rb
|
99
100
|
- lib/octokit/client/repository_invitations.rb
|
101
|
+
- lib/octokit/client/reviews.rb
|
100
102
|
- lib/octokit/client/say.rb
|
101
103
|
- lib/octokit/client/search.rb
|
102
104
|
- lib/octokit/client/service_status.rb
|