octokit 4.13.0 → 4.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +14 -13
- data/README.md +38 -12
- data/lib/octokit/authentication.rb +2 -11
- data/lib/octokit/client.rb +21 -10
- data/lib/octokit/client/actions_secrets.rb +58 -0
- data/lib/octokit/client/actions_workflow_runs.rb +94 -0
- data/lib/octokit/client/actions_workflows.rb +43 -0
- data/lib/octokit/client/apps.rb +34 -8
- data/lib/octokit/client/authorizations.rb +2 -70
- data/lib/octokit/client/checks.rb +211 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/events.rb +1 -0
- data/lib/octokit/client/issues.rb +7 -2
- data/lib/octokit/client/oauth_applications.rb +122 -0
- data/lib/octokit/client/organizations.rb +24 -10
- data/lib/octokit/client/projects.rb +1 -1
- data/lib/octokit/client/pull_requests.rb +1 -1
- data/lib/octokit/client/refs.rb +7 -3
- data/lib/octokit/client/repositories.rb +47 -10
- data/lib/octokit/client/repository_invitations.rb +1 -1
- data/lib/octokit/client/reviews.rb +18 -0
- data/lib/octokit/client/search.rb +1 -1
- data/lib/octokit/client/users.rb +86 -0
- data/lib/octokit/connection.rb +14 -3
- data/lib/octokit/error.rb +33 -1
- data/lib/octokit/middleware/follow_redirects.rb +1 -1
- data/lib/octokit/preview.rb +9 -1
- data/lib/octokit/rate_limit.rb +1 -1
- data/lib/octokit/repository.rb +1 -1
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +2 -1
- metadata +34 -8
@@ -131,6 +131,7 @@ module Octokit
|
|
131
131
|
# @example List all issues events for issue #38 on octokit/octokit.rb
|
132
132
|
# Octokit.issue_events("octokit/octokit.rb", 38)
|
133
133
|
def issue_events(repo, number, options = {})
|
134
|
+
options = ensure_api_media_type(:project_card_events, options)
|
134
135
|
paginate "#{Repository.path repo}/issues/#{number}/events", options
|
135
136
|
end
|
136
137
|
|
@@ -81,6 +81,7 @@ module Octokit
|
|
81
81
|
# @param body [String] An optional concise description
|
82
82
|
# @param options [Hash] A customizable set of options.
|
83
83
|
# @option options [String] :assignee User login.
|
84
|
+
# @option options [Array<String>] :assignees User login.
|
84
85
|
# @option options [Integer] :milestone Milestone number.
|
85
86
|
# @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
|
86
87
|
# @return [Sawyer::Resource] Your newly created issue
|
@@ -120,6 +121,7 @@ module Octokit
|
|
120
121
|
# @param number [Integer] Number ID of the issue
|
121
122
|
# @param options [Hash] A customizable set of options.
|
122
123
|
# @option options [String] :assignee User login.
|
124
|
+
# @option options [Array<String>] :assignees User login.
|
123
125
|
# @option options [Integer] :milestone Milestone number.
|
124
126
|
# @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
|
125
127
|
# @return [Sawyer::Resource] The updated Issue
|
@@ -136,6 +138,7 @@ module Octokit
|
|
136
138
|
# @param number [Integer] Number ID of the issue
|
137
139
|
# @param options [Hash] A customizable set of options.
|
138
140
|
# @option options [String] :assignee User login.
|
141
|
+
# @option options [Array<String>] :assignees User login.
|
139
142
|
# @option options [Integer] :milestone Milestone number.
|
140
143
|
# @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
|
141
144
|
# @return [Sawyer::Resource] The updated Issue
|
@@ -179,6 +182,7 @@ module Octokit
|
|
179
182
|
# @param body [String] Updated body of the issue
|
180
183
|
# @param options [Hash] A customizable set of options.
|
181
184
|
# @option options [String] :assignee User login.
|
185
|
+
# @option options [Array<String>] :assignees User login.
|
182
186
|
# @option options [Integer] :milestone Milestone number.
|
183
187
|
# @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
|
184
188
|
# @option options [String] :state State of the issue. <tt>open</tt> or <tt>closed</tt>
|
@@ -190,6 +194,7 @@ module Octokit
|
|
190
194
|
# @option options [String] :title Updated title for the issue
|
191
195
|
# @option options [String] :body Updated body of the issue
|
192
196
|
# @option options [String] :assignee User login.
|
197
|
+
# @option options [Array<String>] :assignees User login.
|
193
198
|
# @option options [Integer] :milestone Milestone number.
|
194
199
|
# @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
|
195
200
|
# @option options [String] :state State of the issue. <tt>open</tt> or <tt>closed</tt>
|
@@ -332,7 +337,7 @@ module Octokit
|
|
332
337
|
#
|
333
338
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
334
339
|
# @param number [Integer] Issue number
|
335
|
-
# @param assignees [Array] Assignees to be added
|
340
|
+
# @param assignees [Array<String>] Assignees to be added
|
336
341
|
# @return [Sawyer::Resource] Issue
|
337
342
|
# @see https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue
|
338
343
|
# @example Add assignees "pengwynn" and "joeyw" to Issue #23 on octokit/octokit.rb
|
@@ -345,7 +350,7 @@ module Octokit
|
|
345
350
|
#
|
346
351
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
347
352
|
# @param number [Integer] Issue number
|
348
|
-
# @param assignees [Array] Assignees to be removed
|
353
|
+
# @param assignees [Array<String>] Assignees to be removed
|
349
354
|
# @param options [Hash] Header params for request
|
350
355
|
# @return [Sawyer::Resource] Issue
|
351
356
|
# @see https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue
|
@@ -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
|
@@ -324,6 +324,20 @@ module Octokit
|
|
324
324
|
get "teams/#{team_id}", options
|
325
325
|
end
|
326
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
|
+
|
327
341
|
# List child teams
|
328
342
|
#
|
329
343
|
# Requires authenticated organization member.
|
@@ -676,7 +690,7 @@ module Octokit
|
|
676
690
|
|
677
691
|
# Edit an organization membership
|
678
692
|
#
|
679
|
-
# @param org [String] Organization GitHub login.
|
693
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
680
694
|
# @option options [String] :role The role of the user in the organization.
|
681
695
|
# @option options [String] :state The state that the membership should be in.
|
682
696
|
# @option options [String] :user The login of the user, otherwise authenticated user.
|
@@ -687,7 +701,7 @@ module Octokit
|
|
687
701
|
options = options.dup
|
688
702
|
if user = options.delete(:user)
|
689
703
|
options.delete(:state)
|
690
|
-
put "
|
704
|
+
put "#{Organization.path(org)}/memberships/#{user}", options
|
691
705
|
else
|
692
706
|
options.delete(:role)
|
693
707
|
patch "user/memberships/orgs/#{org}", options
|
@@ -697,13 +711,13 @@ module Octokit
|
|
697
711
|
|
698
712
|
# Remove an organization membership
|
699
713
|
#
|
700
|
-
# @param org [String] Organization GitHub login.
|
714
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
701
715
|
# @return [Boolean] Success
|
702
716
|
# @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
|
703
717
|
def remove_organization_membership(org, options = {})
|
704
718
|
options = options.dup
|
705
719
|
user = options.delete(:user)
|
706
|
-
user && boolean_from_response(:delete, "
|
720
|
+
user && boolean_from_response(:delete, "#{Organization.path(org)}/memberships/#{user}", options)
|
707
721
|
end
|
708
722
|
alias :remove_org_membership :remove_organization_membership
|
709
723
|
|
@@ -721,7 +735,7 @@ module Octokit
|
|
721
735
|
def start_migration(org, repositories, options = {})
|
722
736
|
options = ensure_api_media_type(:migrations, options)
|
723
737
|
options[:repositories] = repositories
|
724
|
-
post "
|
738
|
+
post "#{Organization.path(org)}/migrations", options
|
725
739
|
end
|
726
740
|
|
727
741
|
# Lists the most recent migrations.
|
@@ -733,7 +747,7 @@ module Octokit
|
|
733
747
|
# @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
|
734
748
|
def migrations(org, options = {})
|
735
749
|
options = ensure_api_media_type(:migrations, options)
|
736
|
-
paginate "
|
750
|
+
paginate "#{Organization.path(org)}/migrations", options
|
737
751
|
end
|
738
752
|
|
739
753
|
# Fetches the status of a migration.
|
@@ -745,7 +759,7 @@ module Octokit
|
|
745
759
|
# @see https://developer.github.com/v3/orgs/migrations/#get-the-status-of-a-migration
|
746
760
|
def migration_status(org, id, options = {})
|
747
761
|
options = ensure_api_media_type(:migrations, options)
|
748
|
-
get "
|
762
|
+
get "#{Organization.path(org)}/migrations/#{id}", options
|
749
763
|
end
|
750
764
|
|
751
765
|
# Fetches the URL to a migration archive.
|
@@ -757,7 +771,7 @@ module Octokit
|
|
757
771
|
# @see https://developer.github.com/v3/orgs/migrations/#download-a-migration-archive
|
758
772
|
def migration_archive_url(org, id, options = {})
|
759
773
|
options = ensure_api_media_type(:migrations, options)
|
760
|
-
url = "
|
774
|
+
url = "#{Organization.path(org)}/migrations/#{id}/archive"
|
761
775
|
|
762
776
|
response = client_without_redirects(options).get(url)
|
763
777
|
response.headers['location']
|
@@ -772,7 +786,7 @@ module Octokit
|
|
772
786
|
# @see https://developer.github.com/v3/orgs/migrations/#delete-a-migration-archive
|
773
787
|
def delete_migration_archive(org, id, options = {})
|
774
788
|
options = ensure_api_media_type(:migrations, options)
|
775
|
-
delete "
|
789
|
+
delete "#{Organization.path(org)}/migrations/#{id}/archive", options
|
776
790
|
end
|
777
791
|
|
778
792
|
# Unlock a previous migration archive.
|
@@ -785,7 +799,7 @@ module Octokit
|
|
785
799
|
# @see https://developer.github.com/v3/orgs/migrations/#unlock-a-repository
|
786
800
|
def unlock_repository(org, id, repo, options = {})
|
787
801
|
options = ensure_api_media_type(:migrations, options)
|
788
|
-
delete "
|
802
|
+
delete "#{Organization.path(org)}/migrations/#{id}/repos/#{repo}/lock", options
|
789
803
|
end
|
790
804
|
end
|
791
805
|
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
|
-
|
54
|
+
paginate "orgs/#{org}/projects", opts
|
55
55
|
end
|
56
56
|
alias :organization_projects :org_projects
|
57
57
|
|
@@ -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
|
data/lib/octokit/client/refs.rb
CHANGED
@@ -60,11 +60,13 @@ module Octokit
|
|
60
60
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
61
61
|
# @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
|
62
62
|
# @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
|
63
|
-
# @param force [Boolean] A flag indicating
|
63
|
+
# @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
|
64
64
|
# @return [Array<Sawyer::Resource>] The list of references updated
|
65
65
|
# @see https://developer.github.com/v3/git/refs/#update-a-reference
|
66
66
|
# @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
67
67
|
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
|
68
|
+
# @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
69
|
+
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
|
68
70
|
def update_ref(repo, ref, sha, force = true, options = {})
|
69
71
|
parameters = {
|
70
72
|
:sha => sha,
|
@@ -79,11 +81,13 @@ module Octokit
|
|
79
81
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
80
82
|
# @param branch [String] The ref, e.g. <tt>feature/new-shiny</tt>
|
81
83
|
# @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
|
82
|
-
# @param force [Boolean] A flag indicating
|
84
|
+
# @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
|
83
85
|
# @return [Array<Sawyer::Resource>] The list of references updated
|
84
86
|
# @see https://developer.github.com/v3/git/refs/#update-a-reference
|
85
87
|
# @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
86
|
-
# Octokit.
|
88
|
+
# Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
|
89
|
+
# @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
90
|
+
# Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
|
87
91
|
def update_branch(repo, branch, sha, force = true, options = {})
|
88
92
|
update_ref repo, "heads/#{branch}", sha, force, options
|
89
93
|
end
|
@@ -10,7 +10,7 @@ module Octokit
|
|
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
16
|
rescue Octokit::InvalidRepository
|
@@ -32,7 +32,7 @@ module Octokit
|
|
32
32
|
|
33
33
|
# Edit a repository
|
34
34
|
#
|
35
|
-
# @see https://developer.github.com/v3/repos/#
|
35
|
+
# @see https://developer.github.com/v3/repos/#update-a-repository
|
36
36
|
# @param repo [String, Hash, Repository] A GitHub repository
|
37
37
|
# @param options [Hash] Repository information to update
|
38
38
|
# @option options [String] :name Name of the repo
|
@@ -41,11 +41,15 @@ module Octokit
|
|
41
41
|
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
42
42
|
# @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
|
43
43
|
# @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
|
44
|
+
# @option options [Boolean] :is_template `true` makes the repository a template, `false` makes it not a template.
|
44
45
|
# @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
|
45
46
|
# @option options [String] :default_branch Update the default branch for this repository.
|
46
47
|
# @return [Sawyer::Resource] Repository information
|
47
48
|
def edit_repository(repo, options = {})
|
48
49
|
repo = Repository.new(repo)
|
50
|
+
if options.include? :is_template
|
51
|
+
options = ensure_api_media_type(:template_repositories, options)
|
52
|
+
end
|
49
53
|
options[:name] ||= repo.name
|
50
54
|
patch "repos/#{repo}", options
|
51
55
|
end
|
@@ -144,6 +148,7 @@ module Octokit
|
|
144
148
|
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
145
149
|
# @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
|
146
150
|
# @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
|
151
|
+
# @option options [Boolean] :is_template `true` makes this repo available as a template repository, `false` to prevent it.
|
147
152
|
# @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
|
148
153
|
# @option options [String] :organization Short name for the org under which to create the repo.
|
149
154
|
# @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.
|
@@ -155,6 +160,9 @@ module Octokit
|
|
155
160
|
opts = options.dup
|
156
161
|
organization = opts.delete :organization
|
157
162
|
opts.merge! :name => name
|
163
|
+
if opts.include? :is_template
|
164
|
+
opts = ensure_api_media_type(:template_repositories, opts)
|
165
|
+
end
|
158
166
|
|
159
167
|
if organization.nil?
|
160
168
|
post 'user/repos', opts
|
@@ -192,6 +200,22 @@ module Octokit
|
|
192
200
|
end
|
193
201
|
alias :transfer_repo :transfer_repository
|
194
202
|
|
203
|
+
# Create a repository for a user or organization generated from a template repository
|
204
|
+
#
|
205
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub template repository
|
206
|
+
# @param name [String] Name of the new repo
|
207
|
+
# @option options [String] :owner Organization or user who the new repository will belong to.
|
208
|
+
# @option options [String] :description Description of the repo
|
209
|
+
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
210
|
+
# @option options [Boolean] :include_all_branches `true` copies all branches from the template repository, `false` (default) makes it only copy the master branch.
|
211
|
+
# @return [Sawyer::Resource] Repository info for the new repository
|
212
|
+
def create_repository_from_template(repo, name, options = {})
|
213
|
+
options.merge! :name => name
|
214
|
+
options = ensure_api_media_type(:template_repositories, options)
|
215
|
+
post "#{Repository.path repo}/generate", options
|
216
|
+
end
|
217
|
+
alias :create_repo_from_template :create_repository_from_template
|
218
|
+
|
195
219
|
# Hide a public repository
|
196
220
|
#
|
197
221
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -293,7 +317,7 @@ module Octokit
|
|
293
317
|
#
|
294
318
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
295
319
|
# @option options [String] :affiliation Filters the return array by affiliation.
|
296
|
-
# Can be one of: <tt>outside</tt> or <tt>all</tt>.
|
320
|
+
# Can be one of: <tt>outside</tt>, <tt>direct</tt>, or <tt>all</tt>.
|
297
321
|
# If not specified, defaults to <tt>all</tt>
|
298
322
|
# @return [Array<Sawyer::Resource>] Array of hashes representing collaborating users.
|
299
323
|
# @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
|
@@ -405,7 +429,7 @@ module Octokit
|
|
405
429
|
# @example List topics for octokit/octokit.rb
|
406
430
|
# Octokit.topics('octokit/octokit.rb')
|
407
431
|
# @example List topics for octokit/octokit.rb
|
408
|
-
# client.topics('octokit/octokit.rb')
|
432
|
+
# client.topics('octokit/octokit.rb')
|
409
433
|
def topics(repo, options = {})
|
410
434
|
opts = ensure_api_media_type(:topics, options)
|
411
435
|
paginate "#{Repository.path repo}/topics", opts
|
@@ -562,14 +586,14 @@ module Octokit
|
|
562
586
|
#
|
563
587
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
564
588
|
# @param branch [String] Branch name
|
565
|
-
# @option options [Hash] :required_status_checks If not null, the following keys are required:
|
566
|
-
# <tt>:enforce_admins [boolean] Enforce required status checks for repository administrators.</tt>
|
567
|
-
# <tt>:strict [boolean] Require branches to be up to date before merging.</tt>
|
568
|
-
# <tt>:contexts [Array] The list of status checks to require in order to merge into this branch</tt>
|
589
|
+
# @option options [Hash] :required_status_checks If not null, the following keys are required:
|
590
|
+
# <tt>:enforce_admins [boolean] Enforce required status checks for repository administrators.</tt>
|
591
|
+
# <tt>:strict [boolean] Require branches to be up to date before merging.</tt>
|
592
|
+
# <tt>:contexts [Array] The list of status checks to require in order to merge into this branch</tt>
|
569
593
|
#
|
570
594
|
# @option options [Hash] :restrictions If not null, the following keys are required:
|
571
|
-
# <tt>:users [Array] The list of user logins with push access</tt>
|
572
|
-
# <tt>:teams [Array] The list of team slugs with push access</tt>.
|
595
|
+
# <tt>:users [Array] The list of user logins with push access</tt>
|
596
|
+
# <tt>:teams [Array] The list of team slugs with push access</tt>.
|
573
597
|
#
|
574
598
|
# Teams and users restrictions are only available for organization-owned repositories.
|
575
599
|
# @return [Sawyer::Resource] The protected branch
|
@@ -696,6 +720,19 @@ module Octokit
|
|
696
720
|
def delete_subscription(repo, options = {})
|
697
721
|
boolean_from_response :delete, "#{Repository.path repo}/subscription", options
|
698
722
|
end
|
723
|
+
|
724
|
+
# Create a repository dispatch event
|
725
|
+
#
|
726
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
727
|
+
# @param event_type [String] A custom webhook event name.
|
728
|
+
# @option options [Hash] :client_payload payload with extra information
|
729
|
+
# about the webhook event that your action or worklow may use.
|
730
|
+
#
|
731
|
+
# @return [Boolean] True if event was dispatched, false otherwise.
|
732
|
+
# @see https://developer.github.com/v3/repos/#create-a-repository-dispatch-event
|
733
|
+
def dispatch_event(repo, event_type, options = {})
|
734
|
+
boolean_from_response :post, "#{Repository.path repo}/dispatches", options.merge({ event_type: event_type })
|
735
|
+
end
|
699
736
|
end
|
700
737
|
end
|
701
738
|
end
|