octokit 4.25.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +3 -1
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +21 -3
- data/lib/octokit/client/actions_workflows.rb +25 -1
- data/lib/octokit/client/apps.rb +15 -15
- data/lib/octokit/client/community_profile.rb +0 -1
- data/lib/octokit/client/events.rb +0 -1
- data/lib/octokit/client/hooks.rb +0 -10
- data/lib/octokit/client/issues.rb +0 -1
- data/lib/octokit/client/licenses.rb +0 -3
- data/lib/octokit/client/oauth_applications.rb +0 -4
- data/lib/octokit/client/organizations.rb +41 -13
- data/lib/octokit/client/pages.rb +2 -4
- data/lib/octokit/client/projects.rb +26 -45
- data/lib/octokit/client/pub_sub_hubbub.rb +7 -7
- data/lib/octokit/client/pull_requests.rb +11 -0
- data/lib/octokit/client/reactions.rb +4 -9
- data/lib/octokit/client/refs.rb +1 -3
- data/lib/octokit/client/repositories.rb +13 -33
- data/lib/octokit/client/reviews.rb +2 -2
- data/lib/octokit/client/search.rb +14 -1
- data/lib/octokit/client/source_import.rb +3 -8
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +4 -8
- data/lib/octokit/client/users.rb +0 -7
- data/lib/octokit/client.rb +6 -4
- data/lib/octokit/configurable.rb +2 -4
- data/lib/octokit/connection.rb +1 -1
- data/lib/octokit/default.rb +18 -18
- data/lib/octokit/error.rb +21 -14
- data/lib/octokit/middleware/follow_redirects.rb +1 -1
- data/lib/octokit/rate_limit.rb +1 -1
- data/lib/octokit/repository.rb +1 -0
- data/lib/octokit/version.rb +3 -3
- data/octokit.gemspec +1 -1
- metadata +10 -9
- data/lib/octokit/client/authorizations.rb +0 -185
- data/lib/octokit/preview.rb +0 -46
@@ -4,7 +4,7 @@ module Octokit
|
|
4
4
|
class Client
|
5
5
|
# Methods for Projects API
|
6
6
|
#
|
7
|
-
# @see https://
|
7
|
+
# @see https://docs.github.com/en/rest/projects
|
8
8
|
module Projects
|
9
9
|
# List projects for a repository
|
10
10
|
#
|
@@ -16,8 +16,7 @@ module Octokit
|
|
16
16
|
# @example
|
17
17
|
# @client.projects('octokit/octokit.rb')
|
18
18
|
def projects(repo, options = {})
|
19
|
-
|
20
|
-
paginate "#{Repository.path repo}/projects", opts
|
19
|
+
paginate "#{Repository.path repo}/projects", options
|
21
20
|
end
|
22
21
|
|
23
22
|
# Create a project
|
@@ -35,9 +34,8 @@ module Octokit
|
|
35
34
|
# @example Create project with name and body
|
36
35
|
# @client.create_project('octokit/octokit.rb', 'bugs be gone', body: 'Fix all the bugs @joeyw creates')
|
37
36
|
def create_project(repo, name, options = {})
|
38
|
-
|
39
|
-
|
40
|
-
post "#{Repository.path repo}/projects", opts
|
37
|
+
options[:name] = name
|
38
|
+
post "#{Repository.path repo}/projects", options
|
41
39
|
end
|
42
40
|
|
43
41
|
# List organization projects
|
@@ -50,8 +48,7 @@ module Octokit
|
|
50
48
|
# @example
|
51
49
|
# @client.org_projects("octokit")
|
52
50
|
def org_projects(org, options = {})
|
53
|
-
|
54
|
-
paginate "orgs/#{org}/projects", opts
|
51
|
+
paginate "orgs/#{org}/projects", options
|
55
52
|
end
|
56
53
|
alias organization_projects org_projects
|
57
54
|
|
@@ -69,9 +66,8 @@ module Octokit
|
|
69
66
|
# @example Create a project with name and body
|
70
67
|
# @client.create_org_project("octokit", "octocan", body: 'Improve clients')
|
71
68
|
def create_org_project(org, name, options = {})
|
72
|
-
|
73
|
-
|
74
|
-
post "orgs/#{org}/projects", opts
|
69
|
+
options[:name] = name
|
70
|
+
post "orgs/#{org}/projects", options
|
75
71
|
end
|
76
72
|
alias create_organization_project create_org_project
|
77
73
|
|
@@ -83,8 +79,7 @@ module Octokit
|
|
83
79
|
# @example
|
84
80
|
# Octokit.project(123942)
|
85
81
|
def project(id, options = {})
|
86
|
-
|
87
|
-
get "projects/#{id}", opts
|
82
|
+
get "projects/#{id}", options
|
88
83
|
end
|
89
84
|
|
90
85
|
# Update a project
|
@@ -99,8 +94,7 @@ module Octokit
|
|
99
94
|
# @example Update project name
|
100
95
|
# @client.update_project(123942, name: 'New name')
|
101
96
|
def update_project(id, options = {})
|
102
|
-
|
103
|
-
patch "projects/#{id}", opts
|
97
|
+
patch "projects/#{id}", options
|
104
98
|
end
|
105
99
|
|
106
100
|
# Delete a project
|
@@ -113,8 +107,7 @@ module Octokit
|
|
113
107
|
# @example
|
114
108
|
# @client.delete_project(123942)
|
115
109
|
def delete_project(id, options = {})
|
116
|
-
|
117
|
-
boolean_from_response :delete, "projects/#{id}", opts
|
110
|
+
boolean_from_response :delete, "projects/#{id}", options
|
118
111
|
end
|
119
112
|
|
120
113
|
# List project columns
|
@@ -125,8 +118,7 @@ module Octokit
|
|
125
118
|
# @example
|
126
119
|
# @client.project_columns(123942)
|
127
120
|
def project_columns(id, options = {})
|
128
|
-
|
129
|
-
paginate "projects/#{id}/columns", opts
|
121
|
+
paginate "projects/#{id}/columns", options
|
130
122
|
end
|
131
123
|
|
132
124
|
# Create a project column
|
@@ -140,9 +132,8 @@ module Octokit
|
|
140
132
|
# @example
|
141
133
|
# @client.create_project_column(123942, "To Dones")
|
142
134
|
def create_project_column(id, name, options = {})
|
143
|
-
|
144
|
-
|
145
|
-
post "projects/#{id}/columns", opts
|
135
|
+
options[:name] = name
|
136
|
+
post "projects/#{id}/columns", options
|
146
137
|
end
|
147
138
|
|
148
139
|
# Get a project column by ID
|
@@ -153,8 +144,7 @@ module Octokit
|
|
153
144
|
# @example
|
154
145
|
# Octokit.project_column(30294)
|
155
146
|
def project_column(id, options = {})
|
156
|
-
|
157
|
-
get "projects/columns/#{id}", opts
|
147
|
+
get "projects/columns/#{id}", options
|
158
148
|
end
|
159
149
|
|
160
150
|
# Update a project column
|
@@ -168,9 +158,8 @@ module Octokit
|
|
168
158
|
# @example
|
169
159
|
# @client.update_project_column(30294, "new column name")
|
170
160
|
def update_project_column(id, name, options = {})
|
171
|
-
|
172
|
-
|
173
|
-
patch "projects/columns/#{id}", opts
|
161
|
+
options[:name] = name
|
162
|
+
patch "projects/columns/#{id}", options
|
174
163
|
end
|
175
164
|
|
176
165
|
# Delete a project column
|
@@ -183,8 +172,7 @@ module Octokit
|
|
183
172
|
# @example
|
184
173
|
# @client.delete_project_column(30294)
|
185
174
|
def delete_project_column(id, options = {})
|
186
|
-
|
187
|
-
boolean_from_response :delete, "projects/columns/#{id}", opts
|
175
|
+
boolean_from_response :delete, "projects/columns/#{id}", options
|
188
176
|
end
|
189
177
|
|
190
178
|
# Move a project column
|
@@ -200,9 +188,8 @@ module Octokit
|
|
200
188
|
# @example
|
201
189
|
# @client.move_project_column(30294, "last")
|
202
190
|
def move_project_column(id, position, options = {})
|
203
|
-
|
204
|
-
|
205
|
-
post "projects/columns/#{id}/moves", opts
|
191
|
+
options[:position] = position
|
192
|
+
post "projects/columns/#{id}/moves", options
|
206
193
|
end
|
207
194
|
|
208
195
|
# List columns cards
|
@@ -215,8 +202,7 @@ module Octokit
|
|
215
202
|
# @example
|
216
203
|
# @client.column_cards(30294)
|
217
204
|
def column_cards(id, options = {})
|
218
|
-
|
219
|
-
paginate "projects/columns/#{id}/cards", opts
|
205
|
+
paginate "projects/columns/#{id}/cards", options
|
220
206
|
end
|
221
207
|
|
222
208
|
# Create project card
|
@@ -238,8 +224,7 @@ module Octokit
|
|
238
224
|
# @example Create a project card for an repository issue
|
239
225
|
# @client.create_project_card(123495, content_id: 1, content_type: 'Issue')
|
240
226
|
def create_project_card(id, options = {})
|
241
|
-
|
242
|
-
post "projects/columns/#{id}/cards", opts
|
227
|
+
post "projects/columns/#{id}/cards", options
|
243
228
|
end
|
244
229
|
|
245
230
|
# Get a project card
|
@@ -252,8 +237,7 @@ module Octokit
|
|
252
237
|
# @example
|
253
238
|
# @client.project_card(123495)
|
254
239
|
def project_card(id, options = {})
|
255
|
-
|
256
|
-
get "projects/columns/cards/#{id}", opts
|
240
|
+
get "projects/columns/cards/#{id}", options
|
257
241
|
end
|
258
242
|
|
259
243
|
# Update a project card
|
@@ -269,8 +253,7 @@ module Octokit
|
|
269
253
|
# @example
|
270
254
|
# @client.update_project_card(12345, note: 'new note')
|
271
255
|
def update_project_card(id, options = {})
|
272
|
-
|
273
|
-
patch "projects/columns/cards/#{id}", opts
|
256
|
+
patch "projects/columns/cards/#{id}", options
|
274
257
|
end
|
275
258
|
|
276
259
|
# Move a project card
|
@@ -290,9 +273,8 @@ module Octokit
|
|
290
273
|
# @example Move a card to the top of another column
|
291
274
|
# @client.move_project_card(123495, 'top', column_id: 59402)
|
292
275
|
def move_project_card(id, position, options = {})
|
293
|
-
|
294
|
-
|
295
|
-
post "projects/columns/cards/#{id}/moves", opts
|
276
|
+
options[:position] = position
|
277
|
+
post "projects/columns/cards/#{id}/moves", options
|
296
278
|
end
|
297
279
|
|
298
280
|
# Delete a project card
|
@@ -305,8 +287,7 @@ module Octokit
|
|
305
287
|
# @example
|
306
288
|
# @client.delete_project_card(123495)
|
307
289
|
def delete_project_card(id, options = {})
|
308
|
-
|
309
|
-
boolean_from_response :delete, "projects/columns/cards/#{id}", opts
|
290
|
+
boolean_from_response :delete, "projects/columns/cards/#{id}", options
|
310
291
|
end
|
311
292
|
end # Projects
|
312
293
|
end
|
@@ -18,11 +18,11 @@ module Octokit
|
|
18
18
|
# client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
|
19
19
|
def subscribe(topic, callback, secret = nil)
|
20
20
|
options = {
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
'hub.callback': callback,
|
22
|
+
'hub.mode': 'subscribe',
|
23
|
+
'hub.topic': topic
|
24
24
|
}
|
25
|
-
options.merge!(
|
25
|
+
options.merge!('hub.secret': secret) unless secret.nil?
|
26
26
|
|
27
27
|
response = pub_sub_hubbub_request(options)
|
28
28
|
|
@@ -40,9 +40,9 @@ module Octokit
|
|
40
40
|
# client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
|
41
41
|
def unsubscribe(topic, callback)
|
42
42
|
options = {
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
'hub.callback': callback,
|
44
|
+
'hub.mode': 'unsubscribe',
|
45
|
+
'hub.topic': topic
|
46
46
|
}
|
47
47
|
response = pub_sub_hubbub_request(options)
|
48
48
|
|
@@ -276,6 +276,17 @@ module Octokit
|
|
276
276
|
end
|
277
277
|
alias pull_files pull_request_files
|
278
278
|
|
279
|
+
# Update a pull request branch
|
280
|
+
#
|
281
|
+
# @see https://developer.github.com/v3/pulls/#update-a-pull-request-branch
|
282
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
283
|
+
# @param number [Integer] Number of pull request
|
284
|
+
# @param options [Hash] Optional parameters (e.g. expected_head_sha)
|
285
|
+
# @return [Boolean] True if the pull request branch has been updated
|
286
|
+
def update_pull_request_branch(repo, number, options = {})
|
287
|
+
boolean_from_response(:put, "#{Repository.path repo}/pulls/#{number}/update-branch", options)
|
288
|
+
end
|
289
|
+
|
279
290
|
# Merge a pull request
|
280
291
|
#
|
281
292
|
# @see https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
|
@@ -17,7 +17,6 @@ module Octokit
|
|
17
17
|
#
|
18
18
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
19
19
|
def commit_comment_reactions(repo, id, options = {})
|
20
|
-
options = ensure_api_media_type(:reactions, options)
|
21
20
|
get "#{Repository.path repo}/comments/#{id}/reactions", options
|
22
21
|
end
|
23
22
|
|
@@ -34,7 +33,7 @@ module Octokit
|
|
34
33
|
#
|
35
34
|
# @return [<Sawyer::Resource>] Hash representing the reaction
|
36
35
|
def create_commit_comment_reaction(repo, id, reaction, options = {})
|
37
|
-
options =
|
36
|
+
options = options.merge(content: reaction)
|
38
37
|
post "#{Repository.path repo}/comments/#{id}/reactions", options
|
39
38
|
end
|
40
39
|
|
@@ -49,7 +48,6 @@ module Octokit
|
|
49
48
|
#
|
50
49
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
51
50
|
def issue_reactions(repo, number, options = {})
|
52
|
-
options = ensure_api_media_type(:reactions, options)
|
53
51
|
get "#{Repository.path repo}/issues/#{number}/reactions", options
|
54
52
|
end
|
55
53
|
|
@@ -67,7 +65,7 @@ module Octokit
|
|
67
65
|
#
|
68
66
|
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
69
67
|
def create_issue_reaction(repo, number, reaction, options = {})
|
70
|
-
options =
|
68
|
+
options = options.merge(content: reaction)
|
71
69
|
post "#{Repository.path repo}/issues/#{number}/reactions", options
|
72
70
|
end
|
73
71
|
|
@@ -83,7 +81,6 @@ module Octokit
|
|
83
81
|
#
|
84
82
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
85
83
|
def issue_comment_reactions(repo, id, options = {})
|
86
|
-
options = ensure_api_media_type(:reactions, options)
|
87
84
|
get "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
88
85
|
end
|
89
86
|
|
@@ -101,7 +98,7 @@ module Octokit
|
|
101
98
|
#
|
102
99
|
# @return [<Sawyer::Resource>] Hashes representing the reaction.
|
103
100
|
def create_issue_comment_reaction(repo, id, reaction, options = {})
|
104
|
-
options =
|
101
|
+
options = options.merge(content: reaction)
|
105
102
|
post "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
106
103
|
end
|
107
104
|
|
@@ -117,7 +114,6 @@ module Octokit
|
|
117
114
|
#
|
118
115
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
119
116
|
def pull_request_review_comment_reactions(repo, id, options = {})
|
120
|
-
options = ensure_api_media_type(:reactions, options)
|
121
117
|
get "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
122
118
|
end
|
123
119
|
|
@@ -135,7 +131,7 @@ module Octokit
|
|
135
131
|
#
|
136
132
|
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
137
133
|
def create_pull_request_review_comment_reaction(repo, id, reaction, options = {})
|
138
|
-
options =
|
134
|
+
options = options.merge(content: reaction)
|
139
135
|
post "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
140
136
|
end
|
141
137
|
|
@@ -150,7 +146,6 @@ module Octokit
|
|
150
146
|
#
|
151
147
|
# @return [Boolean] Return true if reaction was deleted, false otherwise.
|
152
148
|
def delete_reaction(id, options = {})
|
153
|
-
options = ensure_api_media_type(:reactions, options)
|
154
149
|
boolean_from_response :delete, "reactions/#{id}", options
|
155
150
|
end
|
156
151
|
end
|
data/lib/octokit/client/refs.rb
CHANGED
@@ -77,9 +77,7 @@ module Octokit
|
|
77
77
|
# @see https://developer.github.com/v3/git/refs/#update-a-reference
|
78
78
|
# @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
79
79
|
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
|
80
|
-
|
81
|
-
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
|
82
|
-
def update_ref(repo, ref, sha, force = true, options = {})
|
80
|
+
def update_ref(repo, ref, sha, force = false, options = {})
|
83
81
|
parameters = {
|
84
82
|
sha: sha,
|
85
83
|
force: force
|
@@ -13,9 +13,7 @@ module Octokit
|
|
13
13
|
# @return [Boolean]
|
14
14
|
def repository?(repo, options = {})
|
15
15
|
!!repository(repo, options)
|
16
|
-
rescue Octokit::InvalidRepository
|
17
|
-
false
|
18
|
-
rescue Octokit::NotFound
|
16
|
+
rescue Octokit::InvalidRepository, Octokit::NotFound
|
19
17
|
false
|
20
18
|
end
|
21
19
|
|
@@ -47,9 +45,6 @@ module Octokit
|
|
47
45
|
# @return [Sawyer::Resource] Repository information
|
48
46
|
def edit_repository(repo, options = {})
|
49
47
|
repo = Repository.new(repo)
|
50
|
-
if options.include? :is_template
|
51
|
-
options = ensure_api_media_type(:template_repositories, options)
|
52
|
-
end
|
53
48
|
options[:name] ||= repo.name
|
54
49
|
patch "repos/#{repo}", options
|
55
50
|
end
|
@@ -160,9 +155,6 @@ module Octokit
|
|
160
155
|
opts = options.dup
|
161
156
|
organization = opts.delete :organization
|
162
157
|
opts.merge! name: name
|
163
|
-
if opts.include? :is_template
|
164
|
-
opts = ensure_api_media_type(:template_repositories, opts)
|
165
|
-
end
|
166
158
|
|
167
159
|
if organization.nil?
|
168
160
|
post 'user/repos', opts
|
@@ -195,7 +187,6 @@ module Octokit
|
|
195
187
|
# @param options [Array<Integer>] :team_ids ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories.
|
196
188
|
# @return [Sawyer::Resource] Repository info for the transferred repository
|
197
189
|
def transfer_repository(repo, new_owner, options = {})
|
198
|
-
options = ensure_api_media_type(:transfer_repository, options)
|
199
190
|
post "#{Repository.path repo}/transfer", options.merge({ new_owner: new_owner })
|
200
191
|
end
|
201
192
|
alias transfer_repo transfer_repository
|
@@ -211,7 +202,6 @@ module Octokit
|
|
211
202
|
# @return [Sawyer::Resource] Repository info for the new repository
|
212
203
|
def create_repository_from_template(repo, name, options = {})
|
213
204
|
options.merge! name: name
|
214
|
-
options = ensure_api_media_type(:template_repositories, options)
|
215
205
|
post "#{Repository.path repo}/generate", options
|
216
206
|
end
|
217
207
|
alias create_repo_from_template create_repository_from_template
|
@@ -431,8 +421,7 @@ module Octokit
|
|
431
421
|
# @example List topics for octokit/octokit.rb
|
432
422
|
# client.topics('octokit/octokit.rb')
|
433
423
|
def topics(repo, options = {})
|
434
|
-
|
435
|
-
paginate "#{Repository.path repo}/topics", opts
|
424
|
+
paginate "#{Repository.path repo}/topics", options
|
436
425
|
end
|
437
426
|
|
438
427
|
# Replace all topics for a repository
|
@@ -448,8 +437,7 @@ module Octokit
|
|
448
437
|
# @example Clear all topics for octokit/octokit.rb
|
449
438
|
# client.replace_all_topics('octokit/octokit.rb', [])
|
450
439
|
def replace_all_topics(repo, names, options = {})
|
451
|
-
|
452
|
-
put "#{Repository.path repo}/topics", opts.merge(names: names)
|
440
|
+
put "#{Repository.path repo}/topics", options.merge(names: names)
|
453
441
|
end
|
454
442
|
|
455
443
|
# List contributors to a repo
|
@@ -601,10 +589,9 @@ module Octokit
|
|
601
589
|
# @example
|
602
590
|
# @client.protect_branch('octokit/octokit.rb', 'master', foo)
|
603
591
|
def protect_branch(repo, branch, options = {})
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
put "#{Repository.path repo}/branches/#{branch}/protection", opts
|
592
|
+
options[:restrictions] ||= nil
|
593
|
+
options[:required_status_checks] ||= nil
|
594
|
+
put "#{Repository.path repo}/branches/#{branch}/protection", options
|
608
595
|
end
|
609
596
|
|
610
597
|
# Get branch protection summary
|
@@ -617,12 +604,9 @@ module Octokit
|
|
617
604
|
# @example
|
618
605
|
# @client.branch_protection('octokit/octokit.rb', 'master')
|
619
606
|
def branch_protection(repo, branch, options = {})
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
rescue Octokit::BranchNotProtected
|
624
|
-
nil
|
625
|
-
end
|
607
|
+
get "#{Repository.path repo}/branches/#{branch}/protection", options
|
608
|
+
rescue Octokit::BranchNotProtected
|
609
|
+
nil
|
626
610
|
end
|
627
611
|
|
628
612
|
# Unlock a single branch from a repository
|
@@ -636,8 +620,7 @@ module Octokit
|
|
636
620
|
# @example
|
637
621
|
# @client.unprotect_branch('octokit/octokit.rb', 'master')
|
638
622
|
def unprotect_branch(repo, branch, options = {})
|
639
|
-
|
640
|
-
boolean_from_response :delete, "#{Repository.path repo}/branches/#{branch}/protection", opts
|
623
|
+
boolean_from_response :delete, "#{Repository.path repo}/branches/#{branch}/protection", options
|
641
624
|
end
|
642
625
|
|
643
626
|
# Rename a single branch from a repository
|
@@ -763,8 +746,7 @@ module Octokit
|
|
763
746
|
# @example
|
764
747
|
# @client.vulnerability_alerts_enabled?("octokit/octokit.rb")
|
765
748
|
def vulnerability_alerts_enabled?(repo, options = {})
|
766
|
-
|
767
|
-
boolean_from_response(:get, "#{Repository.path repo}/vulnerability-alerts", opts)
|
749
|
+
boolean_from_response(:get, "#{Repository.path repo}/vulnerability-alerts", options)
|
768
750
|
end
|
769
751
|
|
770
752
|
# Enable vulnerability alerts for a repository
|
@@ -777,8 +759,7 @@ module Octokit
|
|
777
759
|
# @example Enable vulnerability alerts for a repository
|
778
760
|
# @client.enable_vulnerability_alerts("octokit/octokit.rb")
|
779
761
|
def enable_vulnerability_alerts(repo, options = {})
|
780
|
-
|
781
|
-
boolean_from_response(:put, "#{Repository.path repo}/vulnerability-alerts", opts)
|
762
|
+
boolean_from_response(:put, "#{Repository.path repo}/vulnerability-alerts", options)
|
782
763
|
end
|
783
764
|
|
784
765
|
# Disable vulnerability alerts for a repository
|
@@ -791,8 +772,7 @@ module Octokit
|
|
791
772
|
# @example Disable vulnerability alerts for a repository
|
792
773
|
# @client.disable_vulnerability_alerts("octokit/octokit.rb")
|
793
774
|
def disable_vulnerability_alerts(repo, options = {})
|
794
|
-
|
795
|
-
boolean_from_response(:delete, "#{Repository.path repo}/vulnerability-alerts", opts)
|
775
|
+
boolean_from_response(:delete, "#{Repository.path repo}/vulnerability-alerts", options)
|
796
776
|
end
|
797
777
|
end
|
798
778
|
end
|
@@ -161,7 +161,7 @@ module Octokit
|
|
161
161
|
# TODO(5.0): remove deprecated behavior
|
162
162
|
if reviewers.is_a?(Array)
|
163
163
|
octokit_warn(
|
164
|
-
'Deprecated: Octokit::Client#request_pull_request_review '\
|
164
|
+
'Deprecated: Octokit::Client#request_pull_request_review ' \
|
165
165
|
"no longer takes a separate :reviewers argument.\n" \
|
166
166
|
'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
|
167
167
|
)
|
@@ -194,7 +194,7 @@ module Octokit
|
|
194
194
|
# TODO(5.0): remove deprecated behavior
|
195
195
|
if !reviewers.empty? && !options.empty?
|
196
196
|
octokit_warn(
|
197
|
-
'Deprecated: Octokit::Client#delete_pull_request_review_request '\
|
197
|
+
'Deprecated: Octokit::Client#delete_pull_request_review_request ' \
|
198
198
|
"no longer takes a separate :reviewers argument.\n" \
|
199
199
|
'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
|
200
200
|
)
|
@@ -31,7 +31,6 @@ module Octokit
|
|
31
31
|
# @return [Sawyer::Resource] Search results object
|
32
32
|
# @see https://developer.github.com/v3/search/#search-commits
|
33
33
|
def search_commits(query, options = {})
|
34
|
-
options = ensure_api_media_type(:commit_search, options)
|
35
34
|
search 'search/commits', query, options
|
36
35
|
end
|
37
36
|
|
@@ -64,6 +63,20 @@ module Octokit
|
|
64
63
|
end
|
65
64
|
alias search_repos search_repositories
|
66
65
|
|
66
|
+
# Search topics
|
67
|
+
#
|
68
|
+
# @param query [String] Search term and qualifiers
|
69
|
+
# @param options [Hash] Sort and pagination options
|
70
|
+
# @option options [String] :sort Sort field
|
71
|
+
# @option options [String] :order Sort order (asc or desc)
|
72
|
+
# @option options [Integer] :page Page of paginated results
|
73
|
+
# @option options [Integer] :per_page Number of items per page
|
74
|
+
# @return [Sawyer::Resource] Search results object
|
75
|
+
# @see https://developer.github.com/v3/search/#search-topics
|
76
|
+
def search_topics(query, options = {})
|
77
|
+
search 'search/topics', query, options
|
78
|
+
end
|
79
|
+
|
67
80
|
# Search users
|
68
81
|
#
|
69
82
|
# @param query [String] Search term and qualifiers
|
@@ -42,7 +42,7 @@ module Octokit
|
|
42
42
|
octokit_warn 'Octokit#start_source_import vcs parameter is now an option, please update your call before the next major Octokit version update.'
|
43
43
|
arguments.options.merge!(vcs: vcs)
|
44
44
|
end
|
45
|
-
options =
|
45
|
+
options = arguments.options.merge(vcs_url: vcs_url)
|
46
46
|
put "#{Repository.path arguments.repo}/import", options
|
47
47
|
end
|
48
48
|
|
@@ -55,7 +55,6 @@ module Octokit
|
|
55
55
|
# @example
|
56
56
|
# @client.source_import_progress("octokit/octokit.rb")
|
57
57
|
def source_import_progress(repo, options = {})
|
58
|
-
options = ensure_api_media_type(:source_imports, options)
|
59
58
|
get "#{Repository.path repo}/import", options
|
60
59
|
end
|
61
60
|
|
@@ -76,7 +75,6 @@ module Octokit
|
|
76
75
|
# :vcs_password => "secret"
|
77
76
|
# })
|
78
77
|
def update_source_import(repo, options = {})
|
79
|
-
options = ensure_api_media_type(:source_imports, options)
|
80
78
|
patch "#{Repository.path repo}/import", options
|
81
79
|
end
|
82
80
|
|
@@ -91,7 +89,6 @@ module Octokit
|
|
91
89
|
# @example
|
92
90
|
# @client.source_import_commit_authors("octokit/octokit.rb")
|
93
91
|
def source_import_commit_authors(repo, options = {})
|
94
|
-
options = ensure_api_media_type(:source_imports, options)
|
95
92
|
get "#{Repository.path repo}/import/authors", options
|
96
93
|
end
|
97
94
|
|
@@ -111,7 +108,7 @@ module Octokit
|
|
111
108
|
# :name => "Hubot the Robot"
|
112
109
|
# })
|
113
110
|
def map_source_import_commit_author(author_url, values, options = {})
|
114
|
-
options =
|
111
|
+
options = options.merge(values)
|
115
112
|
patch author_url, options
|
116
113
|
end
|
117
114
|
|
@@ -124,7 +121,6 @@ module Octokit
|
|
124
121
|
# @example
|
125
122
|
# @client.cancel_source_import("octokit/octokit.rb")
|
126
123
|
def cancel_source_import(repo, options = {})
|
127
|
-
options = ensure_api_media_type(:source_imports, options)
|
128
124
|
boolean_from_response :delete, "#{Repository.path repo}/import", options
|
129
125
|
end
|
130
126
|
|
@@ -139,7 +135,6 @@ module Octokit
|
|
139
135
|
# @example
|
140
136
|
# @client.source_import_large_files("octokit/octokit.rb")
|
141
137
|
def source_import_large_files(repo, options = {})
|
142
|
-
options = ensure_api_media_type(:source_imports, options)
|
143
138
|
get "#{Repository.path repo}/import/large_files", options
|
144
139
|
end
|
145
140
|
|
@@ -153,7 +148,7 @@ module Octokit
|
|
153
148
|
# @example
|
154
149
|
# @client.opt_in_source_import_lfs("octokit/octokit.rb", "opt_in")
|
155
150
|
def set_source_import_lfs_preference(repo, use_lfs, options = {})
|
156
|
-
options =
|
151
|
+
options = options.merge(use_lfs: use_lfs)
|
157
152
|
patch "#{Repository.path repo}/import/lfs", options
|
158
153
|
end
|
159
154
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Method to check scopes
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
|
8
|
+
module Tokens
|
9
|
+
# Check scopes for a token
|
10
|
+
#
|
11
|
+
# @param token [String] GitHub OAuth token
|
12
|
+
# @param options [Hash] Header params for request
|
13
|
+
# @return [Array<String>] OAuth scopes
|
14
|
+
# @see https://developer.github.com/v3/oauth/#scopes
|
15
|
+
def scopes(token = @access_token, options = {})
|
16
|
+
options = options.dup
|
17
|
+
raise ArgumentError, 'Access token required' if token.nil?
|
18
|
+
|
19
|
+
auth = { 'Authorization' => "token #{token}" }
|
20
|
+
headers = (options.delete(:headers) || {}).merge(auth)
|
21
|
+
|
22
|
+
agent.call(:get, 'user', headers: headers)
|
23
|
+
.headers['X-OAuth-Scopes']
|
24
|
+
.to_s
|
25
|
+
.split(',')
|
26
|
+
.map(&:strip)
|
27
|
+
.sort
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -14,8 +14,7 @@ module Octokit
|
|
14
14
|
# @example
|
15
15
|
# @client.top_referrers('octokit/octokit.rb')
|
16
16
|
def top_referrers(repo, options = {})
|
17
|
-
|
18
|
-
get "#{Repository.path repo}/traffic/popular/referrers", opts
|
17
|
+
get "#{Repository.path repo}/traffic/popular/referrers", options
|
19
18
|
end
|
20
19
|
|
21
20
|
# Get the top 10 popular contents over the last 14 days
|
@@ -26,8 +25,7 @@ module Octokit
|
|
26
25
|
# @example
|
27
26
|
# @client.top_paths('octokit/octokit.rb')
|
28
27
|
def top_paths(repo, options = {})
|
29
|
-
|
30
|
-
get "#{Repository.path repo}/traffic/popular/paths", opts
|
28
|
+
get "#{Repository.path repo}/traffic/popular/paths", options
|
31
29
|
end
|
32
30
|
|
33
31
|
# Get the total number of views and breakdown per day or week for the
|
@@ -43,8 +41,7 @@ module Octokit
|
|
43
41
|
# @example Views per week
|
44
42
|
# @client.views('octokit/octokit.rb', per: 'week')
|
45
43
|
def views(repo, options = {})
|
46
|
-
|
47
|
-
get "#{Repository.path repo}/traffic/views", opts
|
44
|
+
get "#{Repository.path repo}/traffic/views", options
|
48
45
|
end
|
49
46
|
|
50
47
|
# Get the total number of clones and breakdown per day or week for the
|
@@ -60,8 +57,7 @@ module Octokit
|
|
60
57
|
# @example Clones per week
|
61
58
|
# @client.clones('octokit/octokit.rb', per: 'week')
|
62
59
|
def clones(repo, options = {})
|
63
|
-
|
64
|
-
get "#{Repository.path repo}/traffic/clones", opts
|
60
|
+
get "#{Repository.path repo}/traffic/clones", options
|
65
61
|
end
|
66
62
|
end
|
67
63
|
end
|