octokit 4.2.0 → 9.2.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 +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +275 -127
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +12 -0
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +161 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +125 -0
- data/lib/octokit/client/actions_workflows.rb +68 -0
- data/lib/octokit/client/apps.rb +259 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/commits.rb +32 -35
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +29 -7
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +36 -8
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +34 -30
- data/lib/octokit/client/issues.rb +97 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +5 -8
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +14 -14
- data/lib/octokit/client/notifications.rb +7 -11
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +256 -73
- data/lib/octokit/client/pages.rb +26 -3
- data/lib/octokit/client/projects.rb +294 -0
- data/lib/octokit/client/pull_requests.rb +74 -51
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +204 -0
- data/lib/octokit/client/refs.rb +34 -20
- data/lib/octokit/client/releases.rb +16 -13
- data/lib/octokit/client/repositories.rb +276 -60
- data/lib/octokit/client/repository_invitations.rb +96 -0
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +46 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +156 -0
- data/lib/octokit/client/stats.rb +39 -17
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +64 -0
- data/lib/octokit/client/users.rb +133 -25
- data/lib/octokit/client.rb +85 -19
- data/lib/octokit/configurable.rb +60 -32
- data/lib/octokit/connection.rb +45 -21
- data/lib/octokit/default.rb +82 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +19 -18
- data/lib/octokit/enterprise_admin_client.rb +11 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +144 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +18 -14
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +35 -23
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -10
- metadata +47 -24
- data/lib/octokit/client/authorizations.rb +0 -256
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -28
@@ -1,37 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Repositories API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/
|
7
8
|
module Repositories
|
8
|
-
|
9
9
|
# Check if a repository exists
|
10
10
|
#
|
11
11
|
# @see https://developer.github.com/v3/repos/#get
|
12
12
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
13
|
-
# @return [
|
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
|
|
22
20
|
# Get a single repository
|
23
21
|
#
|
24
22
|
# @see https://developer.github.com/v3/repos/#get
|
23
|
+
# @see https://developer.github.com/v3/licenses/#get-a-repositorys-license
|
25
24
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
26
25
|
# @return [Sawyer::Resource] Repository information
|
27
26
|
def repository(repo, options = {})
|
28
27
|
get Repository.path(repo), options
|
29
28
|
end
|
30
|
-
alias
|
29
|
+
alias repo repository
|
31
30
|
|
32
31
|
# Edit a repository
|
33
32
|
#
|
34
|
-
# @see https://developer.github.com/v3/repos/#
|
33
|
+
# @see https://developer.github.com/v3/repos/#update-a-repository
|
35
34
|
# @param repo [String, Hash, Repository] A GitHub repository
|
36
35
|
# @param options [Hash] Repository information to update
|
37
36
|
# @option options [String] :name Name of the repo
|
@@ -40,6 +39,7 @@ module Octokit
|
|
40
39
|
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
41
40
|
# @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
|
42
41
|
# @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
|
42
|
+
# @option options [Boolean] :is_template `true` makes the repository a template, `false` makes it not a template.
|
43
43
|
# @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
|
44
44
|
# @option options [String] :default_branch Update the default branch for this repository.
|
45
45
|
# @return [Sawyer::Resource] Repository information
|
@@ -48,9 +48,9 @@ module Octokit
|
|
48
48
|
options[:name] ||= repo.name
|
49
49
|
patch "repos/#{repo}", options
|
50
50
|
end
|
51
|
-
alias
|
52
|
-
alias
|
53
|
-
alias
|
51
|
+
alias edit edit_repository
|
52
|
+
alias update_repository edit_repository
|
53
|
+
alias update edit_repository
|
54
54
|
|
55
55
|
# List user repositories
|
56
56
|
#
|
@@ -66,12 +66,12 @@ module Octokit
|
|
66
66
|
# @param user [Integer, String] Optional GitHub user login or id for which
|
67
67
|
# to list repos.
|
68
68
|
# @return [Array<Sawyer::Resource>] List of repositories
|
69
|
-
def repositories(user=nil, options = {})
|
69
|
+
def repositories(user = nil, options = {})
|
70
70
|
paginate "#{User.path user}/repos", options
|
71
71
|
end
|
72
|
-
alias
|
73
|
-
alias
|
74
|
-
alias
|
72
|
+
alias list_repositories repositories
|
73
|
+
alias list_repos repositories
|
74
|
+
alias repos repositories
|
75
75
|
|
76
76
|
# List all repositories
|
77
77
|
#
|
@@ -143,6 +143,7 @@ module Octokit
|
|
143
143
|
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
144
144
|
# @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
|
145
145
|
# @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
|
146
|
+
# @option options [Boolean] :is_template `true` makes this repo available as a template repository, `false` to prevent it.
|
146
147
|
# @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
|
147
148
|
# @option options [String] :organization Short name for the org under which to create the repo.
|
148
149
|
# @option options [Integer] :team_id The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.
|
@@ -151,17 +152,18 @@ module Octokit
|
|
151
152
|
# @return [Sawyer::Resource] Repository info for the new repository
|
152
153
|
# @see https://developer.github.com/v3/repos/#create
|
153
154
|
def create_repository(name, options = {})
|
154
|
-
|
155
|
-
|
155
|
+
opts = options.dup
|
156
|
+
organization = opts.delete :organization
|
157
|
+
opts.merge! name: name
|
156
158
|
|
157
159
|
if organization.nil?
|
158
|
-
post 'user/repos',
|
160
|
+
post 'user/repos', opts
|
159
161
|
else
|
160
|
-
post "#{Organization.path organization}/repos",
|
162
|
+
post "#{Organization.path organization}/repos", opts
|
161
163
|
end
|
162
164
|
end
|
163
|
-
alias
|
164
|
-
alias
|
165
|
+
alias create_repo create_repository
|
166
|
+
alias create create_repository
|
165
167
|
|
166
168
|
# Delete repository
|
167
169
|
#
|
@@ -173,7 +175,36 @@ module Octokit
|
|
173
175
|
def delete_repository(repo, options = {})
|
174
176
|
boolean_from_response :delete, Repository.path(repo), options
|
175
177
|
end
|
176
|
-
alias
|
178
|
+
alias delete_repo delete_repository
|
179
|
+
|
180
|
+
# Transfer repository
|
181
|
+
#
|
182
|
+
# Transfer a repository owned by your organization
|
183
|
+
#
|
184
|
+
# @see https://developer.github.com/v3/repos/#transfer-a-repository
|
185
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
186
|
+
# @param new_owner [String] The username or organization name the repository will be transferred to.
|
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.
|
188
|
+
# @return [Sawyer::Resource] Repository info for the transferred repository
|
189
|
+
def transfer_repository(repo, new_owner, options = {})
|
190
|
+
post "#{Repository.path repo}/transfer", options.merge({ new_owner: new_owner })
|
191
|
+
end
|
192
|
+
alias transfer_repo transfer_repository
|
193
|
+
|
194
|
+
# Create a repository for a user or organization generated from a template repository
|
195
|
+
#
|
196
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub template repository
|
197
|
+
# @param name [String] Name of the new repo
|
198
|
+
# @option options [String] :owner Organization or user who the new repository will belong to.
|
199
|
+
# @option options [String] :description Description of the repo
|
200
|
+
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
201
|
+
# @option options [Boolean] :include_all_branches `true` copies all branches from the template repository, `false` (default) makes it only copy the master branch.
|
202
|
+
# @return [Sawyer::Resource] Repository info for the new repository
|
203
|
+
def create_repository_from_template(repo, name, options = {})
|
204
|
+
options.merge! name: name
|
205
|
+
post "#{Repository.path repo}/generate", options
|
206
|
+
end
|
207
|
+
alias create_repo_from_template create_repository_from_template
|
177
208
|
|
178
209
|
# Hide a public repository
|
179
210
|
#
|
@@ -181,7 +212,7 @@ module Octokit
|
|
181
212
|
# @return [Sawyer::Resource] Updated repository info
|
182
213
|
def set_private(repo, options = {})
|
183
214
|
# GitHub Api for setting private updated to use private attr, rather than public
|
184
|
-
update_repository repo, options.merge({ :
|
215
|
+
update_repository repo, options.merge({ private: true })
|
185
216
|
end
|
186
217
|
|
187
218
|
# Unhide a private repository
|
@@ -190,7 +221,7 @@ module Octokit
|
|
190
221
|
# @return [Sawyer::Resource] Updated repository info
|
191
222
|
def set_public(repo, options = {})
|
192
223
|
# GitHub Api for setting private updated to use private attr, rather than public
|
193
|
-
update_repository repo, options.merge({ :
|
224
|
+
update_repository repo, options.merge({ private: false })
|
194
225
|
end
|
195
226
|
|
196
227
|
# Get deploy keys on a repo
|
@@ -199,7 +230,7 @@ module Octokit
|
|
199
230
|
#
|
200
231
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
201
232
|
# @return [Array<Sawyer::Resource>] Array of hashes representing deploy keys.
|
202
|
-
# @see https://developer.github.com/v3/repos/keys/#list
|
233
|
+
# @see https://developer.github.com/v3/repos/keys/#list-deploy-keys
|
203
234
|
# @example
|
204
235
|
# @client.deploy_keys('octokit/octokit.rb')
|
205
236
|
# @example
|
@@ -207,17 +238,17 @@ module Octokit
|
|
207
238
|
def deploy_keys(repo, options = {})
|
208
239
|
paginate "#{Repository.path repo}/keys", options
|
209
240
|
end
|
210
|
-
alias
|
241
|
+
alias list_deploy_keys deploy_keys
|
211
242
|
|
212
243
|
# Get a single deploy key for a repo
|
213
244
|
#
|
214
245
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
215
246
|
# @param id [Integer] Deploy key ID.
|
216
247
|
# @return [Sawyer::Resource] Deploy key.
|
217
|
-
# @see https://developer.github.com/v3/repos/keys/#get
|
248
|
+
# @see https://developer.github.com/v3/repos/keys/#get-a-deploy-key
|
218
249
|
# @example
|
219
250
|
# @client.deploy_key('octokit/octokit.rb', 8675309)
|
220
|
-
def deploy_key(repo, id, options={})
|
251
|
+
def deploy_key(repo, id, options = {})
|
221
252
|
get "#{Repository.path repo}/keys/#{id}", options
|
222
253
|
end
|
223
254
|
|
@@ -229,11 +260,11 @@ module Octokit
|
|
229
260
|
# @param title [String] Title reference for the deploy key.
|
230
261
|
# @param key [String] Public key.
|
231
262
|
# @return [Sawyer::Resource] Hash representing newly added key.
|
232
|
-
# @see https://developer.github.com/v3/repos/keys/#
|
263
|
+
# @see https://developer.github.com/v3/repos/keys/#add-a-new-deploy-key
|
233
264
|
# @example
|
234
265
|
# @client.add_deploy_key('octokit/octokit.rb', 'Staging server', 'ssh-rsa AAA...')
|
235
266
|
def add_deploy_key(repo, title, key, options = {})
|
236
|
-
post "#{Repository.path repo}/keys", options.merge(:
|
267
|
+
post "#{Repository.path repo}/keys", options.merge(title: title, key: key)
|
237
268
|
end
|
238
269
|
|
239
270
|
# Edit a deploy key
|
@@ -246,7 +277,7 @@ module Octokit
|
|
246
277
|
# @return [Sawyer::Resource] Updated deploy key.
|
247
278
|
# @deprecated This method is no longer supported in the API
|
248
279
|
# @see https://developer.github.com/changes/2014-02-24-finer-grained-scopes-for-ssh-keys/
|
249
|
-
# @see https://developer.github.com/v3/repos/keys/#edit
|
280
|
+
# @see https://developer.github.com/v3/repos/keys/#edit-a-deploy-key
|
250
281
|
# @example Update the key for a deploy key.
|
251
282
|
# @client.edit_deploy_key('octokit/octokit.rb', 8675309, :key => 'ssh-rsa BBB...')
|
252
283
|
# @example
|
@@ -254,7 +285,7 @@ module Octokit
|
|
254
285
|
def edit_deploy_key(repo, id, options)
|
255
286
|
patch "#{Repository.path repo}/keys/#{id}", options
|
256
287
|
end
|
257
|
-
alias
|
288
|
+
alias update_deploy_key edit_deploy_key
|
258
289
|
|
259
290
|
# Remove deploy key from a repo
|
260
291
|
#
|
@@ -263,7 +294,7 @@ module Octokit
|
|
263
294
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
264
295
|
# @param id [Integer] Id of the deploy key to remove.
|
265
296
|
# @return [Boolean] True if key removed, false otherwise.
|
266
|
-
# @see https://developer.github.com/v3/repos/keys/#
|
297
|
+
# @see https://developer.github.com/v3/repos/keys/#remove-a-deploy-key
|
267
298
|
# @example
|
268
299
|
# @client.remove_deploy_key('octokit/octokit.rb', 100000)
|
269
300
|
def remove_deploy_key(repo, id, options = {})
|
@@ -275,8 +306,11 @@ module Octokit
|
|
275
306
|
# Requires authenticated client for private repos.
|
276
307
|
#
|
277
308
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
309
|
+
# @option options [String] :affiliation Filters the return array by affiliation.
|
310
|
+
# Can be one of: <tt>outside</tt>, <tt>direct</tt>, or <tt>all</tt>.
|
311
|
+
# If not specified, defaults to <tt>all</tt>
|
278
312
|
# @return [Array<Sawyer::Resource>] Array of hashes representing collaborating users.
|
279
|
-
# @see https://developer.github.com/v3/repos/collaborators/#list
|
313
|
+
# @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
|
280
314
|
# @example
|
281
315
|
# Octokit.collaborators('octokit/octokit.rb')
|
282
316
|
# @example
|
@@ -286,24 +320,32 @@ module Octokit
|
|
286
320
|
def collaborators(repo, options = {})
|
287
321
|
paginate "#{Repository.path repo}/collaborators", options
|
288
322
|
end
|
289
|
-
alias
|
323
|
+
alias collabs collaborators
|
290
324
|
|
291
325
|
# Add collaborator to repo
|
292
326
|
#
|
327
|
+
# This can also be used to update the permission of an existing collaborator
|
328
|
+
#
|
293
329
|
# Requires authenticated client.
|
294
330
|
#
|
295
331
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
296
332
|
# @param collaborator [String] Collaborator GitHub username to add.
|
333
|
+
# @option options [String] :permission The permission to grant the collaborator.
|
334
|
+
# Only valid on organization-owned repositories.
|
335
|
+
# Can be one of: <tt>pull</tt>, <tt>push</tt>, or <tt>admin</tt>.
|
336
|
+
# If not specified, defaults to <tt>push</tt>
|
297
337
|
# @return [Boolean] True if collaborator added, false otherwise.
|
298
|
-
# @see https://developer.github.com/v3/repos/collaborators/#add-collaborator
|
338
|
+
# @see https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
|
299
339
|
# @example
|
300
340
|
# @client.add_collaborator('octokit/octokit.rb', 'holman')
|
301
341
|
# @example
|
302
342
|
# @client.add_collab('octokit/octokit.rb', 'holman')
|
343
|
+
# @example Add a collaborator with admin permissions
|
344
|
+
# @client.add_collaborator('octokit/octokit.rb', 'holman', permission: 'admin')
|
303
345
|
def add_collaborator(repo, collaborator, options = {})
|
304
346
|
boolean_from_response :put, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
305
347
|
end
|
306
|
-
alias
|
348
|
+
alias add_collab add_collaborator
|
307
349
|
|
308
350
|
# Remove collaborator from repo.
|
309
351
|
#
|
@@ -312,7 +354,7 @@ module Octokit
|
|
312
354
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
313
355
|
# @param collaborator [String] Collaborator GitHub username to remove.
|
314
356
|
# @return [Boolean] True if collaborator removed, false otherwise.
|
315
|
-
# @see https://developer.github.com/v3/repos/collaborators/#remove-collaborator
|
357
|
+
# @see https://developer.github.com/v3/repos/collaborators/#remove-user-as-a-collaborator
|
316
358
|
# @example
|
317
359
|
# @client.remove_collaborator('octokit/octokit.rb', 'holman')
|
318
360
|
# @example
|
@@ -320,7 +362,7 @@ module Octokit
|
|
320
362
|
def remove_collaborator(repo, collaborator, options = {})
|
321
363
|
boolean_from_response :delete, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
322
364
|
end
|
323
|
-
alias
|
365
|
+
alias remove_collab remove_collaborator
|
324
366
|
|
325
367
|
# Checks if a user is a collaborator for a repo.
|
326
368
|
#
|
@@ -329,13 +371,25 @@ module Octokit
|
|
329
371
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
330
372
|
# @param collaborator [String] Collaborator GitHub username to check.
|
331
373
|
# @return [Boolean] True if user is a collaborator, false otherwise.
|
332
|
-
# @see https://developer.github.com/v3/repos/collaborators/#
|
374
|
+
# @see https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
|
333
375
|
# @example
|
334
376
|
# @client.collaborator?('octokit/octokit.rb', 'holman')
|
335
|
-
def collaborator?(repo, collaborator, options={})
|
377
|
+
def collaborator?(repo, collaborator, options = {})
|
336
378
|
boolean_from_response :get, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
337
379
|
end
|
338
380
|
|
381
|
+
# Get a user's permission level for a repo.
|
382
|
+
#
|
383
|
+
# Requires authenticated client
|
384
|
+
#
|
385
|
+
# @return [Sawyer::Resource] Hash representing the user's permission level for the given repository
|
386
|
+
# @see https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
|
387
|
+
# @example
|
388
|
+
# @client.permission_level('octokit/octokit.rb', 'lizzhale')
|
389
|
+
def permission_level(repo, collaborator, options = {})
|
390
|
+
get "#{Repository.path repo}/collaborators/#{collaborator}/permission", options
|
391
|
+
end
|
392
|
+
|
339
393
|
# List teams for a repo
|
340
394
|
#
|
341
395
|
# Requires authenticated client that is an owner or collaborator of the repo.
|
@@ -352,8 +406,39 @@ module Octokit
|
|
352
406
|
def repository_teams(repo, options = {})
|
353
407
|
paginate "#{Repository.path repo}/teams", options
|
354
408
|
end
|
355
|
-
alias
|
356
|
-
alias
|
409
|
+
alias repo_teams repository_teams
|
410
|
+
alias teams repository_teams
|
411
|
+
|
412
|
+
# List all topics for a repository
|
413
|
+
#
|
414
|
+
# Requires authenticated client for private repos.
|
415
|
+
#
|
416
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
417
|
+
# @return [Sawyer::Resource] representing the topics for given repo
|
418
|
+
# @see https://developer.github.com/v3/repos/#list-all-topics-for-a-repository
|
419
|
+
# @example List topics for octokit/octokit.rb
|
420
|
+
# Octokit.topics('octokit/octokit.rb')
|
421
|
+
# @example List topics for octokit/octokit.rb
|
422
|
+
# client.topics('octokit/octokit.rb')
|
423
|
+
def topics(repo, options = {})
|
424
|
+
paginate "#{Repository.path repo}/topics", options
|
425
|
+
end
|
426
|
+
|
427
|
+
# Replace all topics for a repository
|
428
|
+
#
|
429
|
+
# Requires authenticated client.
|
430
|
+
#
|
431
|
+
# @param repo [Integer, String, Repository, Hash] A Github repository
|
432
|
+
# @param names [Array] An array of topics to add to the repository.
|
433
|
+
# @return [Sawyer::Resource] representing the replaced topics for given repo
|
434
|
+
# @see https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository
|
435
|
+
# @example Replace topics for octokit/octokit.rb
|
436
|
+
# client.replace_all_topics('octokit/octokit.rb', ['octocat', 'atom', 'electron', 'API'])
|
437
|
+
# @example Clear all topics for octokit/octokit.rb
|
438
|
+
# client.replace_all_topics('octokit/octokit.rb', [])
|
439
|
+
def replace_all_topics(repo, names, options = {})
|
440
|
+
put "#{Repository.path repo}/topics", options.merge(names: names)
|
441
|
+
end
|
357
442
|
|
358
443
|
# List contributors to a repo
|
359
444
|
#
|
@@ -373,7 +458,7 @@ module Octokit
|
|
373
458
|
options[:anon] = 1 if anon.to_s[/1|true/]
|
374
459
|
paginate "#{Repository.path repo}/contributors", options
|
375
460
|
end
|
376
|
-
alias
|
461
|
+
alias contribs contributors
|
377
462
|
|
378
463
|
# List stargazers of a repo
|
379
464
|
#
|
@@ -423,7 +508,7 @@ module Octokit
|
|
423
508
|
def forks(repo, options = {})
|
424
509
|
paginate "#{Repository.path repo}/forks", options
|
425
510
|
end
|
426
|
-
alias
|
511
|
+
alias network forks
|
427
512
|
|
428
513
|
# List languages of code in the repo.
|
429
514
|
#
|
@@ -479,9 +564,9 @@ module Octokit
|
|
479
564
|
# @example Get branch 'master` from octokit/octokit.rb
|
480
565
|
# Octokit.branch("octokit/octokit.rb", "master")
|
481
566
|
def branch(repo, branch, options = {})
|
482
|
-
get "#{Repository.path repo}/branches/#{branch}", options
|
567
|
+
get "#{Repository.path repo}/branches/#{CGI.escape(branch)}", options
|
483
568
|
end
|
484
|
-
alias
|
569
|
+
alias get_branch branch
|
485
570
|
|
486
571
|
# Lock a single branch from a repository
|
487
572
|
#
|
@@ -489,20 +574,39 @@ module Octokit
|
|
489
574
|
#
|
490
575
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
491
576
|
# @param branch [String] Branch name
|
492
|
-
# @
|
577
|
+
# @option options [Hash] :required_status_checks If not null, the following keys are required:
|
578
|
+
# <tt>:enforce_admins [boolean] Enforce required status checks for repository administrators.</tt>
|
579
|
+
# <tt>:strict [boolean] Require branches to be up to date before merging.</tt>
|
580
|
+
# <tt>:contexts [Array] The list of status checks to require in order to merge into this branch</tt>
|
581
|
+
#
|
582
|
+
# @option options [Hash] :restrictions If not null, the following keys are required:
|
583
|
+
# <tt>:users [Array] The list of user logins with push access</tt>
|
584
|
+
# <tt>:teams [Array] The list of team slugs with push access</tt>.
|
585
|
+
#
|
586
|
+
# Teams and users restrictions are only available for organization-owned repositories.
|
493
587
|
# @return [Sawyer::Resource] The protected branch
|
494
588
|
# @see https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
|
495
589
|
# @example
|
496
590
|
# @client.protect_branch('octokit/octokit.rb', 'master', foo)
|
497
|
-
def protect_branch(repo, branch,
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
protection = { :protection => { :enabled => true }.merge(required_status_checks) }
|
503
|
-
options = ensure_api_media_type(:branch_protection, options.merge(protection))
|
591
|
+
def protect_branch(repo, branch, options = {})
|
592
|
+
options[:restrictions] ||= nil
|
593
|
+
options[:required_status_checks] ||= nil
|
594
|
+
put "#{Repository.path repo}/branches/#{branch}/protection", options
|
595
|
+
end
|
504
596
|
|
505
|
-
|
597
|
+
# Get branch protection summary
|
598
|
+
#
|
599
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
600
|
+
# @param branch [String] Branch name
|
601
|
+
# @return [Sawyer::Resource, nil] Branch protection summary or nil if the branch
|
602
|
+
# is not protected
|
603
|
+
# @see https://developer.github.com/v3/repos/branches/#get-branch-protection
|
604
|
+
# @example
|
605
|
+
# @client.branch_protection('octokit/octokit.rb', 'master')
|
606
|
+
def branch_protection(repo, branch, options = {})
|
607
|
+
get "#{Repository.path repo}/branches/#{branch}/protection", options
|
608
|
+
rescue Octokit::BranchNotProtected
|
609
|
+
nil
|
506
610
|
end
|
507
611
|
|
508
612
|
# Unlock a single branch from a repository
|
@@ -516,9 +620,25 @@ module Octokit
|
|
516
620
|
# @example
|
517
621
|
# @client.unprotect_branch('octokit/octokit.rb', 'master')
|
518
622
|
def unprotect_branch(repo, branch, options = {})
|
519
|
-
|
520
|
-
|
521
|
-
|
623
|
+
boolean_from_response :delete, "#{Repository.path repo}/branches/#{branch}/protection", options
|
624
|
+
end
|
625
|
+
|
626
|
+
# Rename a single branch from a repository
|
627
|
+
#
|
628
|
+
# Requires authenticated client
|
629
|
+
#
|
630
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
631
|
+
# @param branch [String] Current branch name
|
632
|
+
# @param new_name [String] New branch name
|
633
|
+
# @return [Sawyer::Resource] The renamed branch
|
634
|
+
# @see https://developer.github.com/v3/repos/#rename-a-branch
|
635
|
+
# @example
|
636
|
+
# @client.rename_branch('octokit/octokit.rb', 'master', 'main')
|
637
|
+
def rename_branch(repo, branch, new_name, options = {})
|
638
|
+
params = {
|
639
|
+
new_name: new_name
|
640
|
+
}
|
641
|
+
post "#{Repository.path repo}/branches/#{branch}/rename", params.merge(options)
|
522
642
|
end
|
523
643
|
|
524
644
|
# List users available for assigning to issues.
|
@@ -537,7 +657,7 @@ module Octokit
|
|
537
657
|
def repository_assignees(repo, options = {})
|
538
658
|
paginate "#{Repository.path repo}/assignees", options
|
539
659
|
end
|
540
|
-
alias
|
660
|
+
alias repo_assignees repository_assignees
|
541
661
|
|
542
662
|
# Check to see if a particular user is an assignee for a repository.
|
543
663
|
#
|
@@ -601,6 +721,102 @@ module Octokit
|
|
601
721
|
def delete_subscription(repo, options = {})
|
602
722
|
boolean_from_response :delete, "#{Repository.path repo}/subscription", options
|
603
723
|
end
|
724
|
+
|
725
|
+
# Create a repository dispatch event
|
726
|
+
#
|
727
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
728
|
+
# @param event_type [String] A custom webhook event name.
|
729
|
+
# @option options [Hash] :client_payload payload with extra information
|
730
|
+
# about the webhook event that your action or worklow may use.
|
731
|
+
#
|
732
|
+
# @return [Boolean] True if event was dispatched, false otherwise.
|
733
|
+
# @see https://developer.github.com/v3/repos/#create-a-repository-dispatch-event
|
734
|
+
def dispatch_event(repo, event_type, options = {})
|
735
|
+
boolean_from_response :post, "#{Repository.path repo}/dispatches", options.merge({ event_type: event_type })
|
736
|
+
end
|
737
|
+
|
738
|
+
# Check to see if vulnerability alerts are enabled for a repository
|
739
|
+
#
|
740
|
+
# The authenticated user must have admin access to the repository.
|
741
|
+
#
|
742
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
743
|
+
# @return [Boolean] True if vulnerability alerts are enabled, false otherwise.
|
744
|
+
# @see https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository
|
745
|
+
#
|
746
|
+
# @example
|
747
|
+
# @client.vulnerability_alerts_enabled?("octokit/octokit.rb")
|
748
|
+
def vulnerability_alerts_enabled?(repo, options = {})
|
749
|
+
boolean_from_response(:get, "#{Repository.path repo}/vulnerability-alerts", options)
|
750
|
+
end
|
751
|
+
|
752
|
+
# Enable vulnerability alerts for a repository
|
753
|
+
#
|
754
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
755
|
+
# @param options [Hash]
|
756
|
+
#
|
757
|
+
# @return [Boolean] True if vulnerability alerts enabled, false otherwise.
|
758
|
+
# @see https://docs.github.com/en/rest/reference/repos#enable-vulnerability-alerts
|
759
|
+
# @example Enable vulnerability alerts for a repository
|
760
|
+
# @client.enable_vulnerability_alerts("octokit/octokit.rb")
|
761
|
+
def enable_vulnerability_alerts(repo, options = {})
|
762
|
+
boolean_from_response(:put, "#{Repository.path repo}/vulnerability-alerts", options)
|
763
|
+
end
|
764
|
+
|
765
|
+
# Disable vulnerability alerts for a repository
|
766
|
+
#
|
767
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
768
|
+
# @param options [Hash]
|
769
|
+
#
|
770
|
+
# @return [Boolean] True if vulnerability alerts disabled, false otherwise.
|
771
|
+
# @see https://docs.github.com/en/rest/reference/repos#disable-vulnerability-alerts
|
772
|
+
# @example Disable vulnerability alerts for a repository
|
773
|
+
# @client.disable_vulnerability_alerts("octokit/octokit.rb")
|
774
|
+
def disable_vulnerability_alerts(repo, options = {})
|
775
|
+
boolean_from_response(:delete, "#{Repository.path repo}/vulnerability-alerts", options)
|
776
|
+
end
|
777
|
+
|
778
|
+
# Check to see if automated security fixes are enabled for a repository
|
779
|
+
#
|
780
|
+
# The authenticated user must have admin access to the repository.
|
781
|
+
#
|
782
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
783
|
+
# @return [Boolean] True if automated security fixes are enabled, false otherwise.
|
784
|
+
# @see https://docs.github.com/en/rest/reference/repos#check-if-automated-security-fixes-are-enabled-for-a-repository
|
785
|
+
#
|
786
|
+
# @example
|
787
|
+
# @client.automated_security_fixes_enabled?("octokit/octokit.rb")
|
788
|
+
def automated_security_fixes_enabled?(repo, options = {})
|
789
|
+
response = get "#{Repository.path repo}/automated-security-fixes", options
|
790
|
+
return response[:enabled] if @last_response.status == 200
|
791
|
+
|
792
|
+
false
|
793
|
+
end
|
794
|
+
|
795
|
+
# Enable automated security fixes for a repository
|
796
|
+
#
|
797
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
798
|
+
# @param options [Hash]
|
799
|
+
#
|
800
|
+
# @return [Boolean] True if vulnerability alerts enabled, false otherwise.
|
801
|
+
# @see https://docs.github.com/en/rest/reference/repos#automated-security-fixes
|
802
|
+
# @example Enable automated security fixes for a repository
|
803
|
+
# @client.enable_automated_security_fixes("octokit/octokit.rb")
|
804
|
+
def enable_automated_security_fixes(repo, options = {})
|
805
|
+
boolean_from_response(:put, "#{Repository.path repo}/automated-security-fixes", options)
|
806
|
+
end
|
807
|
+
|
808
|
+
# Disable automated security fixes for a repository
|
809
|
+
#
|
810
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
811
|
+
# @param options [Hash]
|
812
|
+
#
|
813
|
+
# @return [Boolean] True if vulnerability alerts disabled, false otherwise.
|
814
|
+
# @see https://docs.github.com/en/rest/reference/repos#automated-security-fixes
|
815
|
+
# @example Disable automated security fixes for a repository
|
816
|
+
# @client.disable_automated_security_fixes("octokit/octokit.rb")
|
817
|
+
def disable_automated_security_fixes(repo, options = {})
|
818
|
+
boolean_from_response(:delete, "#{Repository.path repo}/automated-security-fixes", options)
|
819
|
+
end
|
604
820
|
end
|
605
821
|
end
|
606
822
|
end
|