octokit 4.2.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +275 -127
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +12 -0
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +161 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +125 -0
- data/lib/octokit/client/actions_workflows.rb +68 -0
- data/lib/octokit/client/apps.rb +259 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/commits.rb +32 -35
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +29 -7
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +36 -8
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +34 -30
- data/lib/octokit/client/issues.rb +97 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +5 -8
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +14 -14
- data/lib/octokit/client/notifications.rb +7 -11
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +256 -73
- data/lib/octokit/client/pages.rb +26 -3
- data/lib/octokit/client/projects.rb +294 -0
- data/lib/octokit/client/pull_requests.rb +74 -51
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +204 -0
- data/lib/octokit/client/refs.rb +34 -20
- data/lib/octokit/client/releases.rb +16 -13
- data/lib/octokit/client/repositories.rb +276 -60
- data/lib/octokit/client/repository_invitations.rb +96 -0
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +46 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +156 -0
- data/lib/octokit/client/stats.rb +39 -17
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +64 -0
- data/lib/octokit/client/users.rb +133 -25
- data/lib/octokit/client.rb +85 -19
- data/lib/octokit/configurable.rb +60 -32
- data/lib/octokit/connection.rb +45 -21
- data/lib/octokit/default.rb +82 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +19 -18
- data/lib/octokit/enterprise_admin_client.rb +11 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +144 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +18 -14
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +35 -23
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -10
- metadata +47 -24
- data/lib/octokit/client/authorizations.rb +0 -256
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -28
data/lib/octokit/client/pages.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Pages API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/pages/
|
7
8
|
module Pages
|
8
|
-
|
9
9
|
# List Pages information for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -15,6 +15,18 @@ module Octokit
|
|
15
15
|
get "#{Repository.path repo}/pages", options
|
16
16
|
end
|
17
17
|
|
18
|
+
# Get a specific Pages build by ID
|
19
|
+
#
|
20
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
21
|
+
# @param id [Integer, String] Build ID
|
22
|
+
# @return [Sawyer::Resource] Pages build information
|
23
|
+
# @see https://developer.github.com/v3/repos/pages/#list-a-specific-pages-build
|
24
|
+
# @example
|
25
|
+
# Octokit.pages_build("github/developer.github.com", 5472601)
|
26
|
+
def pages_build(repo, id, options = {})
|
27
|
+
get "#{Repository.path repo}/pages/builds/#{id}", options
|
28
|
+
end
|
29
|
+
|
18
30
|
# List Pages builds for a repository
|
19
31
|
#
|
20
32
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -23,7 +35,7 @@ module Octokit
|
|
23
35
|
def pages_builds(repo, options = {})
|
24
36
|
get "#{Repository.path repo}/pages/builds", options
|
25
37
|
end
|
26
|
-
alias
|
38
|
+
alias list_pages_builds pages_builds
|
27
39
|
|
28
40
|
# List the latest Pages build information for a repository
|
29
41
|
#
|
@@ -33,6 +45,17 @@ module Octokit
|
|
33
45
|
def latest_pages_build(repo, options = {})
|
34
46
|
get "#{Repository.path repo}/pages/builds/latest", options
|
35
47
|
end
|
48
|
+
|
49
|
+
# Request a page build for the latest revision of the default branch
|
50
|
+
#
|
51
|
+
# You can only request builds for your repositories
|
52
|
+
#
|
53
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
54
|
+
# @return [Sawyer::Resource] Request result
|
55
|
+
# @see https://developer.github.com/v3/repos/pages/#request-a-page-build
|
56
|
+
def request_page_build(repo, options = {})
|
57
|
+
post "#{Repository.path repo}/pages/builds", options
|
58
|
+
end
|
36
59
|
end
|
37
60
|
end
|
38
61
|
end
|
@@ -0,0 +1,294 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for Projects API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/projects
|
8
|
+
module Projects
|
9
|
+
# List projects for a repository
|
10
|
+
#
|
11
|
+
# Requires authenticated client
|
12
|
+
#
|
13
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
14
|
+
# @return [Array<Sawyer::Resource>] Repository projects
|
15
|
+
# @see https://developer.github.com/v3/projects/#list-repository-projects
|
16
|
+
# @example
|
17
|
+
# @client.projects('octokit/octokit.rb')
|
18
|
+
def projects(repo, options = {})
|
19
|
+
paginate "#{Repository.path repo}/projects", options
|
20
|
+
end
|
21
|
+
|
22
|
+
# Create a project
|
23
|
+
#
|
24
|
+
# Requires authenticated client
|
25
|
+
#
|
26
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
27
|
+
# @param name [String] Project name
|
28
|
+
# @option options [String] :body Body of the project
|
29
|
+
# @return [Sawyer::Resource] Fresh new project
|
30
|
+
# @see https://developer.github.com/v3/projects/#create-a-repository-project
|
31
|
+
# @example Create project with only a name
|
32
|
+
# @client.create_project('octokit/octokit.rb', 'implement new APIs')
|
33
|
+
#
|
34
|
+
# @example Create project with name and body
|
35
|
+
# @client.create_project('octokit/octokit.rb', 'bugs be gone', body: 'Fix all the bugs @joeyw creates')
|
36
|
+
def create_project(repo, name, options = {})
|
37
|
+
options[:name] = name
|
38
|
+
post "#{Repository.path repo}/projects", options
|
39
|
+
end
|
40
|
+
|
41
|
+
# List organization projects
|
42
|
+
#
|
43
|
+
# Requires authenticated client
|
44
|
+
#
|
45
|
+
# @param org [String] A GitHub organization
|
46
|
+
# @return [Array<Sawyer::Resource>] Organization projects
|
47
|
+
# @see https://developer.github.com/v3/projects/#list-organization-projects
|
48
|
+
# @example
|
49
|
+
# @client.org_projects("octokit")
|
50
|
+
def org_projects(org, options = {})
|
51
|
+
paginate "orgs/#{org}/projects", options
|
52
|
+
end
|
53
|
+
alias organization_projects org_projects
|
54
|
+
|
55
|
+
# Create organization project
|
56
|
+
#
|
57
|
+
# Requires authenticated client
|
58
|
+
#
|
59
|
+
# @param org [String] A GitHub organization
|
60
|
+
# @param name [String] Project name
|
61
|
+
# @option options [String] :body Project body
|
62
|
+
# @return [Sawyer::Resource] Organization project
|
63
|
+
# @see https://developer.github.com/v3/projects/#create-an-organization-project
|
64
|
+
# @example Create with only a name
|
65
|
+
# @client.create_org_project("octocat", "make more octocats")
|
66
|
+
# @example Create a project with name and body
|
67
|
+
# @client.create_org_project("octokit", "octocan", body: 'Improve clients')
|
68
|
+
def create_org_project(org, name, options = {})
|
69
|
+
options[:name] = name
|
70
|
+
post "orgs/#{org}/projects", options
|
71
|
+
end
|
72
|
+
alias create_organization_project create_org_project
|
73
|
+
|
74
|
+
# Get a project by id
|
75
|
+
#
|
76
|
+
# @param id [Integer] Project id
|
77
|
+
# @return [Sawyer::Resource] Project
|
78
|
+
# @see https://developer.github.com/v3/projects/#get-a-project
|
79
|
+
# @example
|
80
|
+
# Octokit.project(123942)
|
81
|
+
def project(id, options = {})
|
82
|
+
get "projects/#{id}", options
|
83
|
+
end
|
84
|
+
|
85
|
+
# Update a project
|
86
|
+
#
|
87
|
+
# Requires authenticated client
|
88
|
+
#
|
89
|
+
# @param id [Integer] Project id
|
90
|
+
# @option options [String] :name Project name
|
91
|
+
# @option options [String] :body Project body
|
92
|
+
# @return [Sawyer::Resource] Project
|
93
|
+
# @see https://developer.github.com/v3/projects/#update-a-project
|
94
|
+
# @example Update project name
|
95
|
+
# @client.update_project(123942, name: 'New name')
|
96
|
+
def update_project(id, options = {})
|
97
|
+
patch "projects/#{id}", options
|
98
|
+
end
|
99
|
+
|
100
|
+
# Delete a project
|
101
|
+
#
|
102
|
+
# Requires authenticated client
|
103
|
+
#
|
104
|
+
# @param id [Integer] Project id
|
105
|
+
# @return [Boolean] Result of deletion
|
106
|
+
# @see https://developer.github.com/v3/projects/#delete-a-project
|
107
|
+
# @example
|
108
|
+
# @client.delete_project(123942)
|
109
|
+
def delete_project(id, options = {})
|
110
|
+
boolean_from_response :delete, "projects/#{id}", options
|
111
|
+
end
|
112
|
+
|
113
|
+
# List project columns
|
114
|
+
#
|
115
|
+
# @param id [Integer] Project id
|
116
|
+
# @return [Array<Sawyer::Resource>] List of project columns
|
117
|
+
# @see https://developer.github.com/v3/projects/columns/#list-project-columns
|
118
|
+
# @example
|
119
|
+
# @client.project_columns(123942)
|
120
|
+
def project_columns(id, options = {})
|
121
|
+
paginate "projects/#{id}/columns", options
|
122
|
+
end
|
123
|
+
|
124
|
+
# Create a project column
|
125
|
+
#
|
126
|
+
# Requires authenticated client
|
127
|
+
#
|
128
|
+
# @param id [Integer] Project column id
|
129
|
+
# @param name [String] New column name
|
130
|
+
# @return [Sawyer::Resource] Newly created column
|
131
|
+
# @see https://developer.github.com/v3/projects/columns/#create-a-project-column
|
132
|
+
# @example
|
133
|
+
# @client.create_project_column(123942, "To Dones")
|
134
|
+
def create_project_column(id, name, options = {})
|
135
|
+
options[:name] = name
|
136
|
+
post "projects/#{id}/columns", options
|
137
|
+
end
|
138
|
+
|
139
|
+
# Get a project column by ID
|
140
|
+
#
|
141
|
+
# @param id [Integer] Project column id
|
142
|
+
# @return [Sawyer::Resource] Project column
|
143
|
+
# @see https://developer.github.com/v3/projects/columns/#get-a-project-column
|
144
|
+
# @example
|
145
|
+
# Octokit.project_column(30294)
|
146
|
+
def project_column(id, options = {})
|
147
|
+
get "projects/columns/#{id}", options
|
148
|
+
end
|
149
|
+
|
150
|
+
# Update a project column
|
151
|
+
#
|
152
|
+
# Requires authenticated client
|
153
|
+
#
|
154
|
+
# @param id [Integer] Project column id
|
155
|
+
# @param name [String] New column name
|
156
|
+
# @return [Sawyer::Resource] Updated column
|
157
|
+
# @see https://developer.github.com/v3/projects/columns/#update-a-project-column
|
158
|
+
# @example
|
159
|
+
# @client.update_project_column(30294, "new column name")
|
160
|
+
def update_project_column(id, name, options = {})
|
161
|
+
options[:name] = name
|
162
|
+
patch "projects/columns/#{id}", options
|
163
|
+
end
|
164
|
+
|
165
|
+
# Delete a project column
|
166
|
+
#
|
167
|
+
# Requires authenticated client
|
168
|
+
#
|
169
|
+
# @param id [Integer] Project column id
|
170
|
+
# @return [Boolean] Result of deletion request, true when deleted
|
171
|
+
# @see https://developer.github.com/v3/projects/columns/#delete-a-project-column
|
172
|
+
# @example
|
173
|
+
# @client.delete_project_column(30294)
|
174
|
+
def delete_project_column(id, options = {})
|
175
|
+
boolean_from_response :delete, "projects/columns/#{id}", options
|
176
|
+
end
|
177
|
+
|
178
|
+
# Move a project column
|
179
|
+
#
|
180
|
+
# Requires authenticated client
|
181
|
+
#
|
182
|
+
# @param id [Integer] Project column id
|
183
|
+
# @param position [String] New position for the column. Can be one of
|
184
|
+
# <tt>first</tt>, <tt>last</tt>, or <tt>after:<column-id></tt>, where
|
185
|
+
# <tt><column-id></tt> is the id value of a column in the same project.
|
186
|
+
# @return [Sawyer::Resource] Result
|
187
|
+
# @see https://developer.github.com/v3/projects/columns/#move-a-project-column
|
188
|
+
# @example
|
189
|
+
# @client.move_project_column(30294, "last")
|
190
|
+
def move_project_column(id, position, options = {})
|
191
|
+
options[:position] = position
|
192
|
+
post "projects/columns/#{id}/moves", options
|
193
|
+
end
|
194
|
+
|
195
|
+
# List columns cards
|
196
|
+
#
|
197
|
+
# Requires authenticated client
|
198
|
+
#
|
199
|
+
# @param id [Integer] Project column id
|
200
|
+
# @return [Array<Sawyer::Resource>] Cards in the column
|
201
|
+
# @see https://developer.github.com/v3/projects/cards/#list-project-cards
|
202
|
+
# @example
|
203
|
+
# @client.column_cards(30294)
|
204
|
+
def column_cards(id, options = {})
|
205
|
+
paginate "projects/columns/#{id}/cards", options
|
206
|
+
end
|
207
|
+
|
208
|
+
# Create project card
|
209
|
+
#
|
210
|
+
# Requires authenticated client
|
211
|
+
#
|
212
|
+
# @param id [Integer] Project column id
|
213
|
+
# @option options [String] :note Card contents for a note type
|
214
|
+
# @option options [Integer] :content_id Issue ID for the card contents
|
215
|
+
# @option options [String] :content_type Type of content to associate
|
216
|
+
# with the card. <tt>Issue</tt> is presently the only avaiable value
|
217
|
+
# @note If :note is supplied, :content_id and :content_type must be
|
218
|
+
# excluded. Similarly, if :content_id is supplied, :content_type must
|
219
|
+
# be set and :note must not be included.
|
220
|
+
# @return [Sawyer::Resource] Newly created card
|
221
|
+
# @see https://developer.github.com/v3/projects/cards/#create-a-project-card
|
222
|
+
# @example Create a project card with a note
|
223
|
+
# @client.create_project_card(123495, note: 'New note card')
|
224
|
+
# @example Create a project card for an repository issue
|
225
|
+
# @client.create_project_card(123495, content_id: 1, content_type: 'Issue')
|
226
|
+
def create_project_card(id, options = {})
|
227
|
+
post "projects/columns/#{id}/cards", options
|
228
|
+
end
|
229
|
+
|
230
|
+
# Get a project card
|
231
|
+
#
|
232
|
+
# Requires authenticated client
|
233
|
+
#
|
234
|
+
# @param id [Integer] Project card id
|
235
|
+
# @return [Sawyer::Resource] Project card
|
236
|
+
# @see https://developer.github.com/v3/projects/cards/#get-a-project-card
|
237
|
+
# @example
|
238
|
+
# @client.project_card(123495)
|
239
|
+
def project_card(id, options = {})
|
240
|
+
get "projects/columns/cards/#{id}", options
|
241
|
+
end
|
242
|
+
|
243
|
+
# Update a project card
|
244
|
+
#
|
245
|
+
# Requires authenticated client
|
246
|
+
#
|
247
|
+
# @param id [Integer] Project card id
|
248
|
+
# @option options [String] :note The card's note content. Only valid for
|
249
|
+
# cards without another type of content, so this cannot be specified if
|
250
|
+
# the card already has a content_id and content_type.
|
251
|
+
# @return [Sawyer::Resource] Updated project card
|
252
|
+
# @see https://developer.github.com/v3/projects/cards/#update-a-project-card
|
253
|
+
# @example
|
254
|
+
# @client.update_project_card(12345, note: 'new note')
|
255
|
+
def update_project_card(id, options = {})
|
256
|
+
patch "projects/columns/cards/#{id}", options
|
257
|
+
end
|
258
|
+
|
259
|
+
# Move a project card
|
260
|
+
#
|
261
|
+
# Requires authenticated client
|
262
|
+
#
|
263
|
+
# @param id [Integer] Project card id
|
264
|
+
# @param position [String] Can be one of <tt>top</tt>, <tt>bottom</tt>,
|
265
|
+
# or <tt>after:<card-id></tt>, where <card-id> is the id value of a
|
266
|
+
# card in the same column, or in the new column specified by column_id.
|
267
|
+
# @option options [Integer] :column_id The column id to move the card to,
|
268
|
+
# must be column in same project
|
269
|
+
# @return [Sawyer::Resource] Empty sawyer resource
|
270
|
+
# @see https://developer.github.com/v3/projects/cards/#move-a-project-card
|
271
|
+
# @example Move a card to the bottom of the same column
|
272
|
+
# @client.move_project_card(123495, 'bottom')
|
273
|
+
# @example Move a card to the top of another column
|
274
|
+
# @client.move_project_card(123495, 'top', column_id: 59402)
|
275
|
+
def move_project_card(id, position, options = {})
|
276
|
+
options[:position] = position
|
277
|
+
post "projects/columns/cards/#{id}/moves", options
|
278
|
+
end
|
279
|
+
|
280
|
+
# Delete a project card
|
281
|
+
#
|
282
|
+
# Requires authenticated client
|
283
|
+
#
|
284
|
+
# @param id [Integer] Project card id
|
285
|
+
# @return [Boolean] True of deleted, false otherwise
|
286
|
+
# @see https://developer.github.com/v3/projects/cards/#delete-a-project-card
|
287
|
+
# @example
|
288
|
+
# @client.delete_project_card(123495)
|
289
|
+
def delete_project_card(id, options = {})
|
290
|
+
boolean_from_response :delete, "projects/columns/cards/#{id}", options
|
291
|
+
end
|
292
|
+
end # Projects
|
293
|
+
end
|
294
|
+
end
|
@@ -1,17 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Pull Requests API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/pulls/
|
7
8
|
module PullRequests
|
8
|
-
|
9
9
|
# List pull requests for a repository
|
10
10
|
#
|
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
|
@@ -19,7 +19,7 @@ module Octokit
|
|
19
19
|
def pull_requests(repo, options = {})
|
20
20
|
paginate "#{Repository.path repo}/pulls", options
|
21
21
|
end
|
22
|
-
alias
|
22
|
+
alias pulls pull_requests
|
23
23
|
|
24
24
|
# Get a pull request
|
25
25
|
#
|
@@ -27,10 +27,12 @@ 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
|
33
|
-
alias
|
35
|
+
alias pull pull_request
|
34
36
|
|
35
37
|
# Create a pull request
|
36
38
|
#
|
@@ -49,9 +51,9 @@ module Octokit
|
|
49
51
|
# "Pull Request title", "Pull Request body")
|
50
52
|
def create_pull_request(repo, base, head, title, body = nil, options = {})
|
51
53
|
pull = {
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
54
|
+
base: base,
|
55
|
+
head: head,
|
56
|
+
title: title
|
55
57
|
}
|
56
58
|
pull[:body] = body unless body.nil?
|
57
59
|
post "#{Repository.path repo}/pulls", options.merge(pull)
|
@@ -70,22 +72,22 @@ module Octokit
|
|
70
72
|
# @return [Sawyer::Resource] The newly created pull request
|
71
73
|
def create_pull_request_for_issue(repo, base, head, issue, options = {})
|
72
74
|
pull = {
|
73
|
-
:
|
74
|
-
:
|
75
|
-
:
|
75
|
+
base: base,
|
76
|
+
head: head,
|
77
|
+
issue: issue
|
76
78
|
}
|
77
79
|
post "#{Repository.path repo}/pulls", options.merge(pull)
|
78
80
|
end
|
79
81
|
|
80
82
|
# Update a pull request
|
81
|
-
# @overload update_pull_request(repo,
|
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,
|
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.
|
@@ -101,7 +103,7 @@ module Octokit
|
|
101
103
|
# @client.update_pull_request('octokit/octokit.rb', 67, nil, '')
|
102
104
|
def update_pull_request(*args)
|
103
105
|
arguments = Octokit::Arguments.new(args)
|
104
|
-
repo
|
106
|
+
repo = arguments.shift
|
105
107
|
number = arguments.shift
|
106
108
|
patch "#{Repository.path repo}/pulls/#{number}", arguments.options
|
107
109
|
end
|
@@ -115,7 +117,7 @@ module Octokit
|
|
115
117
|
# @example
|
116
118
|
# @client.close_pull_request('octokit/octokit.rb', 67)
|
117
119
|
def close_pull_request(repo, number, options = {})
|
118
|
-
options.merge! :
|
120
|
+
options.merge! state: 'closed'
|
119
121
|
update_pull_request(repo, number, options)
|
120
122
|
end
|
121
123
|
|
@@ -128,7 +130,7 @@ module Octokit
|
|
128
130
|
def pull_request_commits(repo, number, options = {})
|
129
131
|
paginate "#{Repository.path repo}/pulls/#{number}/commits", options
|
130
132
|
end
|
131
|
-
alias
|
133
|
+
alias pull_commits pull_request_commits
|
132
134
|
|
133
135
|
# List pull request comments for a repository
|
134
136
|
#
|
@@ -151,15 +153,15 @@ 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 => '
|
155
|
-
# :direction => '
|
156
|
+
# :sort => 'updated',
|
157
|
+
# :direction => 'asc',
|
156
158
|
# :since => '2010-05-04T23:45:02Z'
|
157
159
|
# })
|
158
160
|
def pull_requests_comments(repo, options = {})
|
159
161
|
paginate("#{Repository.path repo}/pulls/comments", options)
|
160
162
|
end
|
161
|
-
alias
|
162
|
-
alias
|
163
|
+
alias pulls_comments pull_requests_comments
|
164
|
+
alias reviews_comments pull_requests_comments
|
163
165
|
|
164
166
|
# List comments on a pull request
|
165
167
|
#
|
@@ -171,8 +173,8 @@ module Octokit
|
|
171
173
|
# return the comments for a pull request
|
172
174
|
paginate("#{Repository.path repo}/pulls/#{number}/comments", options)
|
173
175
|
end
|
174
|
-
alias
|
175
|
-
alias
|
176
|
+
alias pull_comments pull_request_comments
|
177
|
+
alias review_comments pull_request_comments
|
176
178
|
|
177
179
|
# Get a pull request comment
|
178
180
|
#
|
@@ -185,8 +187,8 @@ module Octokit
|
|
185
187
|
def pull_request_comment(repo, comment_id, options = {})
|
186
188
|
get "#{Repository.path repo}/pulls/comments/#{comment_id}", options
|
187
189
|
end
|
188
|
-
alias
|
189
|
-
alias
|
190
|
+
alias pull_comment pull_request_comment
|
191
|
+
alias review_comment pull_request_comment
|
190
192
|
|
191
193
|
# Create a pull request comment
|
192
194
|
#
|
@@ -195,23 +197,34 @@ module Octokit
|
|
195
197
|
# @param body [String] Comment content
|
196
198
|
# @param commit_id [String] Sha of the commit to comment on.
|
197
199
|
# @param path [String] Relative path of the file to comment on.
|
198
|
-
# @param
|
200
|
+
# @param line [Integer] Optional line index in the diff to comment on.
|
201
|
+
# For a multi-line comment, the last line of the range
|
202
|
+
# and specify 'start_line' in the 'options'.
|
203
|
+
# If not specified, the comment will be on the whole file.
|
199
204
|
# @return [Sawyer::Resource] Hash representing the new comment
|
205
|
+
# @deprecated The position will be deprecated in the next major version. Please refer to the details below.
|
200
206
|
# @see https://developer.github.com/v3/pulls/comments/#create-a-comment
|
201
207
|
# @example
|
202
208
|
# @client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
|
203
209
|
# "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
|
204
|
-
def create_pull_request_comment(repo, pull_id, body, commit_id, path,
|
205
|
-
|
206
|
-
:
|
207
|
-
:
|
208
|
-
:
|
209
|
-
|
210
|
-
|
210
|
+
def create_pull_request_comment(repo, pull_id, body, commit_id, path, line = nil, options = {})
|
211
|
+
comment = {
|
212
|
+
body: body,
|
213
|
+
commit_id: commit_id,
|
214
|
+
path: path
|
215
|
+
}
|
216
|
+
|
217
|
+
if line.nil?
|
218
|
+
comment[:subject_type] = 'file'
|
219
|
+
else
|
220
|
+
comment[:line] = line
|
221
|
+
end
|
222
|
+
|
223
|
+
options.merge! comment
|
211
224
|
post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
|
212
225
|
end
|
213
|
-
alias
|
214
|
-
alias
|
226
|
+
alias create_pull_comment create_pull_request_comment
|
227
|
+
alias create_view_comment create_pull_request_comment
|
215
228
|
|
216
229
|
# Create reply to a pull request comment
|
217
230
|
#
|
@@ -222,16 +235,16 @@ module Octokit
|
|
222
235
|
# @return [Sawyer::Resource] Hash representing new comment
|
223
236
|
# @see https://developer.github.com/v3/pulls/comments/#create-a-comment
|
224
237
|
# @example
|
225
|
-
# @client.create_pull_request_comment_reply("octokit/octokit.rb",
|
238
|
+
# @client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)
|
226
239
|
def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})
|
227
240
|
options.merge!({
|
228
|
-
|
229
|
-
|
230
|
-
|
241
|
+
body: body,
|
242
|
+
in_reply_to: comment_id
|
243
|
+
})
|
231
244
|
post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
|
232
245
|
end
|
233
|
-
alias
|
234
|
-
alias
|
246
|
+
alias create_pull_reply create_pull_request_comment_reply
|
247
|
+
alias create_review_reply create_pull_request_comment_reply
|
235
248
|
|
236
249
|
# Update pull request comment
|
237
250
|
#
|
@@ -243,11 +256,11 @@ module Octokit
|
|
243
256
|
# @example
|
244
257
|
# @client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")
|
245
258
|
def update_pull_request_comment(repo, comment_id, body, options = {})
|
246
|
-
options.merge! :
|
259
|
+
options.merge! body: body
|
247
260
|
patch("#{Repository.path repo}/pulls/comments/#{comment_id}", options)
|
248
261
|
end
|
249
|
-
alias
|
250
|
-
alias
|
262
|
+
alias update_pull_comment update_pull_request_comment
|
263
|
+
alias update_review_comment update_pull_request_comment
|
251
264
|
|
252
265
|
# Delete pull request comment
|
253
266
|
#
|
@@ -260,8 +273,8 @@ module Octokit
|
|
260
273
|
def delete_pull_request_comment(repo, comment_id, options = {})
|
261
274
|
boolean_from_response(:delete, "#{Repository.path repo}/pulls/comments/#{comment_id}", options)
|
262
275
|
end
|
263
|
-
alias
|
264
|
-
alias
|
276
|
+
alias delete_pull_comment delete_pull_request_comment
|
277
|
+
alias delete_review_comment delete_pull_request_comment
|
265
278
|
|
266
279
|
# List files on a pull request
|
267
280
|
#
|
@@ -272,17 +285,28 @@ module Octokit
|
|
272
285
|
def pull_request_files(repo, number, options = {})
|
273
286
|
paginate "#{Repository.path repo}/pulls/#{number}/files", options
|
274
287
|
end
|
275
|
-
alias
|
288
|
+
alias pull_files pull_request_files
|
289
|
+
|
290
|
+
# Update a pull request branch
|
291
|
+
#
|
292
|
+
# @see https://developer.github.com/v3/pulls/#update-a-pull-request-branch
|
293
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
294
|
+
# @param number [Integer] Number of pull request
|
295
|
+
# @param options [Hash] Optional parameters (e.g. expected_head_sha)
|
296
|
+
# @return [Boolean] True if the pull request branch has been updated
|
297
|
+
def update_pull_request_branch(repo, number, options = {})
|
298
|
+
boolean_from_response(:put, "#{Repository.path repo}/pulls/#{number}/update-branch", options)
|
299
|
+
end
|
276
300
|
|
277
301
|
# Merge a pull request
|
278
302
|
#
|
279
|
-
# @see https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-
|
303
|
+
# @see https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
|
280
304
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
281
305
|
# @param number [Integer] Number of pull request
|
282
306
|
# @param commit_message [String] Optional commit message for the merge commit
|
283
307
|
# @return [Array<Sawyer::Resource>] Merge commit info if successful
|
284
|
-
def merge_pull_request(repo, number, commit_message='', options = {})
|
285
|
-
put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({:commit_message
|
308
|
+
def merge_pull_request(repo, number, commit_message = '', options = {})
|
309
|
+
put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({ commit_message: commit_message })
|
286
310
|
end
|
287
311
|
|
288
312
|
# Check pull request merge status
|
@@ -294,8 +318,7 @@ module Octokit
|
|
294
318
|
def pull_merged?(repo, number, options = {})
|
295
319
|
boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
|
296
320
|
end
|
297
|
-
alias
|
298
|
-
|
321
|
+
alias pull_request_merged? pull_merged?
|
299
322
|
end
|
300
323
|
end
|
301
324
|
end
|