octokit 4.6.0 → 4.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +14 -13
  3. data/LICENSE.md +1 -1
  4. data/README.md +141 -60
  5. data/lib/ext/sawyer/relation.rb +10 -0
  6. data/lib/octokit/authentication.rb +10 -11
  7. data/lib/octokit/client/actions_secrets.rb +58 -0
  8. data/lib/octokit/client/actions_workflow_runs.rb +105 -0
  9. data/lib/octokit/client/actions_workflows.rb +43 -0
  10. data/lib/octokit/client/apps.rb +222 -0
  11. data/lib/octokit/client/authorizations.rb +12 -74
  12. data/lib/octokit/client/checks.rb +191 -0
  13. data/lib/octokit/client/commit_branches.rb +20 -0
  14. data/lib/octokit/client/commit_pulls.rb +20 -0
  15. data/lib/octokit/client/community_profile.rb +22 -0
  16. data/lib/octokit/client/contents.rb +6 -0
  17. data/lib/octokit/client/deployments.rb +20 -0
  18. data/lib/octokit/client/events.rb +1 -0
  19. data/lib/octokit/client/gists.rb +3 -2
  20. data/lib/octokit/client/issues.rb +48 -1
  21. data/lib/octokit/client/labels.rb +7 -7
  22. data/lib/octokit/client/licenses.rb +1 -1
  23. data/lib/octokit/client/marketplace.rb +56 -0
  24. data/lib/octokit/client/notifications.rb +0 -4
  25. data/lib/octokit/client/oauth_applications.rb +122 -0
  26. data/lib/octokit/client/organizations.rb +149 -16
  27. data/lib/octokit/client/projects.rb +7 -7
  28. data/lib/octokit/client/pull_requests.rb +7 -5
  29. data/lib/octokit/client/rate_limit.rb +2 -2
  30. data/lib/octokit/client/refs.rb +19 -3
  31. data/lib/octokit/client/releases.rb +1 -0
  32. data/lib/octokit/client/repositories.rb +169 -8
  33. data/lib/octokit/client/repository_invitations.rb +1 -8
  34. data/lib/octokit/client/reviews.rb +227 -0
  35. data/lib/octokit/client/search.rb +24 -9
  36. data/lib/octokit/client/source_import.rb +1 -1
  37. data/lib/octokit/client/stats.rb +2 -0
  38. data/lib/octokit/client/statuses.rb +2 -2
  39. data/lib/octokit/client/users.rb +88 -1
  40. data/lib/octokit/client.rb +41 -9
  41. data/lib/octokit/configurable.rb +10 -2
  42. data/lib/octokit/connection.rb +19 -4
  43. data/lib/octokit/default.rb +17 -1
  44. data/lib/octokit/enterprise_admin_client/admin_stats.rb +1 -1
  45. data/lib/octokit/enterprise_admin_client/license.rb +1 -1
  46. data/lib/octokit/enterprise_admin_client/orgs.rb +2 -2
  47. data/lib/octokit/enterprise_admin_client/search_indexing.rb +1 -1
  48. data/lib/octokit/enterprise_admin_client/users.rb +12 -12
  49. data/lib/octokit/enterprise_management_console_client/management_console.rb +1 -1
  50. data/lib/octokit/enterprise_management_console_client.rb +1 -1
  51. data/lib/octokit/error.rb +74 -4
  52. data/lib/octokit/gist.rb +1 -1
  53. data/lib/octokit/middleware/follow_redirects.rb +2 -2
  54. data/lib/octokit/preview.rb +14 -3
  55. data/lib/octokit/rate_limit.rb +4 -4
  56. data/lib/octokit/repository.rb +10 -8
  57. data/lib/octokit/response/feed_parser.rb +0 -2
  58. data/lib/octokit/response/raise_error.rb +0 -2
  59. data/lib/octokit/version.rb +1 -1
  60. data/octokit.gemspec +2 -1
  61. metadata +39 -9
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+
6
+ # Methods for the OauthApplications API
7
+ #
8
+ # @see https://developer.github.com/v3/apps/oauth_applications
9
+ module OauthApplications
10
+
11
+ # Check if a token is valid.
12
+ #
13
+ # Applications can check if a token is valid without rate limits.
14
+ #
15
+ # @param access_token [String] 40 character GitHub OAuth access token
16
+ #
17
+ # @return [Sawyer::Resource] A single authorization for the authenticated user
18
+ # @see https://developer.github.com/v3/apps/oauth_applications/#check-a-token
19
+ #
20
+ # @example
21
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
22
+ # client.check_token('deadbeef1234567890deadbeef987654321')
23
+ def check_token(access_token, options = {})
24
+ options = ensure_api_media_type(:applications_api, options.dup)
25
+ options[:access_token] = access_token
26
+
27
+ key = options.delete(:client_id) || client_id
28
+ secret = options.delete(:client_secret) || client_secret
29
+
30
+ as_app(key, secret) do |app_client|
31
+ app_client.post "applications/#{client_id}/token", options
32
+ end
33
+ end
34
+ alias check_application_authorization check_token
35
+
36
+ # Reset a token
37
+ #
38
+ # Applications can reset a token without requiring a user to re-authorize.
39
+ #
40
+ # @param access_token [String] 40 character GitHub OAuth access token
41
+ #
42
+ # @return [Sawyer::Resource] A single authorization for the authenticated user
43
+ # @see https://developer.github.com/v3/apps/oauth_applications/#reset-a-token
44
+ #
45
+ # @example
46
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
47
+ # client.reset_token('deadbeef1234567890deadbeef987654321')
48
+ def reset_token(access_token, options = {})
49
+ options = ensure_api_media_type(:applications_api, options.dup)
50
+ options[:access_token] = access_token
51
+
52
+ key = options.delete(:client_id) || client_id
53
+ secret = options.delete(:client_secret) || client_secret
54
+
55
+ as_app(key, secret) do |app_client|
56
+ app_client.patch "applications/#{client_id}/token", options
57
+ end
58
+ end
59
+ alias reset_application_authorization reset_token
60
+
61
+ # Delete an app token
62
+ #
63
+ # Applications can revoke (delete) a token
64
+ #
65
+ # @param access_token [String] 40 character GitHub OAuth access token
66
+ #
67
+ # @return [Boolean] Result
68
+ # @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
69
+ #
70
+ # @example
71
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
72
+ # client.delete_token('deadbeef1234567890deadbeef987654321')
73
+ def delete_app_token(access_token, options = {})
74
+ options = ensure_api_media_type(:applications_api, options.dup)
75
+ options[:access_token] = access_token
76
+
77
+ key = options.delete(:client_id) || client_id
78
+ secret = options.delete(:client_secret) || client_secret
79
+
80
+ begin
81
+ as_app(key, secret) do |app_client|
82
+ app_client.delete "applications/#{client_id}/token", options
83
+ app_client.last_response.status == 204
84
+ end
85
+ rescue Octokit::NotFound
86
+ false
87
+ end
88
+ end
89
+ alias delete_application_authorization delete_app_token
90
+ alias revoke_application_authorization delete_app_token
91
+
92
+ # Delete an app authorization
93
+ #
94
+ # OAuth application owners can revoke a grant for their OAuth application and a specific user.
95
+ #
96
+ # @param access_token [String] 40 character GitHub OAuth access token
97
+ #
98
+ # @return [Boolean] Result
99
+ # @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
100
+ #
101
+ # @example
102
+ # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
103
+ # client.delete_app_authorization('deadbeef1234567890deadbeef987654321')
104
+ def delete_app_authorization(access_token, options = {})
105
+ options = ensure_api_media_type(:applications_api, options.dup)
106
+ options[:access_token] = access_token
107
+
108
+ key = options.delete(:client_id) || client_id
109
+ secret = options.delete(:client_secret) || client_secret
110
+
111
+ begin
112
+ as_app(key, secret) do |app_client|
113
+ app_client.delete "applications/#{client_id}/grant", options
114
+ app_client.last_response.status == 204
115
+ end
116
+ rescue Octokit::NotFound
117
+ false
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -31,6 +31,8 @@ module Octokit
31
31
  # @option values [String] :email Publicly visible email address.
32
32
  # @option values [String] :location Location of organization.
33
33
  # @option values [String] :name GitHub username for organization.
34
+ # @option values [String] :default_repository_permission The default permission members have on organization repositories.
35
+ # @option values [Boolean] :members_can_create_repositories Set true to allow members to create repositories on the organization.
34
36
  # @return [Sawyer::Resource] Hash representing GitHub organization.
35
37
  # @see https://developer.github.com/v3/orgs/#edit-an-organization
36
38
  # @example
@@ -96,7 +98,7 @@ module Octokit
96
98
  #
97
99
  # @return [Array<Sawyer::Resource>] List of GitHub organizations.
98
100
  def all_organizations(options = {})
99
- paginate "organizations"
101
+ paginate "organizations", options
100
102
  end
101
103
  alias :all_orgs :all_organizations
102
104
 
@@ -140,6 +142,7 @@ module Octokit
140
142
  # @example
141
143
  # Octokit.org_members('github')
142
144
  def organization_members(org, options = {})
145
+ options = options.dup
143
146
  path = "public_" if options.delete(:public)
144
147
  paginate "#{Organization.path org}/#{path}members", options
145
148
  end
@@ -207,6 +210,65 @@ module Octokit
207
210
  end
208
211
  alias :org_public_member? :organization_public_member?
209
212
 
213
+ # List pending organization invitations
214
+ #
215
+ # Requires authenticated organization member.
216
+ #
217
+ # @param org [String, Integer] Organization GitHub login or id.
218
+ # @return [Array<Sawyer::Resource>] Array of hashes representing invitations.
219
+ # @see https://developer.github.com/v3/orgs/members/#list-pending-organization-invitations
220
+ #
221
+ # @example
222
+ # @client.organization_invitations('github')
223
+ def organization_invitations(org, options = {})
224
+ get "#{Organization.path org}/invitations", options
225
+ end
226
+ alias :org_invitations :organization_invitations
227
+
228
+ # List outside collaborators for an organization
229
+ #
230
+ # Requires authenticated organization members.
231
+ #
232
+ # @param org [String, Integer] Organization GitHub login or id.
233
+ # @return [Array<Sawyer::Resource>] Array of hashes representing users.
234
+ # @see https://developer.github.com/v3/orgs/outside_collaborators/#list-outside-collaborators
235
+ #
236
+ # @example
237
+ # @client.outside_collaborators('github')
238
+ def outside_collaborators(org, options={})
239
+ paginate "#{Organization.path org}/outside_collaborators", options
240
+ end
241
+
242
+ # Remove outside collaborator from an organization
243
+ #
244
+ # Requires authenticated organization members.
245
+ #
246
+ # @param org [String, Integer] Organization GitHub login or id.
247
+ # @param user [String] GitHub username to be removed as outside collaborator
248
+ # @return [Boolean] Return true if outside collaborator removed from organization, false otherwise.
249
+ # @see https://developer.github.com/v3/orgs/outside-collaborators/#remove-outside-collaborator
250
+ #
251
+ # @example
252
+ # @client.remove_outside_collaborator('github', 'lizzhale')
253
+ def remove_outside_collaborator(org, user, options={})
254
+ boolean_from_response :delete, "#{Organization.path org}/outside_collaborators/#{user}", options
255
+ end
256
+
257
+ # Converts an organization member to an outside collaborator
258
+ #
259
+ # Requires authenticated organization members.
260
+ #
261
+ # @param org [String, Integer] Organization GitHub login or id.
262
+ # @param user [String] GitHub username to be removed as outside collaborator
263
+ # @return [Boolean] Return true if outside collaborator removed from organization, false otherwise.
264
+ # @see https://developer.github.com/v3/orgs/outside-collaborators/#convert-member-to-outside-collaborator
265
+ #
266
+ # @example
267
+ # @client.convert_to_outside_collaborator('github', 'lizzhale')
268
+ def convert_to_outside_collaborator(org, user, options={})
269
+ boolean_from_response :put, "#{Organization.path org}/outside_collaborators/#{user}", options
270
+ end
271
+
210
272
  # List teams
211
273
  #
212
274
  # Requires authenticated organization member.
@@ -230,6 +292,8 @@ module Octokit
230
292
  # @param org [String, Integer] Organization GitHub login or id.
231
293
  # @option options [String] :name Team name.
232
294
  # @option options [Array<String>] :repo_names Repositories for the team.
295
+ # @option options [Array<String>] :maintainers Maintainers for the team.
296
+ # @option options [Integer] :parent_team_id ID of a team to set as the parent team.
233
297
  # @return [Sawyer::Resource] Hash representing new team.
234
298
  # @see https://developer.github.com/v3/orgs/teams/#create-team
235
299
  # @example
@@ -241,6 +305,9 @@ module Octokit
241
305
  if options.key?(:permission)
242
306
  octokit_warn "Deprecated: Passing :permission option to #create_team. Assign team repository permission by passing :permission to #add_team_repository instead."
243
307
  end
308
+ if options.key?(:parent_team_id)
309
+ options = ensure_api_media_type(:nested_teams, options)
310
+ end
244
311
  post "#{Organization.path org}/teams", options
245
312
  end
246
313
 
@@ -257,6 +324,34 @@ module Octokit
257
324
  get "teams/#{team_id}", options
258
325
  end
259
326
 
327
+ # Get team by name and org
328
+ #
329
+ # Requires authenticated organization member.
330
+ #
331
+ # @param org [String, Integer] Organization GitHub login or id.
332
+ # @param team_slug [String] Team slug.
333
+ # @return [Sawyer::Resource] Hash representing team.
334
+ # @see https://developer.github.com/v3/teams/#get-team-by-name
335
+ # @example
336
+ # @client.team_by_name("github", "justice-league")
337
+ def team_by_name(org, team_slug, options = {})
338
+ get "#{Organization.path(org)}/teams/#{team_slug}", options
339
+ end
340
+
341
+ # List child teams
342
+ #
343
+ # Requires authenticated organization member.
344
+ #
345
+ # @param team_id [Integer] Team id.
346
+ # @return [Sawyer::Resource] Hash representing team.
347
+ # @see https://developer.github.com/v3/orgs/teams/#list-child-teams
348
+ # @example
349
+ # @client.child_teams(100000, :accept => "application/vnd.github.hellcat-preview+json")
350
+ def child_teams(team_id, options = {})
351
+ options = ensure_api_media_type(:nested_teams, options)
352
+ paginate "teams/#{team_id}/teams", options
353
+ end
354
+
260
355
  # Update team
261
356
  #
262
357
  # Requires authenticated organization owner.
@@ -268,6 +363,7 @@ module Octokit
268
363
  # `pull` - team members can pull, but not push to or administer these repositories.
269
364
  # `push` - team members can pull and push, but not administer these repositories.
270
365
  # `admin` - team members can pull, push and administer these repositories.
366
+ # @option options [Integer] :parent_team_id ID of a team to set as the parent team.
271
367
  # @return [Sawyer::Resource] Hash representing updated team.
272
368
  # @see https://developer.github.com/v3/orgs/teams/#edit-team
273
369
  # @example
@@ -276,6 +372,9 @@ module Octokit
276
372
  # :permission => 'push'
277
373
  # })
278
374
  def update_team(team_id, options = {})
375
+ if options.key?(:parent_team_id)
376
+ options = ensure_api_media_type(:nested_teams, options)
377
+ end
279
378
  patch "teams/#{team_id}", options
280
379
  end
281
380
 
@@ -361,12 +460,26 @@ module Octokit
361
460
  # @see https://developer.github.com/v3/orgs/teams/#get-team-member
362
461
  #
363
462
  # @example Check if a user is in your team
364
- # @client.team_member?('your_team', 'pengwynn')
463
+ # @client.team_member?(100000, 'pengwynn')
365
464
  # => false
366
465
  def team_member?(team_id, user, options = {})
367
466
  boolean_from_response :get, "teams/#{team_id}/members/#{user}", options
368
467
  end
369
468
 
469
+ # List pending team invitations
470
+ #
471
+ # Requires authenticated organization member.
472
+ #
473
+ # @param team_id [Integer] Team id.
474
+ # @return [Array<Sawyer::Resource>] Array of hashes representing invitations.
475
+ # @see https://developer.github.com/v3/orgs/teams/#list-pending-team-invitations
476
+ #
477
+ # @example
478
+ # @client.team_invitations('github')
479
+ def team_invitations(team_id, options = {})
480
+ get "teams/#{team_id}/invitations", options
481
+ end
482
+
370
483
  # List team repositories
371
484
  #
372
485
  # Requires authenticated organization member.
@@ -425,7 +538,7 @@ module Octokit
425
538
  # @example Add a team with admin permissions
426
539
  # @client.add_team_repository(100000, 'github/developer.github.com', permission: 'admin')
427
540
  def add_team_repository(team_id, repo, options = {})
428
- boolean_from_response :put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options.merge(:name => Repository.new(repo))
541
+ boolean_from_response :put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options
429
542
  end
430
543
  alias :add_team_repo :add_team_repository
431
544
 
@@ -529,7 +642,7 @@ module Octokit
529
642
  #
530
643
  # @return [Sawyer::Resource] Hash of team membership info
531
644
  #
532
- # @see https://developer.github.com/v3/orgs/teams/#add-team-membership
645
+ # @see https://developer.github.com/v3/orgs/teams/#add-or-update-team-membership
533
646
  #
534
647
  # @example Check if a user has a membership for a team
535
648
  # @client.add_team_membership(1234, 'pengwynn')
@@ -560,14 +673,15 @@ module Octokit
560
673
 
561
674
  # Get an organization membership
562
675
  #
563
- # @param org [String] Organization GitHub login.
676
+ # @param org [Integer, String] The GitHub Organization.
564
677
  # @option options [String] :user The login of the user, otherwise authenticated user.
565
678
  # @return [Sawyer::Resource] Hash representing the organization membership.
566
679
  # @see https://developer.github.com/v3/orgs/members/#get-your-organization-membership
567
680
  # @see https://developer.github.com/v3/orgs/members/#get-organization-membership
568
681
  def organization_membership(org, options = {})
682
+ options = options.dup
569
683
  if user = options.delete(:user)
570
- get "orgs/#{org}/memberships/#{user}", options
684
+ get "#{Organization.path(org)}/memberships/#{user}", options
571
685
  else
572
686
  get "user/memberships/orgs/#{org}", options
573
687
  end
@@ -576,7 +690,7 @@ module Octokit
576
690
 
577
691
  # Edit an organization membership
578
692
  #
579
- # @param org [String] Organization GitHub login.
693
+ # @param org [String, Integer] Organization GitHub login or id.
580
694
  # @option options [String] :role The role of the user in the organization.
581
695
  # @option options [String] :state The state that the membership should be in.
582
696
  # @option options [String] :user The login of the user, otherwise authenticated user.
@@ -584,9 +698,12 @@ module Octokit
584
698
  # @see https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
585
699
  # @see https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership
586
700
  def update_organization_membership(org, options = {})
701
+ options = options.dup
587
702
  if user = options.delete(:user)
588
- put "orgs/#{org}/memberships/#{user}", options
703
+ options.delete(:state)
704
+ put "#{Organization.path(org)}/memberships/#{user}", options
589
705
  else
706
+ options.delete(:role)
590
707
  patch "user/memberships/orgs/#{org}", options
591
708
  end
592
709
  end
@@ -594,13 +711,15 @@ module Octokit
594
711
 
595
712
  # Remove an organization membership
596
713
  #
597
- # @param org [String] Organization GitHub login.
714
+ # @param org [String, Integer] Organization GitHub login or id.
598
715
  # @return [Boolean] Success
599
716
  # @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
600
717
  def remove_organization_membership(org, options = {})
718
+ options = options.dup
601
719
  user = options.delete(:user)
602
- user && boolean_from_response(:delete, "orgs/#{org}/memberships/#{user}", options)
720
+ user && boolean_from_response(:delete, "#{Organization.path(org)}/memberships/#{user}", options)
603
721
  end
722
+ alias :remove_org_membership :remove_organization_membership
604
723
 
605
724
  # Initiates the generation of a migration archive.
606
725
  #
@@ -616,7 +735,7 @@ module Octokit
616
735
  def start_migration(org, repositories, options = {})
617
736
  options = ensure_api_media_type(:migrations, options)
618
737
  options[:repositories] = repositories
619
- post "orgs/#{org}/migrations", options
738
+ post "#{Organization.path(org)}/migrations", options
620
739
  end
621
740
 
622
741
  # Lists the most recent migrations.
@@ -628,7 +747,7 @@ module Octokit
628
747
  # @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
629
748
  def migrations(org, options = {})
630
749
  options = ensure_api_media_type(:migrations, options)
631
- paginate "orgs/#{org}/migrations", options
750
+ paginate "#{Organization.path(org)}/migrations", options
632
751
  end
633
752
 
634
753
  # Fetches the status of a migration.
@@ -640,7 +759,7 @@ module Octokit
640
759
  # @see https://developer.github.com/v3/orgs/migrations/#get-the-status-of-a-migration
641
760
  def migration_status(org, id, options = {})
642
761
  options = ensure_api_media_type(:migrations, options)
643
- get "orgs/#{org}/migrations/#{id}", options
762
+ get "#{Organization.path(org)}/migrations/#{id}", options
644
763
  end
645
764
 
646
765
  # Fetches the URL to a migration archive.
@@ -652,7 +771,7 @@ module Octokit
652
771
  # @see https://developer.github.com/v3/orgs/migrations/#download-a-migration-archive
653
772
  def migration_archive_url(org, id, options = {})
654
773
  options = ensure_api_media_type(:migrations, options)
655
- url = "orgs/#{org}/migrations/#{id}/archive"
774
+ url = "#{Organization.path(org)}/migrations/#{id}/archive"
656
775
 
657
776
  response = client_without_redirects(options).get(url)
658
777
  response.headers['location']
@@ -667,7 +786,7 @@ module Octokit
667
786
  # @see https://developer.github.com/v3/orgs/migrations/#delete-a-migration-archive
668
787
  def delete_migration_archive(org, id, options = {})
669
788
  options = ensure_api_media_type(:migrations, options)
670
- delete "orgs/#{org}/migrations/#{id}/archive", options
789
+ delete "#{Organization.path(org)}/migrations/#{id}/archive", options
671
790
  end
672
791
 
673
792
  # Unlock a previous migration archive.
@@ -680,7 +799,21 @@ module Octokit
680
799
  # @see https://developer.github.com/v3/orgs/migrations/#unlock-a-repository
681
800
  def unlock_repository(org, id, repo, options = {})
682
801
  options = ensure_api_media_type(:migrations, options)
683
- delete "orgs/#{org}/migrations/#{id}/repos/#{repo}/lock", options
802
+ delete "#{Organization.path(org)}/migrations/#{id}/repos/#{repo}/lock", options
803
+ end
804
+
805
+ # Get GitHub Actions billing for an organization
806
+ #
807
+ # Requires authenticated organization owner.
808
+ #
809
+ # @param org [String, Integer] Organization GitHub login or id.
810
+ # @return [Sawyer::Resource] Hash representing GitHub Actions billing for an organization.
811
+ # @see https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-an-organization
812
+ #
813
+ # @example
814
+ # @client.billing_actions('github')
815
+ def billing_actions(org)
816
+ get "#{Organization.path(org)}/settings/billing/actions"
684
817
  end
685
818
  end
686
819
  end
@@ -51,7 +51,7 @@ module Octokit
51
51
  # @client.org_projects("octokit")
52
52
  def org_projects(org, options = {})
53
53
  opts = ensure_api_media_type(:projects, options)
54
- get "orgs/#{org}/projects", opts
54
+ paginate "orgs/#{org}/projects", opts
55
55
  end
56
56
  alias :organization_projects :org_projects
57
57
 
@@ -81,7 +81,7 @@ module Octokit
81
81
  # @return [Sawyer::Resource] Project
82
82
  # @see https://developer.github.com/v3/projects/#get-a-project
83
83
  # @example
84
- # Octokit.project("octokit/octokit.rb", 1)
84
+ # Octokit.project(123942)
85
85
  def project(id, options = {})
86
86
  opts = ensure_api_media_type(:projects, options)
87
87
  get "projects/#{id}", opts
@@ -123,7 +123,7 @@ module Octokit
123
123
  # @return [Array<Sawyer::Resource>] List of project columns
124
124
  # @see https://developer.github.com/v3/projects/columns/#list-project-columns
125
125
  # @example
126
- # @client.project_columns("octokit/octokit.rb", 1)
126
+ # @client.project_columns(123942)
127
127
  def project_columns(id, options = {})
128
128
  opts = ensure_api_media_type(:projects, options)
129
129
  paginate "projects/#{id}/columns", opts
@@ -138,7 +138,7 @@ module Octokit
138
138
  # @return [Sawyer::Resource] Newly created column
139
139
  # @see https://developer.github.com/v3/projects/columns/#create-a-project-column
140
140
  # @example
141
- # @client.create_project_column("octokit/octokit.rb", 1, "To Dones")
141
+ # @client.create_project_column(123942, "To Dones")
142
142
  def create_project_column(id, name, options = {})
143
143
  opts = ensure_api_media_type(:projects, options)
144
144
  opts[:name] = name
@@ -151,7 +151,7 @@ module Octokit
151
151
  # @return [Sawyer::Resource] Project column
152
152
  # @see https://developer.github.com/v3/projects/columns/#get-a-project-column
153
153
  # @example
154
- # Octokit.project_column(123940, 30)
154
+ # Octokit.project_column(30294)
155
155
  def project_column(id, options = {})
156
156
  opts = ensure_api_media_type(:projects, options)
157
157
  get "projects/columns/#{id}", opts
@@ -198,7 +198,7 @@ module Octokit
198
198
  # @return [Sawyer::Resource] Result
199
199
  # @see https://developer.github.com/v3/projects/columns/#move-a-project-column
200
200
  # @example
201
- # @client.move_project_column(3049, "last")
201
+ # @client.move_project_column(30294, "last")
202
202
  def move_project_column(id, position, options = {})
203
203
  opts = ensure_api_media_type(:projects, options)
204
204
  opts[:position] = position
@@ -213,7 +213,7 @@ module Octokit
213
213
  # @return [Array<Sawyer::Resource>] Cards in the column
214
214
  # @see https://developer.github.com/v3/projects/cards/#list-project-cards
215
215
  # @example
216
- # @client.column_cards(123847)
216
+ # @client.column_cards(30294)
217
217
  def column_cards(id, options = {})
218
218
  opts = ensure_api_media_type(:projects, options)
219
219
  paginate "projects/columns/#{id}/cards", opts
@@ -11,7 +11,7 @@ module Octokit
11
11
  # @overload pull_requests(repo, options)
12
12
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
13
13
  # @param options [Hash] Method options
14
- # @option options [String] :state `open` or `closed`.
14
+ # @option options [String] :state `open` or `closed` or `all`.
15
15
  # @return [Array<Sawyer::Resource>] Array of pulls
16
16
  # @see https://developer.github.com/v3/pulls/#list-pull-requests
17
17
  # @example
@@ -27,6 +27,8 @@ module Octokit
27
27
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
28
28
  # @param number [Integer] Number of the pull request to fetch
29
29
  # @return [Sawyer::Resource] Pull request info
30
+ # @example
31
+ # Octokit.pull_request('rails/rails', 42, :state => 'closed')
30
32
  def pull_request(repo, number, options = {})
31
33
  get "#{Repository.path repo}/pulls/#{number}", options
32
34
  end
@@ -78,14 +80,14 @@ module Octokit
78
80
  end
79
81
 
80
82
  # Update a pull request
81
- # @overload update_pull_request(repo, id, title=nil, body=nil, state=nil, options = {})
83
+ # @overload update_pull_request(repo, number, title=nil, body=nil, state=nil, options = {})
82
84
  # @deprecated
83
85
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
84
86
  # @param number [Integer] Number of pull request to update.
85
87
  # @param title [String] Title for the pull request.
86
88
  # @param body [String] Body content for pull request. Supports GFM.
87
89
  # @param state [String] State of the pull request. `open` or `closed`.
88
- # @overload update_pull_request(repo, id, options = {})
90
+ # @overload update_pull_request(repo, number, options = {})
89
91
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
90
92
  # @param number [Integer] Number of pull request to update.
91
93
  # @option options [String] :title Title for the pull request.
@@ -151,8 +153,8 @@ module Octokit
151
153
  #
152
154
  # @example Get review comments, sort by updated asc since a time
153
155
  # @client.pull_requests_comments("octokit/octokit.rb", {
154
- # :sort => 'asc',
155
- # :direction => 'down',
156
+ # :sort => 'updated',
157
+ # :direction => 'asc',
156
158
  # :since => '2010-05-04T23:45:02Z'
157
159
  # })
158
160
  def pull_requests_comments(repo, options = {})
@@ -21,7 +21,7 @@ module Octokit
21
21
  # Get number of rate limted requests remaining
22
22
  #
23
23
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
24
- # @return [Fixnum] Number of requests remaining in this period
24
+ # @return [Integer] Number of requests remaining in this period
25
25
  def rate_limit_remaining(options = {})
26
26
  octokit_warn "Deprecated: Please use .rate_limit.remaining"
27
27
  rate_limit.remaining
@@ -41,7 +41,7 @@ module Octokit
41
41
  # Refresh rate limit info and get number of rate limted requests remaining
42
42
  #
43
43
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
44
- # @return [Fixnum] Number of requests remaining in this period
44
+ # @return [Integer] Number of requests remaining in this period
45
45
  def rate_limit_remaining!(options = {})
46
46
  octokit_warn "Deprecated: Please use .rate_limit!.remaining"
47
47
  rate_limit!.remaining
@@ -23,6 +23,18 @@ module Octokit
23
23
  alias :references :refs
24
24
  alias :list_references :refs
25
25
 
26
+ # Fetch matching refs
27
+ #
28
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
29
+ # @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt> or <tt>heads/rails-3</tt>
30
+ # @return [Array<Sawyer::Resource>] The reference matching the given repo and the ref id
31
+ # @see https://developer.github.com/v3/git/refs/#list-matching-references
32
+ # @example Fetch refs matching tags/v2 for sferik/rails_admin
33
+ # Octokit.ref("sferik/rails_admin","tags/v2")
34
+ def matching_refs(repo, ref, options = {})
35
+ paginate "#{Repository.path repo}/git/matching-refs/#{ref}", options
36
+ end
37
+
26
38
  # Fetch a given reference
27
39
  #
28
40
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -60,11 +72,13 @@ module Octokit
60
72
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
61
73
  # @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
62
74
  # @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
63
- # @param force [Boolean] A flag indicating one wants to force the update to make sure the update is a fast-forward update.
75
+ # @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
64
76
  # @return [Array<Sawyer::Resource>] The list of references updated
65
77
  # @see https://developer.github.com/v3/git/refs/#update-a-reference
66
78
  # @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
67
79
  # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
80
+ # @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
81
+ # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
68
82
  def update_ref(repo, ref, sha, force = true, options = {})
69
83
  parameters = {
70
84
  :sha => sha,
@@ -79,11 +93,13 @@ module Octokit
79
93
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
80
94
  # @param branch [String] The ref, e.g. <tt>feature/new-shiny</tt>
81
95
  # @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
82
- # @param force [Boolean] A flag indicating one wants to force the update to make sure the update is a fast-forward update.
96
+ # @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
83
97
  # @return [Array<Sawyer::Resource>] The list of references updated
84
98
  # @see https://developer.github.com/v3/git/refs/#update-a-reference
85
99
  # @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
86
- # Octokit.update_ref("octocat/Hello-World","sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
100
+ # Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
101
+ # @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
102
+ # Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
87
103
  def update_branch(repo, branch, sha, force = true, options = {})
88
104
  update_ref repo, "heads/#{branch}", sha, force, options
89
105
  end
@@ -44,6 +44,7 @@ module Octokit
44
44
  # Update a release
45
45
  #
46
46
  # @param url [String] URL for the release as returned from .releases
47
+ # @option options [String] :tag_name Git tag from which to create release
47
48
  # @option options [String] :target_commitish Specifies the commitish value that determines where the Git tag is created from.
48
49
  # @option options [String] :name Name for the release
49
50
  # @option options [String] :body Content for release notes