octokit 4.22.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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +117 -95
  3. data/Rakefile +20 -14
  4. data/lib/ext/sawyer/relation.rb +4 -2
  5. data/lib/octokit/arguments.rb +3 -3
  6. data/lib/octokit/authentication.rb +10 -3
  7. data/lib/octokit/client/actions_artifacts.rb +71 -0
  8. data/lib/octokit/client/actions_secrets.rb +111 -8
  9. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  10. data/lib/octokit/client/actions_workflow_runs.rb +23 -3
  11. data/lib/octokit/client/actions_workflows.rb +27 -2
  12. data/lib/octokit/client/apps.rb +63 -26
  13. data/lib/octokit/client/checks.rb +18 -9
  14. data/lib/octokit/client/code_scanning.rb +190 -0
  15. data/lib/octokit/client/codespaces_secrets.rb +108 -0
  16. data/lib/octokit/client/commit_branches.rb +2 -2
  17. data/lib/octokit/client/commit_comments.rb +8 -8
  18. data/lib/octokit/client/commit_pulls.rb +2 -2
  19. data/lib/octokit/client/commits.rb +25 -33
  20. data/lib/octokit/client/community_profile.rb +2 -3
  21. data/lib/octokit/client/contents.rb +19 -22
  22. data/lib/octokit/client/dependabot_secrets.rb +108 -0
  23. data/lib/octokit/client/deployments.rb +8 -8
  24. data/lib/octokit/client/downloads.rb +5 -6
  25. data/lib/octokit/client/emojis.rb +3 -3
  26. data/lib/octokit/client/environments.rb +58 -0
  27. data/lib/octokit/client/events.rb +4 -5
  28. data/lib/octokit/client/feeds.rb +4 -5
  29. data/lib/octokit/client/gists.rb +6 -6
  30. data/lib/octokit/client/gitignore.rb +3 -3
  31. data/lib/octokit/client/hooks.rb +9 -19
  32. data/lib/octokit/client/issues.rb +14 -15
  33. data/lib/octokit/client/labels.rb +10 -10
  34. data/lib/octokit/client/legacy_search.rb +3 -3
  35. data/lib/octokit/client/licenses.rb +3 -6
  36. data/lib/octokit/client/markdown.rb +3 -3
  37. data/lib/octokit/client/marketplace.rb +4 -4
  38. data/lib/octokit/client/meta.rb +4 -5
  39. data/lib/octokit/client/milestones.rb +5 -5
  40. data/lib/octokit/client/notifications.rb +6 -6
  41. data/lib/octokit/client/oauth_applications.rb +1 -7
  42. data/lib/octokit/client/objects.rb +14 -14
  43. data/lib/octokit/client/organizations.rb +100 -56
  44. data/lib/octokit/client/pages.rb +5 -7
  45. data/lib/octokit/client/projects.rb +44 -64
  46. data/lib/octokit/client/pull_requests.rb +66 -45
  47. data/lib/octokit/client/rate_limit.rb +9 -11
  48. data/lib/octokit/client/reactions.rb +62 -16
  49. data/lib/octokit/client/refs.rb +14 -17
  50. data/lib/octokit/client/releases.rb +13 -13
  51. data/lib/octokit/client/repositories.rb +92 -69
  52. data/lib/octokit/client/repository_invitations.rb +3 -3
  53. data/lib/octokit/client/reviews.rb +8 -8
  54. data/lib/octokit/client/say.rb +4 -5
  55. data/lib/octokit/client/search.rb +24 -10
  56. data/lib/octokit/client/service_status.rb +19 -9
  57. data/lib/octokit/client/source_import.rb +7 -12
  58. data/lib/octokit/client/stats.rb +10 -9
  59. data/lib/octokit/client/statuses.rb +5 -5
  60. data/lib/octokit/client/tokens.rb +31 -0
  61. data/lib/octokit/client/traffic.rb +6 -11
  62. data/lib/octokit/client/users.rb +54 -33
  63. data/lib/octokit/client.rb +42 -18
  64. data/lib/octokit/configurable.rb +51 -31
  65. data/lib/octokit/connection.rb +30 -21
  66. data/lib/octokit/default.rb +66 -35
  67. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  68. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  69. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  70. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  71. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  72. data/lib/octokit/enterprise_admin_client.rb +9 -3
  73. data/lib/octokit/enterprise_management_console_client/management_console.rb +51 -33
  74. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  75. data/lib/octokit/error.rb +51 -34
  76. data/lib/octokit/gist.rb +3 -4
  77. data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
  78. data/lib/octokit/manage_ghes_client.rb +64 -0
  79. data/lib/octokit/middleware/follow_redirects.rb +13 -12
  80. data/lib/octokit/organization.rb +3 -1
  81. data/lib/octokit/rate_limit.rb +8 -6
  82. data/lib/octokit/repo_arguments.rb +3 -4
  83. data/lib/octokit/repository.rb +32 -25
  84. data/lib/octokit/response/base_middleware.rb +10 -0
  85. data/lib/octokit/response/feed_parser.rb +5 -7
  86. data/lib/octokit/response/raise_error.rb +4 -4
  87. data/lib/octokit/user.rb +4 -2
  88. data/lib/octokit/version.rb +4 -2
  89. data/lib/octokit/warnable.rb +4 -5
  90. data/lib/octokit.rb +30 -8
  91. data/octokit.gemspec +12 -11
  92. metadata +19 -31
  93. data/lib/octokit/client/authorizations.rb +0 -182
  94. data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
  95. data/lib/octokit/preview.rb +0 -46
@@ -1,11 +1,11 @@
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
@@ -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
 
@@ -28,7 +26,7 @@ module Octokit
28
26
  def repository(repo, options = {})
29
27
  get Repository.path(repo), options
30
28
  end
31
- alias :repo :repository
29
+ alias repo repository
32
30
 
33
31
  # Edit a repository
34
32
  #
@@ -47,15 +45,12 @@ 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
56
- alias :edit :edit_repository
57
- alias :update_repository :edit_repository
58
- alias :update :edit_repository
51
+ alias edit edit_repository
52
+ alias update_repository edit_repository
53
+ alias update edit_repository
59
54
 
60
55
  # List user repositories
61
56
  #
@@ -71,12 +66,12 @@ module Octokit
71
66
  # @param user [Integer, String] Optional GitHub user login or id for which
72
67
  # to list repos.
73
68
  # @return [Array<Sawyer::Resource>] List of repositories
74
- def repositories(user=nil, options = {})
69
+ def repositories(user = nil, options = {})
75
70
  paginate "#{User.path user}/repos", options
76
71
  end
77
- alias :list_repositories :repositories
78
- alias :list_repos :repositories
79
- alias :repos :repositories
72
+ alias list_repositories repositories
73
+ alias list_repos repositories
74
+ alias repos repositories
80
75
 
81
76
  # List all repositories
82
77
  #
@@ -159,10 +154,7 @@ module Octokit
159
154
  def create_repository(name, options = {})
160
155
  opts = options.dup
161
156
  organization = opts.delete :organization
162
- opts.merge! :name => name
163
- if opts.include? :is_template
164
- opts = ensure_api_media_type(:template_repositories, opts)
165
- end
157
+ opts.merge! name: name
166
158
 
167
159
  if organization.nil?
168
160
  post 'user/repos', opts
@@ -170,8 +162,8 @@ module Octokit
170
162
  post "#{Organization.path organization}/repos", opts
171
163
  end
172
164
  end
173
- alias :create_repo :create_repository
174
- alias :create :create_repository
165
+ alias create_repo create_repository
166
+ alias create create_repository
175
167
 
176
168
  # Delete repository
177
169
  #
@@ -183,7 +175,7 @@ module Octokit
183
175
  def delete_repository(repo, options = {})
184
176
  boolean_from_response :delete, Repository.path(repo), options
185
177
  end
186
- alias :delete_repo :delete_repository
178
+ alias delete_repo delete_repository
187
179
 
188
180
  # Transfer repository
189
181
  #
@@ -195,10 +187,9 @@ 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
- alias :transfer_repo :transfer_repository
192
+ alias transfer_repo transfer_repository
202
193
 
203
194
  # Create a repository for a user or organization generated from a template repository
204
195
  #
@@ -210,11 +201,10 @@ module Octokit
210
201
  # @option options [Boolean] :include_all_branches `true` copies all branches from the template repository, `false` (default) makes it only copy the master branch.
211
202
  # @return [Sawyer::Resource] Repository info for the new repository
212
203
  def create_repository_from_template(repo, name, options = {})
213
- options.merge! :name => name
214
- options = ensure_api_media_type(:template_repositories, options)
204
+ options.merge! name: name
215
205
  post "#{Repository.path repo}/generate", options
216
206
  end
217
- alias :create_repo_from_template :create_repository_from_template
207
+ alias create_repo_from_template create_repository_from_template
218
208
 
219
209
  # Hide a public repository
220
210
  #
@@ -222,7 +212,7 @@ module Octokit
222
212
  # @return [Sawyer::Resource] Updated repository info
223
213
  def set_private(repo, options = {})
224
214
  # GitHub Api for setting private updated to use private attr, rather than public
225
- update_repository repo, options.merge({ :private => true })
215
+ update_repository repo, options.merge({ private: true })
226
216
  end
227
217
 
228
218
  # Unhide a private repository
@@ -231,7 +221,7 @@ module Octokit
231
221
  # @return [Sawyer::Resource] Updated repository info
232
222
  def set_public(repo, options = {})
233
223
  # GitHub Api for setting private updated to use private attr, rather than public
234
- update_repository repo, options.merge({ :private => false })
224
+ update_repository repo, options.merge({ private: false })
235
225
  end
236
226
 
237
227
  # Get deploy keys on a repo
@@ -248,7 +238,7 @@ module Octokit
248
238
  def deploy_keys(repo, options = {})
249
239
  paginate "#{Repository.path repo}/keys", options
250
240
  end
251
- alias :list_deploy_keys :deploy_keys
241
+ alias list_deploy_keys deploy_keys
252
242
 
253
243
  # Get a single deploy key for a repo
254
244
  #
@@ -258,7 +248,7 @@ module Octokit
258
248
  # @see https://developer.github.com/v3/repos/keys/#get-a-deploy-key
259
249
  # @example
260
250
  # @client.deploy_key('octokit/octokit.rb', 8675309)
261
- def deploy_key(repo, id, options={})
251
+ def deploy_key(repo, id, options = {})
262
252
  get "#{Repository.path repo}/keys/#{id}", options
263
253
  end
264
254
 
@@ -274,7 +264,7 @@ module Octokit
274
264
  # @example
275
265
  # @client.add_deploy_key('octokit/octokit.rb', 'Staging server', 'ssh-rsa AAA...')
276
266
  def add_deploy_key(repo, title, key, options = {})
277
- post "#{Repository.path repo}/keys", options.merge(:title => title, :key => key)
267
+ post "#{Repository.path repo}/keys", options.merge(title: title, key: key)
278
268
  end
279
269
 
280
270
  # Edit a deploy key
@@ -295,7 +285,7 @@ module Octokit
295
285
  def edit_deploy_key(repo, id, options)
296
286
  patch "#{Repository.path repo}/keys/#{id}", options
297
287
  end
298
- alias :update_deploy_key :edit_deploy_key
288
+ alias update_deploy_key edit_deploy_key
299
289
 
300
290
  # Remove deploy key from a repo
301
291
  #
@@ -330,7 +320,7 @@ module Octokit
330
320
  def collaborators(repo, options = {})
331
321
  paginate "#{Repository.path repo}/collaborators", options
332
322
  end
333
- alias :collabs :collaborators
323
+ alias collabs collaborators
334
324
 
335
325
  # Add collaborator to repo
336
326
  #
@@ -355,7 +345,7 @@ module Octokit
355
345
  def add_collaborator(repo, collaborator, options = {})
356
346
  boolean_from_response :put, "#{Repository.path repo}/collaborators/#{collaborator}", options
357
347
  end
358
- alias :add_collab :add_collaborator
348
+ alias add_collab add_collaborator
359
349
 
360
350
  # Remove collaborator from repo.
361
351
  #
@@ -372,7 +362,7 @@ module Octokit
372
362
  def remove_collaborator(repo, collaborator, options = {})
373
363
  boolean_from_response :delete, "#{Repository.path repo}/collaborators/#{collaborator}", options
374
364
  end
375
- alias :remove_collab :remove_collaborator
365
+ alias remove_collab remove_collaborator
376
366
 
377
367
  # Checks if a user is a collaborator for a repo.
378
368
  #
@@ -384,7 +374,7 @@ module Octokit
384
374
  # @see https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
385
375
  # @example
386
376
  # @client.collaborator?('octokit/octokit.rb', 'holman')
387
- def collaborator?(repo, collaborator, options={})
377
+ def collaborator?(repo, collaborator, options = {})
388
378
  boolean_from_response :get, "#{Repository.path repo}/collaborators/#{collaborator}", options
389
379
  end
390
380
 
@@ -396,7 +386,7 @@ module Octokit
396
386
  # @see https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
397
387
  # @example
398
388
  # @client.permission_level('octokit/octokit.rb', 'lizzhale')
399
- def permission_level(repo, collaborator, options={})
389
+ def permission_level(repo, collaborator, options = {})
400
390
  get "#{Repository.path repo}/collaborators/#{collaborator}/permission", options
401
391
  end
402
392
 
@@ -416,8 +406,8 @@ module Octokit
416
406
  def repository_teams(repo, options = {})
417
407
  paginate "#{Repository.path repo}/teams", options
418
408
  end
419
- alias :repo_teams :repository_teams
420
- alias :teams :repository_teams
409
+ alias repo_teams repository_teams
410
+ alias teams repository_teams
421
411
 
422
412
  # List all topics for a repository
423
413
  #
@@ -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
- opts = ensure_api_media_type(:topics, options)
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
- opts = ensure_api_media_type(:topics, options)
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
@@ -470,7 +458,7 @@ module Octokit
470
458
  options[:anon] = 1 if anon.to_s[/1|true/]
471
459
  paginate "#{Repository.path repo}/contributors", options
472
460
  end
473
- alias :contribs :contributors
461
+ alias contribs contributors
474
462
 
475
463
  # List stargazers of a repo
476
464
  #
@@ -520,7 +508,7 @@ module Octokit
520
508
  def forks(repo, options = {})
521
509
  paginate "#{Repository.path repo}/forks", options
522
510
  end
523
- alias :network :forks
511
+ alias network forks
524
512
 
525
513
  # List languages of code in the repo.
526
514
  #
@@ -576,9 +564,9 @@ module Octokit
576
564
  # @example Get branch 'master` from octokit/octokit.rb
577
565
  # Octokit.branch("octokit/octokit.rb", "master")
578
566
  def branch(repo, branch, options = {})
579
- get "#{Repository.path repo}/branches/#{branch}", options
567
+ get "#{Repository.path repo}/branches/#{CGI.escape(branch)}", options
580
568
  end
581
- alias :get_branch :branch
569
+ alias get_branch branch
582
570
 
583
571
  # Lock a single branch from a repository
584
572
  #
@@ -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
- opts = ensure_api_media_type(:branch_protection, options)
605
- opts[:restrictions] ||= nil
606
- opts[:required_status_checks] ||= nil
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
- opts = ensure_api_media_type(:branch_protection, options)
621
- begin
622
- get "#{Repository.path repo}/branches/#{branch}/protection", opts
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
- opts = ensure_api_media_type(:branch_protection, options)
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
@@ -653,7 +636,7 @@ module Octokit
653
636
  # @client.rename_branch('octokit/octokit.rb', 'master', 'main')
654
637
  def rename_branch(repo, branch, new_name, options = {})
655
638
  params = {
656
- new_name: new_name,
639
+ new_name: new_name
657
640
  }
658
641
  post "#{Repository.path repo}/branches/#{branch}/rename", params.merge(options)
659
642
  end
@@ -674,7 +657,7 @@ module Octokit
674
657
  def repository_assignees(repo, options = {})
675
658
  paginate "#{Repository.path repo}/assignees", options
676
659
  end
677
- alias :repo_assignees :repository_assignees
660
+ alias repo_assignees repository_assignees
678
661
 
679
662
  # Check to see if a particular user is an assignee for a repository.
680
663
  #
@@ -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
- opts = ensure_api_media_type(:vulnerability_alerts, options)
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
- opts = ensure_api_media_type(:vulnerability_alerts, options)
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,50 @@ 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
- opts = ensure_api_media_type(:vulnerability_alerts, options)
795
- boolean_from_response(:delete, "#{Repository.path repo}/vulnerability-alerts", opts)
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)
796
819
  end
797
820
  end
798
821
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Repository Invitations API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/invitations/
7
8
  module RepositoryInvitations
8
-
9
9
  # Invite a user to a repository
10
10
  #
11
11
  # Requires authenticated client
@@ -64,7 +64,7 @@ module Octokit
64
64
  # @return [Array<Sawyer::Resource>] The users repository invitations
65
65
  # @see https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations
66
66
  def user_repository_invitations(options = {})
67
- paginate "/user/repository_invitations", options
67
+ paginate '/user/repository_invitations', options
68
68
  end
69
69
  alias user_repo_invitations user_repository_invitations
70
70
 
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Reviews API
5
6
  #
6
7
  # @see https://developer.github.com/v3/pulls/reviews/
7
8
  module Reviews
8
-
9
9
  # List reviews on a pull request
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -151,7 +151,7 @@ module Octokit
151
151
  # @param number [Integer] Number ID of the pull request
152
152
  # @param reviewers [Hash] :reviewers [Array<String>] An array of user logins
153
153
  # @param options [Hash] :team_reviewers [Array<String>] An array of team slugs
154
- # @see https://developer.github.com/v3/pulls/review_requests/#create-a-review-request
154
+ # @see https://developer.github.com/v3/pulls/review_requests/#request-reviewers-for-a-pull-request
155
155
  #
156
156
  # @example
157
157
  # @client.request_pull_request_review('octokit/octokit.rb', 2, reviewers: ['soudy'])
@@ -161,9 +161,9 @@ 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
- "Please update your call to pass :reviewers and :team_reviewers as part of the options hash."
166
+ 'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
167
167
  )
168
168
  options = options.merge(reviewers: reviewers)
169
169
  else
@@ -190,13 +190,13 @@ module Octokit
190
190
  # @client.delete_pull_request_review_request('octokit/octokit.rb', 2, options)
191
191
  #
192
192
  # @return [Sawyer::Resource>] Hash representing the pull request
193
- def delete_pull_request_review_request(repo, id, reviewers={}, options = {})
193
+ def delete_pull_request_review_request(repo, id, reviewers = {}, options = {})
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
- "Please update your call to pass :reviewers and :team_reviewers as part of the options hash."
199
+ 'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
200
200
  )
201
201
  end
202
202
  # For backwards compatibility, this endpoint can be called with a separate reviewers hash.
@@ -1,19 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the unpublished Octocat API
5
6
  module Say
6
-
7
7
  # Return a nifty ASCII Octocat with GitHub wisdom
8
8
  # or your own
9
9
  #
10
10
  # @return [String]
11
11
  def say(text = nil, options = {})
12
12
  options[:s] = text if text
13
- get "octocat", options
13
+ get 'octocat', options
14
14
  end
15
- alias :octocat :say
16
-
15
+ alias octocat say
17
16
  end
18
17
  end
19
18
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Search API
5
6
  #
6
7
  # @see https://developer.github.com/v3/search/
7
8
  module Search
8
-
9
9
  # Search code
10
10
  #
11
11
  # @param query [String] Search term and qualifiers
@@ -17,7 +17,7 @@ module Octokit
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 = {})
20
- search "search/code", query, options
20
+ search 'search/code', query, options
21
21
  end
22
22
 
23
23
  # Search commits
@@ -31,8 +31,7 @@ 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
- search "search/commits", query, options
34
+ search 'search/commits', query, options
36
35
  end
37
36
 
38
37
  # Search issues
@@ -45,8 +44,9 @@ module Octokit
45
44
  # @option options [Integer] :per_page Number of items per page
46
45
  # @return [Sawyer::Resource] Search results object
47
46
  # @see https://developer.github.com/v3/search/#search-issues-and-pull-requests
47
+ # @see https://docs.github.com/en/rest/search#limitations-on-query-length
48
48
  def search_issues(query, options = {})
49
- search "search/issues", query, options
49
+ search 'search/issues', query, options
50
50
  end
51
51
 
52
52
  # Search repositories
@@ -60,9 +60,23 @@ module Octokit
60
60
  # @return [Sawyer::Resource] Search results object
61
61
  # @see https://developer.github.com/v3/search/#search-repositories
62
62
  def search_repositories(query, options = {})
63
- search "search/repositories", query, options
63
+ search 'search/repositories', query, options
64
+ end
65
+ alias search_repos search_repositories
66
+
67
+ # Search topics
68
+ #
69
+ # @param query [String] Search term and qualifiers
70
+ # @param options [Hash] Sort and pagination options
71
+ # @option options [String] :sort Sort field
72
+ # @option options [String] :order Sort order (asc or desc)
73
+ # @option options [Integer] :page Page of paginated results
74
+ # @option options [Integer] :per_page Number of items per page
75
+ # @return [Sawyer::Resource] Search results object
76
+ # @see https://developer.github.com/v3/search/#search-topics
77
+ def search_topics(query, options = {})
78
+ search 'search/topics', query, options
64
79
  end
65
- alias :search_repos :search_repositories
66
80
 
67
81
  # Search users
68
82
  #
@@ -75,13 +89,13 @@ module Octokit
75
89
  # @return [Sawyer::Resource] Search results object
76
90
  # @see https://developer.github.com/v3/search/#search-users
77
91
  def search_users(query, options = {})
78
- search "search/users", query, options
92
+ search 'search/users', query, options
79
93
  end
80
94
 
81
95
  private
82
96
 
83
97
  def search(path, query, options = {})
84
- opts = options.merge(:q => query)
98
+ opts = options.merge(q: query)
85
99
  paginate(path, opts) do |data, last_response|
86
100
  data.items.concat last_response.data.items
87
101
  end
@@ -1,37 +1,47 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the GitHub Status API
5
6
  #
6
7
  # @see https://status.github.com/api
7
8
  module ServiceStatus
8
-
9
9
  # Root for status API
10
10
  # @private
11
- STATUS_ROOT = 'https://status.github.com/api.json'
11
+ SUMMARY_ROOT = 'https://www.githubstatus.com/api/v2/summary.json'
12
+ STATUS_ROOT = 'https://www.githubstatus.com/api/v2/status.json'
13
+ COMPONENTS_ROOT = 'https://www.githubstatus.com/api/v2/components.json'
14
+
15
+ # Returns a summary with the current status and the last status messages.
16
+ #
17
+ # @return [<Sawyer::Resource>] GitHub status summary
18
+ # @see https://www.githubstatus.com/api#summory
19
+ def github_status_summary
20
+ get(SUMMARY_ROOT)
21
+ end
12
22
 
13
23
  # Returns the current system status
14
24
  #
15
25
  # @return [Sawyer::Resource] GitHub status
16
- # @see https://status.github.com/api#api-current-status
26
+ # @see https://www.githubstatus.com/api#status
17
27
  def github_status
18
- get(STATUS_ROOT).rels[:status].get.data
28
+ get(STATUS_ROOT)
19
29
  end
20
30
 
21
31
  # Returns the last human communication, status, and timestamp.
22
32
  #
23
33
  # @return [Sawyer::Resource] GitHub status last message
24
- # @see https://status.github.com/api#api-last-message
34
+ # @see https://www.githubstatus.com/api/#components
25
35
  def github_status_last_message
26
- get(STATUS_ROOT).rels[:last_message].get.data
36
+ get(COMPONENTS_ROOT).components.first
27
37
  end
28
38
 
29
39
  # Returns the most recent human communications with status and timestamp.
30
40
  #
31
41
  # @return [Array<Sawyer::Resource>] GitHub status messages
32
- # @see https://status.github.com/api#api-recent-messages
42
+ # @see https://www.githubstatus.com/api#components
33
43
  def github_status_messages
34
- get(STATUS_ROOT).rels[:messages].get.data
44
+ get(COMPONENTS_ROOT).components
35
45
  end
36
46
  end
37
47
  end