octokit 4.6.2 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +14 -13
  3. data/LICENSE.md +1 -1
  4. data/README.md +239 -118
  5. data/Rakefile +12 -12
  6. data/lib/ext/sawyer/relation.rb +4 -2
  7. data/lib/octokit/arguments.rb +2 -2
  8. data/lib/octokit/authentication.rb +20 -14
  9. data/lib/octokit/client/actions_artifacts.rb +71 -0
  10. data/lib/octokit/client/actions_secrets.rb +59 -0
  11. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  12. data/lib/octokit/client/actions_workflow_runs.rb +125 -0
  13. data/lib/octokit/client/actions_workflows.rb +68 -0
  14. data/lib/octokit/client/apps.rb +222 -0
  15. data/lib/octokit/client/checks.rb +200 -0
  16. data/lib/octokit/client/commit_branches.rb +20 -0
  17. data/lib/octokit/client/commit_comments.rb +8 -8
  18. data/lib/octokit/client/commit_pulls.rb +20 -0
  19. data/lib/octokit/client/commits.rb +31 -34
  20. data/lib/octokit/client/community_profile.rb +21 -0
  21. data/lib/octokit/client/contents.rb +25 -20
  22. data/lib/octokit/client/deployments.rb +25 -5
  23. data/lib/octokit/client/downloads.rb +5 -6
  24. data/lib/octokit/client/emojis.rb +3 -3
  25. data/lib/octokit/client/environments.rb +55 -0
  26. data/lib/octokit/client/events.rb +4 -4
  27. data/lib/octokit/client/feeds.rb +4 -5
  28. data/lib/octokit/client/gists.rb +7 -6
  29. data/lib/octokit/client/gitignore.rb +3 -3
  30. data/lib/octokit/client/hooks.rb +9 -19
  31. data/lib/octokit/client/issues.rb +60 -14
  32. data/lib/octokit/client/labels.rb +17 -17
  33. data/lib/octokit/client/legacy_search.rb +3 -3
  34. data/lib/octokit/client/licenses.rb +4 -7
  35. data/lib/octokit/client/markdown.rb +3 -3
  36. data/lib/octokit/client/marketplace.rb +56 -0
  37. data/lib/octokit/client/meta.rb +4 -5
  38. data/lib/octokit/client/milestones.rb +5 -5
  39. data/lib/octokit/client/notifications.rb +6 -10
  40. data/lib/octokit/client/oauth_applications.rb +116 -0
  41. data/lib/octokit/client/objects.rb +14 -14
  42. data/lib/octokit/client/organizations.rb +238 -61
  43. data/lib/octokit/client/pages.rb +5 -7
  44. data/lib/octokit/client/projects.rb +50 -70
  45. data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
  46. data/lib/octokit/client/pull_requests.rb +58 -46
  47. data/lib/octokit/client/rate_limit.rb +11 -13
  48. data/lib/octokit/client/reactions.rb +6 -11
  49. data/lib/octokit/client/refs.rb +32 -19
  50. data/lib/octokit/client/releases.rb +14 -13
  51. data/lib/octokit/client/repositories.rb +195 -54
  52. data/lib/octokit/client/repository_invitations.rb +4 -11
  53. data/lib/octokit/client/reviews.rb +227 -0
  54. data/lib/octokit/client/say.rb +4 -5
  55. data/lib/octokit/client/search.rb +46 -17
  56. data/lib/octokit/client/service_status.rb +19 -9
  57. data/lib/octokit/client/source_import.rb +8 -13
  58. data/lib/octokit/client/stats.rb +12 -9
  59. data/lib/octokit/client/statuses.rb +6 -6
  60. data/lib/octokit/client/tokens.rb +31 -0
  61. data/lib/octokit/client/traffic.rb +6 -11
  62. data/lib/octokit/client/users.rb +106 -25
  63. data/lib/octokit/client.rb +66 -17
  64. data/lib/octokit/configurable.rb +42 -30
  65. data/lib/octokit/connection.rb +43 -21
  66. data/lib/octokit/default.rb +63 -34
  67. data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
  68. data/lib/octokit/enterprise_admin_client/license.rb +4 -5
  69. data/lib/octokit/enterprise_admin_client/orgs.rb +5 -6
  70. data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
  71. data/lib/octokit/enterprise_admin_client/users.rb +17 -16
  72. data/lib/octokit/enterprise_admin_client.rb +9 -3
  73. data/lib/octokit/enterprise_management_console_client/management_console.rb +33 -33
  74. data/lib/octokit/enterprise_management_console_client.rb +9 -3
  75. data/lib/octokit/error.rb +107 -26
  76. data/lib/octokit/gist.rb +4 -5
  77. data/lib/octokit/middleware/follow_redirects.rb +17 -13
  78. data/lib/octokit/organization.rb +3 -1
  79. data/lib/octokit/rate_limit.rb +11 -9
  80. data/lib/octokit/repo_arguments.rb +2 -3
  81. data/lib/octokit/repository.rb +27 -25
  82. data/lib/octokit/response/base_middleware.rb +10 -0
  83. data/lib/octokit/response/feed_parser.rb +5 -9
  84. data/lib/octokit/response/raise_error.rb +4 -6
  85. data/lib/octokit/user.rb +4 -2
  86. data/lib/octokit/version.rb +5 -3
  87. data/lib/octokit/warnable.rb +4 -5
  88. data/lib/octokit.rb +15 -8
  89. data/octokit.gemspec +13 -10
  90. metadata +55 -22
  91. data/lib/octokit/client/authorizations.rb +0 -244
  92. data/lib/octokit/preview.rb +0 -35
@@ -1,23 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for Projects API
5
6
  #
6
- # @see https://developer.github.com/v3/repos/projects
7
+ # @see https://docs.github.com/en/rest/projects
7
8
  module Projects
8
-
9
9
  # List projects for a repository
10
10
  #
11
11
  # Requires authenticated client
12
12
  #
13
13
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
14
14
  # @return [Array<Sawyer::Resource>] Repository projects
15
- # @see https://developer.github.com/v3/projects/#list-repository-projects
15
+ # @see https://developer.github.com/v3/projects/#list-repository-projects
16
16
  # @example
17
17
  # @client.projects('octokit/octokit.rb')
18
18
  def projects(repo, options = {})
19
- opts = ensure_api_media_type(:projects, options)
20
- paginate "#{Repository.path repo}/projects", opts
19
+ paginate "#{Repository.path repo}/projects", options
21
20
  end
22
21
 
23
22
  # Create a project
@@ -28,16 +27,15 @@ module Octokit
28
27
  # @param name [String] Project name
29
28
  # @option options [String] :body Body of the project
30
29
  # @return [Sawyer::Resource] Fresh new project
31
- # @see https://developer.github.com/v3/projects/#create-a-repository-project
30
+ # @see https://developer.github.com/v3/projects/#create-a-repository-project
32
31
  # @example Create project with only a name
33
32
  # @client.create_project('octokit/octokit.rb', 'implement new APIs')
34
33
  #
35
34
  # @example Create project with name and body
36
35
  # @client.create_project('octokit/octokit.rb', 'bugs be gone', body: 'Fix all the bugs @joeyw creates')
37
36
  def create_project(repo, name, options = {})
38
- opts = ensure_api_media_type(:projects, options)
39
- opts[:name] = name
40
- post "#{Repository.path repo}/projects", opts
37
+ options[:name] = name
38
+ post "#{Repository.path repo}/projects", options
41
39
  end
42
40
 
43
41
  # List organization projects
@@ -50,10 +48,9 @@ module Octokit
50
48
  # @example
51
49
  # @client.org_projects("octokit")
52
50
  def org_projects(org, options = {})
53
- opts = ensure_api_media_type(:projects, options)
54
- get "orgs/#{org}/projects", opts
51
+ paginate "orgs/#{org}/projects", options
55
52
  end
56
- alias :organization_projects :org_projects
53
+ alias organization_projects org_projects
57
54
 
58
55
  # Create organization project
59
56
  #
@@ -69,22 +66,20 @@ module Octokit
69
66
  # @example Create a project with name and body
70
67
  # @client.create_org_project("octokit", "octocan", body: 'Improve clients')
71
68
  def create_org_project(org, name, options = {})
72
- opts = ensure_api_media_type(:projects, options)
73
- opts[:name] = name
74
- post "orgs/#{org}/projects", opts
69
+ options[:name] = name
70
+ post "orgs/#{org}/projects", options
75
71
  end
76
- alias :create_organization_project :create_org_project
72
+ alias create_organization_project create_org_project
77
73
 
78
- # Get a project by id
74
+ # Get a project by id
79
75
  #
80
76
  # @param id [Integer] Project id
81
77
  # @return [Sawyer::Resource] Project
82
- # @see https://developer.github.com/v3/projects/#get-a-project
78
+ # @see https://developer.github.com/v3/projects/#get-a-project
83
79
  # @example
84
- # Octokit.project("octokit/octokit.rb", 1)
80
+ # Octokit.project(123942)
85
81
  def project(id, options = {})
86
- opts = ensure_api_media_type(:projects, options)
87
- get "projects/#{id}", opts
82
+ get "projects/#{id}", options
88
83
  end
89
84
 
90
85
  # Update a project
@@ -95,12 +90,11 @@ module Octokit
95
90
  # @option options [String] :name Project name
96
91
  # @option options [String] :body Project body
97
92
  # @return [Sawyer::Resource] Project
98
- # @see https://developer.github.com/v3/projects/#update-a-project
93
+ # @see https://developer.github.com/v3/projects/#update-a-project
99
94
  # @example Update project name
100
95
  # @client.update_project(123942, name: 'New name')
101
96
  def update_project(id, options = {})
102
- opts = ensure_api_media_type(:projects, options)
103
- patch "projects/#{id}", opts
97
+ patch "projects/#{id}", options
104
98
  end
105
99
 
106
100
  # Delete a project
@@ -109,24 +103,22 @@ module Octokit
109
103
  #
110
104
  # @param id [Integer] Project id
111
105
  # @return [Boolean] Result of deletion
112
- # @see https://developer.github.com/v3/projects/#delete-a-project
106
+ # @see https://developer.github.com/v3/projects/#delete-a-project
113
107
  # @example
114
108
  # @client.delete_project(123942)
115
109
  def delete_project(id, options = {})
116
- opts = ensure_api_media_type(:projects, options)
117
- boolean_from_response :delete, "projects/#{id}", opts
110
+ boolean_from_response :delete, "projects/#{id}", options
118
111
  end
119
112
 
120
113
  # List project columns
121
114
  #
122
- # @param id [Integer] Project id
115
+ # @param id [Integer] Project id
123
116
  # @return [Array<Sawyer::Resource>] List of project columns
124
- # @see https://developer.github.com/v3/projects/columns/#list-project-columns
117
+ # @see https://developer.github.com/v3/projects/columns/#list-project-columns
125
118
  # @example
126
- # @client.project_columns("octokit/octokit.rb", 1)
119
+ # @client.project_columns(123942)
127
120
  def project_columns(id, options = {})
128
- opts = ensure_api_media_type(:projects, options)
129
- paginate "projects/#{id}/columns", opts
121
+ paginate "projects/#{id}/columns", options
130
122
  end
131
123
 
132
124
  # Create a project column
@@ -136,25 +128,23 @@ module Octokit
136
128
  # @param id [Integer] Project column id
137
129
  # @param name [String] New column name
138
130
  # @return [Sawyer::Resource] Newly created column
139
- # @see https://developer.github.com/v3/projects/columns/#create-a-project-column
131
+ # @see https://developer.github.com/v3/projects/columns/#create-a-project-column
140
132
  # @example
141
- # @client.create_project_column("octokit/octokit.rb", 1, "To Dones")
133
+ # @client.create_project_column(123942, "To Dones")
142
134
  def create_project_column(id, name, options = {})
143
- opts = ensure_api_media_type(:projects, options)
144
- opts[:name] = name
145
- post "projects/#{id}/columns", opts
135
+ options[:name] = name
136
+ post "projects/#{id}/columns", options
146
137
  end
147
138
 
148
139
  # Get a project column by ID
149
140
  #
150
141
  # @param id [Integer] Project column id
151
142
  # @return [Sawyer::Resource] Project column
152
- # @see https://developer.github.com/v3/projects/columns/#get-a-project-column
143
+ # @see https://developer.github.com/v3/projects/columns/#get-a-project-column
153
144
  # @example
154
- # Octokit.project_column(123940, 30)
145
+ # Octokit.project_column(30294)
155
146
  def project_column(id, options = {})
156
- opts = ensure_api_media_type(:projects, options)
157
- get "projects/columns/#{id}", opts
147
+ get "projects/columns/#{id}", options
158
148
  end
159
149
 
160
150
  # Update a project column
@@ -164,13 +154,12 @@ module Octokit
164
154
  # @param id [Integer] Project column id
165
155
  # @param name [String] New column name
166
156
  # @return [Sawyer::Resource] Updated column
167
- # @see https://developer.github.com/v3/projects/columns/#update-a-project-column
157
+ # @see https://developer.github.com/v3/projects/columns/#update-a-project-column
168
158
  # @example
169
159
  # @client.update_project_column(30294, "new column name")
170
160
  def update_project_column(id, name, options = {})
171
- opts = ensure_api_media_type(:projects, options)
172
- opts[:name] = name
173
- patch "projects/columns/#{id}", opts
161
+ options[:name] = name
162
+ patch "projects/columns/#{id}", options
174
163
  end
175
164
 
176
165
  # Delete a project column
@@ -179,12 +168,11 @@ module Octokit
179
168
  #
180
169
  # @param id [Integer] Project column id
181
170
  # @return [Boolean] Result of deletion request, true when deleted
182
- # @see https://developer.github.com/v3/projects/columns/#delete-a-project-column
171
+ # @see https://developer.github.com/v3/projects/columns/#delete-a-project-column
183
172
  # @example
184
173
  # @client.delete_project_column(30294)
185
174
  def delete_project_column(id, options = {})
186
- opts = ensure_api_media_type(:projects, options)
187
- boolean_from_response :delete, "projects/columns/#{id}", opts
175
+ boolean_from_response :delete, "projects/columns/#{id}", options
188
176
  end
189
177
 
190
178
  # Move a project column
@@ -192,17 +180,16 @@ module Octokit
192
180
  # Requires authenticated client
193
181
  #
194
182
  # @param id [Integer] Project column id
195
- # @param position [String] New position for the column. Can be one of
183
+ # @param position [String] New position for the column. Can be one of
196
184
  # <tt>first</tt>, <tt>last</tt>, or <tt>after:<column-id></tt>, where
197
185
  # <tt><column-id></tt> is the id value of a column in the same project.
198
186
  # @return [Sawyer::Resource] Result
199
187
  # @see https://developer.github.com/v3/projects/columns/#move-a-project-column
200
188
  # @example
201
- # @client.move_project_column(3049, "last")
189
+ # @client.move_project_column(30294, "last")
202
190
  def move_project_column(id, position, options = {})
203
- opts = ensure_api_media_type(:projects, options)
204
- opts[:position] = position
205
- post "projects/columns/#{id}/moves", opts
191
+ options[:position] = position
192
+ post "projects/columns/#{id}/moves", options
206
193
  end
207
194
 
208
195
  # List columns cards
@@ -213,10 +200,9 @@ module Octokit
213
200
  # @return [Array<Sawyer::Resource>] Cards in the column
214
201
  # @see https://developer.github.com/v3/projects/cards/#list-project-cards
215
202
  # @example
216
- # @client.column_cards(123847)
203
+ # @client.column_cards(30294)
217
204
  def column_cards(id, options = {})
218
- opts = ensure_api_media_type(:projects, options)
219
- paginate "projects/columns/#{id}/cards", opts
205
+ paginate "projects/columns/#{id}/cards", options
220
206
  end
221
207
 
222
208
  # Create project card
@@ -238,8 +224,7 @@ module Octokit
238
224
  # @example Create a project card for an repository issue
239
225
  # @client.create_project_card(123495, content_id: 1, content_type: 'Issue')
240
226
  def create_project_card(id, options = {})
241
- opts = ensure_api_media_type(:projects, options)
242
- post "projects/columns/#{id}/cards", opts
227
+ post "projects/columns/#{id}/cards", options
243
228
  end
244
229
 
245
230
  # Get a project card
@@ -252,8 +237,7 @@ module Octokit
252
237
  # @example
253
238
  # @client.project_card(123495)
254
239
  def project_card(id, options = {})
255
- opts = ensure_api_media_type(:projects, options)
256
- get "projects/columns/cards/#{id}", opts
240
+ get "projects/columns/cards/#{id}", options
257
241
  end
258
242
 
259
243
  # Update a project card
@@ -269,8 +253,7 @@ module Octokit
269
253
  # @example
270
254
  # @client.update_project_card(12345, note: 'new note')
271
255
  def update_project_card(id, options = {})
272
- opts = ensure_api_media_type(:projects, options)
273
- patch "projects/columns/cards/#{id}", opts
256
+ patch "projects/columns/cards/#{id}", options
274
257
  end
275
258
 
276
259
  # Move a project card
@@ -290,13 +273,12 @@ module Octokit
290
273
  # @example Move a card to the top of another column
291
274
  # @client.move_project_card(123495, 'top', column_id: 59402)
292
275
  def move_project_card(id, position, options = {})
293
- opts = ensure_api_media_type(:projects, options)
294
- opts[:position] = position
295
- post "projects/columns/cards/#{id}/moves", opts
276
+ options[:position] = position
277
+ post "projects/columns/cards/#{id}/moves", options
296
278
  end
297
279
 
298
280
  # Delete a project card
299
- #
281
+ #
300
282
  # Requires authenticated client
301
283
  #
302
284
  # @param id [Integer] Project card id
@@ -305,10 +287,8 @@ module Octokit
305
287
  # @example
306
288
  # @client.delete_project_card(123495)
307
289
  def delete_project_card(id, options = {})
308
- opts = ensure_api_media_type(:projects, options)
309
- boolean_from_response :delete, "projects/columns/cards/#{id}", opts
290
+ boolean_from_response :delete, "projects/columns/cards/#{id}", options
310
291
  end
311
-
312
292
  end # Projects
313
293
  end
314
294
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the PubSubHubbub API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/hooks/#pubsubhubbub
7
8
  module PubSubHubbub
8
-
9
9
  # Subscribe to a pubsub topic
10
10
  #
11
11
  # @param topic [String] A recoginized and supported pubsub topic
@@ -18,11 +18,11 @@ module Octokit
18
18
  # client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
19
19
  def subscribe(topic, callback, secret = nil)
20
20
  options = {
21
- :"hub.callback" => callback,
22
- :"hub.mode" => "subscribe",
23
- :"hub.topic" => topic
21
+ 'hub.callback': callback,
22
+ 'hub.mode': 'subscribe',
23
+ 'hub.topic': topic
24
24
  }
25
- options.merge!(:"hub.secret" => secret) unless secret.nil?
25
+ options.merge!('hub.secret': secret) unless secret.nil?
26
26
 
27
27
  response = pub_sub_hubbub_request(options)
28
28
 
@@ -40,9 +40,9 @@ module Octokit
40
40
  # client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
41
41
  def unsubscribe(topic, callback)
42
42
  options = {
43
- :"hub.callback" => callback,
44
- :"hub.mode" => "unsubscribe",
45
- :"hub.topic" => topic
43
+ 'hub.callback': callback,
44
+ 'hub.mode': 'unsubscribe',
45
+ 'hub.topic': topic
46
46
  }
47
47
  response = pub_sub_hubbub_request(options)
48
48
 
@@ -64,7 +64,7 @@ module Octokit
64
64
  # client.subscribe_service_hook('joshk/device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })
65
65
  def subscribe_service_hook(repo, service_name, service_arguments = {}, secret = nil)
66
66
  topic = "#{Octokit.web_endpoint}#{Repository.new(repo)}/events/push"
67
- callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].map{ |p| URI.encode_www_form_component(p) }.join("=") }.join("&") }"
67
+ callback = "github://#{service_name}?#{service_arguments.collect { |k, v| [k, v].map { |p| URI.encode_www_form_component(p) }.join('=') }.join('&')}"
68
68
  subscribe(topic, callback, secret)
69
69
  end
70
70
 
@@ -88,20 +88,20 @@ module Octokit
88
88
  def pub_sub_hubbub_request(options = {})
89
89
  # This method is janky, bypass normal stack so we don't
90
90
  # serialize request as JSON
91
- conn = Faraday.new(:url => @api_endpoint) do |http|
91
+ conn = Faraday.new(url: @api_endpoint) do |http|
92
92
  http.headers[:user_agent] = user_agent
93
93
  if basic_authenticated?
94
- http.basic_auth(@login, @password)
94
+ http.request(*FARADAY_BASIC_AUTH_KEYS, @login, @password)
95
95
  elsif token_authenticated?
96
- http.authorization 'token', @access_token
96
+ http.request :authorization, 'token', @access_token
97
97
  end
98
- http.request :url_encoded
98
+ http.request :url_encoded
99
99
  http.use Octokit::Response::RaiseError
100
- http.adapter Faraday.default_adapter
100
+ http.adapter Faraday.default_adapter
101
101
  end
102
102
 
103
103
  conn.post do |req|
104
- req.url "hub"
104
+ req.url 'hub'
105
105
  req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
106
106
  req.body = options
107
107
  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 :pulls :pull_requests
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 :pull :pull_request
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
- :base => base,
53
- :head => head,
54
- :title => title,
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
- :base => base,
74
- :head => head,
75
- :issue => issue
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, 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.
@@ -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 = arguments.shift
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! :state => 'closed'
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 :pull_commits :pull_request_commits
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 => '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 = {})
159
161
  paginate("#{Repository.path repo}/pulls/comments", options)
160
162
  end
161
- alias :pulls_comments :pull_requests_comments
162
- alias :reviews_comments :pull_requests_comments
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 :pull_comments :pull_request_comments
175
- alias :review_comments :pull_request_comments
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 :pull_comment :pull_request_comment
189
- alias :review_comment :pull_request_comment
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
  #
@@ -203,15 +205,15 @@ module Octokit
203
205
  # "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
204
206
  def create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {})
205
207
  options.merge!({
206
- :body => body,
207
- :commit_id => commit_id,
208
- :path => path,
209
- :position => position
210
- })
208
+ body: body,
209
+ commit_id: commit_id,
210
+ path: path,
211
+ position: position
212
+ })
211
213
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
212
214
  end
213
- alias :create_pull_comment :create_pull_request_comment
214
- alias :create_view_comment :create_pull_request_comment
215
+ alias create_pull_comment create_pull_request_comment
216
+ alias create_view_comment create_pull_request_comment
215
217
 
216
218
  # Create reply to a pull request comment
217
219
  #
@@ -225,13 +227,13 @@ module Octokit
225
227
  # @client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)
226
228
  def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})
227
229
  options.merge!({
228
- :body => body,
229
- :in_reply_to => comment_id
230
- })
230
+ body: body,
231
+ in_reply_to: comment_id
232
+ })
231
233
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
232
234
  end
233
- alias :create_pull_reply :create_pull_request_comment_reply
234
- alias :create_review_reply :create_pull_request_comment_reply
235
+ alias create_pull_reply create_pull_request_comment_reply
236
+ alias create_review_reply create_pull_request_comment_reply
235
237
 
236
238
  # Update pull request comment
237
239
  #
@@ -243,11 +245,11 @@ module Octokit
243
245
  # @example
244
246
  # @client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")
245
247
  def update_pull_request_comment(repo, comment_id, body, options = {})
246
- options.merge! :body => body
248
+ options.merge! body: body
247
249
  patch("#{Repository.path repo}/pulls/comments/#{comment_id}", options)
248
250
  end
249
- alias :update_pull_comment :update_pull_request_comment
250
- alias :update_review_comment :update_pull_request_comment
251
+ alias update_pull_comment update_pull_request_comment
252
+ alias update_review_comment update_pull_request_comment
251
253
 
252
254
  # Delete pull request comment
253
255
  #
@@ -260,8 +262,8 @@ module Octokit
260
262
  def delete_pull_request_comment(repo, comment_id, options = {})
261
263
  boolean_from_response(:delete, "#{Repository.path repo}/pulls/comments/#{comment_id}", options)
262
264
  end
263
- alias :delete_pull_comment :delete_pull_request_comment
264
- alias :delete_review_comment :delete_pull_request_comment
265
+ alias delete_pull_comment delete_pull_request_comment
266
+ alias delete_review_comment delete_pull_request_comment
265
267
 
266
268
  # List files on a pull request
267
269
  #
@@ -272,7 +274,18 @@ module Octokit
272
274
  def pull_request_files(repo, number, options = {})
273
275
  paginate "#{Repository.path repo}/pulls/#{number}/files", options
274
276
  end
275
- alias :pull_files :pull_request_files
277
+ alias pull_files pull_request_files
278
+
279
+ # Update a pull request branch
280
+ #
281
+ # @see https://developer.github.com/v3/pulls/#update-a-pull-request-branch
282
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
283
+ # @param number [Integer] Number of pull request
284
+ # @param options [Hash] Optional parameters (e.g. expected_head_sha)
285
+ # @return [Boolean] True if the pull request branch has been updated
286
+ def update_pull_request_branch(repo, number, options = {})
287
+ boolean_from_response(:put, "#{Repository.path repo}/pulls/#{number}/update-branch", options)
288
+ end
276
289
 
277
290
  # Merge a pull request
278
291
  #
@@ -281,8 +294,8 @@ module Octokit
281
294
  # @param number [Integer] Number of pull request
282
295
  # @param commit_message [String] Optional commit message for the merge commit
283
296
  # @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 => commit_message})
297
+ def merge_pull_request(repo, number, commit_message = '', options = {})
298
+ put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({ commit_message: commit_message })
286
299
  end
287
300
 
288
301
  # Check pull request merge status
@@ -294,8 +307,7 @@ module Octokit
294
307
  def pull_merged?(repo, number, options = {})
295
308
  boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
296
309
  end
297
- alias :pull_request_merged? :pull_merged?
298
-
310
+ alias pull_request_merged? pull_merged?
299
311
  end
300
312
  end
301
313
  end