octokit 4.15.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +2 -4
  3. data/README.md +104 -80
  4. data/Rakefile +5 -3
  5. data/lib/ext/sawyer/relation.rb +4 -2
  6. data/lib/octokit/arguments.rb +2 -2
  7. data/lib/octokit/authentication.rb +12 -14
  8. data/lib/octokit/client/actions_artifacts.rb +71 -0
  9. data/lib/octokit/client/actions_secrets.rb +59 -0
  10. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  11. data/lib/octokit/client/actions_workflow_runs.rb +125 -0
  12. data/lib/octokit/client/actions_workflows.rb +68 -0
  13. data/lib/octokit/client/apps.rb +53 -53
  14. data/lib/octokit/client/checks.rb +18 -29
  15. data/lib/octokit/client/commit_branches.rb +20 -0
  16. data/lib/octokit/client/commit_comments.rb +8 -8
  17. data/lib/octokit/client/commit_pulls.rb +2 -2
  18. data/lib/octokit/client/commits.rb +31 -34
  19. data/lib/octokit/client/community_profile.rb +2 -3
  20. data/lib/octokit/client/contents.rb +24 -21
  21. data/lib/octokit/client/deployments.rb +16 -6
  22. data/lib/octokit/client/downloads.rb +5 -6
  23. data/lib/octokit/client/emojis.rb +3 -3
  24. data/lib/octokit/client/events.rb +4 -4
  25. data/lib/octokit/client/feeds.rb +4 -5
  26. data/lib/octokit/client/gists.rb +6 -6
  27. data/lib/octokit/client/gitignore.rb +3 -3
  28. data/lib/octokit/client/hooks.rb +9 -19
  29. data/lib/octokit/client/issues.rb +14 -15
  30. data/lib/octokit/client/labels.rb +10 -10
  31. data/lib/octokit/client/legacy_search.rb +3 -3
  32. data/lib/octokit/client/licenses.rb +3 -6
  33. data/lib/octokit/client/markdown.rb +3 -3
  34. data/lib/octokit/client/marketplace.rb +4 -4
  35. data/lib/octokit/client/meta.rb +4 -5
  36. data/lib/octokit/client/milestones.rb +5 -5
  37. data/lib/octokit/client/notifications.rb +6 -6
  38. data/lib/octokit/client/oauth_applications.rb +116 -0
  39. data/lib/octokit/client/objects.rb +14 -14
  40. data/lib/octokit/client/organizations.rb +112 -70
  41. data/lib/octokit/client/pages.rb +5 -7
  42. data/lib/octokit/client/projects.rb +44 -64
  43. data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
  44. data/lib/octokit/client/pull_requests.rb +52 -42
  45. data/lib/octokit/client/rate_limit.rb +9 -11
  46. data/lib/octokit/client/reactions.rb +6 -11
  47. data/lib/octokit/client/refs.rb +32 -19
  48. data/lib/octokit/client/releases.rb +13 -13
  49. data/lib/octokit/client/repositories.rb +123 -69
  50. data/lib/octokit/client/repository_invitations.rb +3 -3
  51. data/lib/octokit/client/reviews.rb +7 -7
  52. data/lib/octokit/client/say.rb +4 -5
  53. data/lib/octokit/client/search.rb +24 -11
  54. data/lib/octokit/client/service_status.rb +19 -9
  55. data/lib/octokit/client/source_import.rb +7 -12
  56. data/lib/octokit/client/stats.rb +10 -9
  57. data/lib/octokit/client/statuses.rb +5 -5
  58. data/lib/octokit/client/tokens.rb +31 -0
  59. data/lib/octokit/client/traffic.rb +6 -11
  60. data/lib/octokit/client/users.rb +104 -24
  61. data/lib/octokit/client.rb +44 -18
  62. data/lib/octokit/configurable.rb +34 -30
  63. data/lib/octokit/connection.rb +28 -26
  64. data/lib/octokit/default.rb +46 -35
  65. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  66. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  67. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  68. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  69. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  70. data/lib/octokit/enterprise_admin_client.rb +9 -3
  71. data/lib/octokit/enterprise_management_console_client/management_console.rb +32 -32
  72. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  73. data/lib/octokit/error.rb +72 -27
  74. data/lib/octokit/gist.rb +2 -3
  75. data/lib/octokit/middleware/follow_redirects.rb +15 -11
  76. data/lib/octokit/organization.rb +3 -1
  77. data/lib/octokit/rate_limit.rb +3 -3
  78. data/lib/octokit/repo_arguments.rb +2 -3
  79. data/lib/octokit/repository.rb +24 -24
  80. data/lib/octokit/response/base_middleware.rb +10 -0
  81. data/lib/octokit/response/feed_parser.rb +5 -9
  82. data/lib/octokit/response/raise_error.rb +4 -6
  83. data/lib/octokit/user.rb +4 -2
  84. data/lib/octokit/version.rb +4 -2
  85. data/lib/octokit/warnable.rb +4 -5
  86. data/lib/octokit.rb +15 -8
  87. data/octokit.gemspec +12 -10
  88. metadata +25 -17
  89. data/lib/octokit/client/authorizations.rb +0 -250
  90. data/lib/octokit/preview.rb +0 -46
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the 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
@@ -24,8 +24,7 @@ module Octokit
24
24
  # @example
25
25
  # Octokit.pages_build("github/developer.github.com", 5472601)
26
26
  def pages_build(repo, id, options = {})
27
- opts = ensure_api_media_type(:pages, options)
28
- get "#{Repository.path repo}/pages/builds/#{id}", opts
27
+ get "#{Repository.path repo}/pages/builds/#{id}", options
29
28
  end
30
29
 
31
30
  # List Pages builds for a repository
@@ -36,7 +35,7 @@ module Octokit
36
35
  def pages_builds(repo, options = {})
37
36
  get "#{Repository.path repo}/pages/builds", options
38
37
  end
39
- alias :list_pages_builds :pages_builds
38
+ alias list_pages_builds pages_builds
40
39
 
41
40
  # List the latest Pages build information for a repository
42
41
  #
@@ -55,8 +54,7 @@ module Octokit
55
54
  # @return [Sawyer::Resource] Request result
56
55
  # @see https://developer.github.com/v3/repos/pages/#request-a-page-build
57
56
  def request_page_build(repo, options = {})
58
- opts = ensure_api_media_type(:pages, options)
59
- post "#{Repository.path repo}/pages/builds", opts
57
+ post "#{Repository.path repo}/pages/builds", options
60
58
  end
61
59
  end
62
60
  end
@@ -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
- paginate "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
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
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
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
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,7 +180,7 @@ 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
@@ -200,9 +188,8 @@ module Octokit
200
188
  # @example
201
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
@@ -215,8 +202,7 @@ module Octokit
215
202
  # @example
216
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,11 +1,11 @@
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)
@@ -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
  #
@@ -28,11 +28,11 @@ module Octokit
28
28
  # @param number [Integer] Number of the pull request to fetch
29
29
  # @return [Sawyer::Resource] Pull request info
30
30
  # @example
31
- # Octokit.pull_request('rails/rails', 42, :state => 'closed')
31
+ # Octokit.pull_request('rails/rails', 42, :state => 'closed')
32
32
  def pull_request(repo, number, options = {})
33
33
  get "#{Repository.path repo}/pulls/#{number}", options
34
34
  end
35
- alias :pull :pull_request
35
+ alias pull pull_request
36
36
 
37
37
  # Create a pull request
38
38
  #
@@ -51,9 +51,9 @@ module Octokit
51
51
  # "Pull Request title", "Pull Request body")
52
52
  def create_pull_request(repo, base, head, title, body = nil, options = {})
53
53
  pull = {
54
- :base => base,
55
- :head => head,
56
- :title => title,
54
+ base: base,
55
+ head: head,
56
+ title: title
57
57
  }
58
58
  pull[:body] = body unless body.nil?
59
59
  post "#{Repository.path repo}/pulls", options.merge(pull)
@@ -72,9 +72,9 @@ module Octokit
72
72
  # @return [Sawyer::Resource] The newly created pull request
73
73
  def create_pull_request_for_issue(repo, base, head, issue, options = {})
74
74
  pull = {
75
- :base => base,
76
- :head => head,
77
- :issue => issue
75
+ base: base,
76
+ head: head,
77
+ issue: issue
78
78
  }
79
79
  post "#{Repository.path repo}/pulls", options.merge(pull)
80
80
  end
@@ -103,7 +103,7 @@ module Octokit
103
103
  # @client.update_pull_request('octokit/octokit.rb', 67, nil, '')
104
104
  def update_pull_request(*args)
105
105
  arguments = Octokit::Arguments.new(args)
106
- repo = arguments.shift
106
+ repo = arguments.shift
107
107
  number = arguments.shift
108
108
  patch "#{Repository.path repo}/pulls/#{number}", arguments.options
109
109
  end
@@ -117,7 +117,7 @@ module Octokit
117
117
  # @example
118
118
  # @client.close_pull_request('octokit/octokit.rb', 67)
119
119
  def close_pull_request(repo, number, options = {})
120
- options.merge! :state => 'closed'
120
+ options.merge! state: 'closed'
121
121
  update_pull_request(repo, number, options)
122
122
  end
123
123
 
@@ -130,7 +130,7 @@ module Octokit
130
130
  def pull_request_commits(repo, number, options = {})
131
131
  paginate "#{Repository.path repo}/pulls/#{number}/commits", options
132
132
  end
133
- alias :pull_commits :pull_request_commits
133
+ alias pull_commits pull_request_commits
134
134
 
135
135
  # List pull request comments for a repository
136
136
  #
@@ -160,8 +160,8 @@ module Octokit
160
160
  def pull_requests_comments(repo, options = {})
161
161
  paginate("#{Repository.path repo}/pulls/comments", options)
162
162
  end
163
- alias :pulls_comments :pull_requests_comments
164
- alias :reviews_comments :pull_requests_comments
163
+ alias pulls_comments pull_requests_comments
164
+ alias reviews_comments pull_requests_comments
165
165
 
166
166
  # List comments on a pull request
167
167
  #
@@ -173,8 +173,8 @@ module Octokit
173
173
  # return the comments for a pull request
174
174
  paginate("#{Repository.path repo}/pulls/#{number}/comments", options)
175
175
  end
176
- alias :pull_comments :pull_request_comments
177
- alias :review_comments :pull_request_comments
176
+ alias pull_comments pull_request_comments
177
+ alias review_comments pull_request_comments
178
178
 
179
179
  # Get a pull request comment
180
180
  #
@@ -187,8 +187,8 @@ module Octokit
187
187
  def pull_request_comment(repo, comment_id, options = {})
188
188
  get "#{Repository.path repo}/pulls/comments/#{comment_id}", options
189
189
  end
190
- alias :pull_comment :pull_request_comment
191
- alias :review_comment :pull_request_comment
190
+ alias pull_comment pull_request_comment
191
+ alias review_comment pull_request_comment
192
192
 
193
193
  # Create a pull request comment
194
194
  #
@@ -205,15 +205,15 @@ module Octokit
205
205
  # "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
206
206
  def create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {})
207
207
  options.merge!({
208
- :body => body,
209
- :commit_id => commit_id,
210
- :path => path,
211
- :position => position
212
- })
208
+ body: body,
209
+ commit_id: commit_id,
210
+ path: path,
211
+ position: position
212
+ })
213
213
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
214
214
  end
215
- alias :create_pull_comment :create_pull_request_comment
216
- 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
217
217
 
218
218
  # Create reply to a pull request comment
219
219
  #
@@ -227,13 +227,13 @@ module Octokit
227
227
  # @client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)
228
228
  def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})
229
229
  options.merge!({
230
- :body => body,
231
- :in_reply_to => comment_id
232
- })
230
+ body: body,
231
+ in_reply_to: comment_id
232
+ })
233
233
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
234
234
  end
235
- alias :create_pull_reply :create_pull_request_comment_reply
236
- 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
237
237
 
238
238
  # Update pull request comment
239
239
  #
@@ -245,11 +245,11 @@ module Octokit
245
245
  # @example
246
246
  # @client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")
247
247
  def update_pull_request_comment(repo, comment_id, body, options = {})
248
- options.merge! :body => body
248
+ options.merge! body: body
249
249
  patch("#{Repository.path repo}/pulls/comments/#{comment_id}", options)
250
250
  end
251
- alias :update_pull_comment :update_pull_request_comment
252
- 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
253
253
 
254
254
  # Delete pull request comment
255
255
  #
@@ -262,8 +262,8 @@ module Octokit
262
262
  def delete_pull_request_comment(repo, comment_id, options = {})
263
263
  boolean_from_response(:delete, "#{Repository.path repo}/pulls/comments/#{comment_id}", options)
264
264
  end
265
- alias :delete_pull_comment :delete_pull_request_comment
266
- 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
267
267
 
268
268
  # List files on a pull request
269
269
  #
@@ -274,7 +274,18 @@ module Octokit
274
274
  def pull_request_files(repo, number, options = {})
275
275
  paginate "#{Repository.path repo}/pulls/#{number}/files", options
276
276
  end
277
- 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
278
289
 
279
290
  # Merge a pull request
280
291
  #
@@ -283,8 +294,8 @@ module Octokit
283
294
  # @param number [Integer] Number of pull request
284
295
  # @param commit_message [String] Optional commit message for the merge commit
285
296
  # @return [Array<Sawyer::Resource>] Merge commit info if successful
286
- def merge_pull_request(repo, number, commit_message='', options = {})
287
- 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 })
288
299
  end
289
300
 
290
301
  # Check pull request merge status
@@ -296,8 +307,7 @@ module Octokit
296
307
  def pull_merged?(repo, number, options = {})
297
308
  boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
298
309
  end
299
- alias :pull_request_merged? :pull_merged?
300
-
310
+ alias pull_request_merged? pull_merged?
301
311
  end
302
312
  end
303
313
  end