octokit 4.22.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +113 -75
  3. data/Rakefile +20 -14
  4. data/lib/ext/sawyer/relation.rb +4 -2
  5. data/lib/octokit/arguments.rb +2 -2
  6. data/lib/octokit/authentication.rb +10 -3
  7. data/lib/octokit/client/actions_artifacts.rb +71 -0
  8. data/lib/octokit/client/actions_secrets.rb +10 -9
  9. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  10. data/lib/octokit/client/actions_workflow_runs.rb +23 -3
  11. data/lib/octokit/client/actions_workflows.rb +27 -2
  12. data/lib/octokit/client/apps.rb +26 -26
  13. data/lib/octokit/client/checks.rb +18 -9
  14. data/lib/octokit/client/code_scanning.rb +53 -0
  15. data/lib/octokit/client/codespaces_secrets.rb +59 -0
  16. data/lib/octokit/client/commit_branches.rb +2 -2
  17. data/lib/octokit/client/commit_comments.rb +8 -8
  18. data/lib/octokit/client/commit_pulls.rb +2 -2
  19. data/lib/octokit/client/commits.rb +25 -33
  20. data/lib/octokit/client/community_profile.rb +2 -3
  21. data/lib/octokit/client/contents.rb +20 -21
  22. data/lib/octokit/client/dependabot_secrets.rb +59 -0
  23. data/lib/octokit/client/deployments.rb +6 -6
  24. data/lib/octokit/client/downloads.rb +5 -6
  25. data/lib/octokit/client/emojis.rb +3 -3
  26. data/lib/octokit/client/environments.rb +55 -0
  27. data/lib/octokit/client/events.rb +4 -5
  28. data/lib/octokit/client/feeds.rb +4 -5
  29. data/lib/octokit/client/gists.rb +6 -6
  30. data/lib/octokit/client/gitignore.rb +3 -3
  31. data/lib/octokit/client/hooks.rb +9 -19
  32. data/lib/octokit/client/issues.rb +14 -15
  33. data/lib/octokit/client/labels.rb +10 -10
  34. data/lib/octokit/client/legacy_search.rb +3 -3
  35. data/lib/octokit/client/licenses.rb +3 -6
  36. data/lib/octokit/client/markdown.rb +3 -3
  37. data/lib/octokit/client/marketplace.rb +4 -4
  38. data/lib/octokit/client/meta.rb +4 -5
  39. data/lib/octokit/client/milestones.rb +5 -5
  40. data/lib/octokit/client/notifications.rb +6 -6
  41. data/lib/octokit/client/oauth_applications.rb +0 -6
  42. data/lib/octokit/client/objects.rb +14 -14
  43. data/lib/octokit/client/organizations.rb +100 -56
  44. data/lib/octokit/client/pages.rb +5 -7
  45. data/lib/octokit/client/projects.rb +44 -64
  46. data/lib/octokit/client/pub_sub_hubbub.rb +15 -15
  47. data/lib/octokit/client/pull_requests.rb +54 -42
  48. data/lib/octokit/client/rate_limit.rb +9 -11
  49. data/lib/octokit/client/reactions.rb +13 -16
  50. data/lib/octokit/client/refs.rb +14 -17
  51. data/lib/octokit/client/releases.rb +13 -13
  52. data/lib/octokit/client/repositories.rb +49 -69
  53. data/lib/octokit/client/repository_invitations.rb +3 -3
  54. data/lib/octokit/client/reviews.rb +8 -8
  55. data/lib/octokit/client/say.rb +4 -5
  56. data/lib/octokit/client/search.rb +24 -10
  57. data/lib/octokit/client/service_status.rb +19 -9
  58. data/lib/octokit/client/source_import.rb +7 -12
  59. data/lib/octokit/client/stats.rb +10 -9
  60. data/lib/octokit/client/statuses.rb +5 -5
  61. data/lib/octokit/client/tokens.rb +31 -0
  62. data/lib/octokit/client/traffic.rb +6 -11
  63. data/lib/octokit/client/users.rb +27 -33
  64. data/lib/octokit/client.rb +40 -16
  65. data/lib/octokit/configurable.rb +34 -30
  66. data/lib/octokit/connection.rb +28 -21
  67. data/lib/octokit/default.rb +48 -35
  68. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  69. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  70. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  71. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  72. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  73. data/lib/octokit/enterprise_admin_client.rb +9 -3
  74. data/lib/octokit/enterprise_management_console_client/management_console.rb +32 -32
  75. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  76. data/lib/octokit/error.rb +45 -34
  77. data/lib/octokit/gist.rb +3 -4
  78. data/lib/octokit/middleware/follow_redirects.rb +12 -11
  79. data/lib/octokit/organization.rb +3 -1
  80. data/lib/octokit/rate_limit.rb +8 -6
  81. data/lib/octokit/repo_arguments.rb +2 -3
  82. data/lib/octokit/repository.rb +24 -24
  83. data/lib/octokit/response/base_middleware.rb +10 -0
  84. data/lib/octokit/response/feed_parser.rb +5 -7
  85. data/lib/octokit/response/raise_error.rb +4 -4
  86. data/lib/octokit/user.rb +4 -2
  87. data/lib/octokit/version.rb +4 -2
  88. data/lib/octokit/warnable.rb +4 -5
  89. data/lib/octokit.rb +15 -8
  90. data/octokit.gemspec +12 -11
  91. metadata +20 -33
  92. data/lib/octokit/client/authorizations.rb +0 -182
  93. data/lib/octokit/preview.rb +0 -46
@@ -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.request :basic_auth, @login, @password
94
+ http.request(*FARADAY_BASIC_AUTH_KEYS, @login, @password)
95
95
  elsif token_authenticated?
96
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
  #
@@ -199,21 +199,23 @@ module Octokit
199
199
  # @param path [String] Relative path of the file to comment on.
200
200
  # @param position [Integer] Line index in the diff to comment on.
201
201
  # @return [Sawyer::Resource] Hash representing the new comment
202
+ # @deprecated The position will be deprecated in the next major version. Please refer to the details below.
202
203
  # @see https://developer.github.com/v3/pulls/comments/#create-a-comment
203
204
  # @example
204
205
  # @client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
205
206
  # "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
206
207
  def create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {})
208
+ octokit_warn 'Deprecated: The position will be deprecated in the next major version.'
207
209
  options.merge!({
208
- :body => body,
209
- :commit_id => commit_id,
210
- :path => path,
211
- :position => position
212
- })
210
+ body: body,
211
+ commit_id: commit_id,
212
+ path: path,
213
+ position: position
214
+ })
213
215
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
214
216
  end
215
- alias :create_pull_comment :create_pull_request_comment
216
- alias :create_view_comment :create_pull_request_comment
217
+ alias create_pull_comment create_pull_request_comment
218
+ alias create_view_comment create_pull_request_comment
217
219
 
218
220
  # Create reply to a pull request comment
219
221
  #
@@ -227,13 +229,13 @@ module Octokit
227
229
  # @client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)
228
230
  def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})
229
231
  options.merge!({
230
- :body => body,
231
- :in_reply_to => comment_id
232
- })
232
+ body: body,
233
+ in_reply_to: comment_id
234
+ })
233
235
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
234
236
  end
235
- alias :create_pull_reply :create_pull_request_comment_reply
236
- alias :create_review_reply :create_pull_request_comment_reply
237
+ alias create_pull_reply create_pull_request_comment_reply
238
+ alias create_review_reply create_pull_request_comment_reply
237
239
 
238
240
  # Update pull request comment
239
241
  #
@@ -245,11 +247,11 @@ module Octokit
245
247
  # @example
246
248
  # @client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")
247
249
  def update_pull_request_comment(repo, comment_id, body, options = {})
248
- options.merge! :body => body
250
+ options.merge! body: body
249
251
  patch("#{Repository.path repo}/pulls/comments/#{comment_id}", options)
250
252
  end
251
- alias :update_pull_comment :update_pull_request_comment
252
- alias :update_review_comment :update_pull_request_comment
253
+ alias update_pull_comment update_pull_request_comment
254
+ alias update_review_comment update_pull_request_comment
253
255
 
254
256
  # Delete pull request comment
255
257
  #
@@ -262,8 +264,8 @@ module Octokit
262
264
  def delete_pull_request_comment(repo, comment_id, options = {})
263
265
  boolean_from_response(:delete, "#{Repository.path repo}/pulls/comments/#{comment_id}", options)
264
266
  end
265
- alias :delete_pull_comment :delete_pull_request_comment
266
- alias :delete_review_comment :delete_pull_request_comment
267
+ alias delete_pull_comment delete_pull_request_comment
268
+ alias delete_review_comment delete_pull_request_comment
267
269
 
268
270
  # List files on a pull request
269
271
  #
@@ -274,7 +276,18 @@ module Octokit
274
276
  def pull_request_files(repo, number, options = {})
275
277
  paginate "#{Repository.path repo}/pulls/#{number}/files", options
276
278
  end
277
- alias :pull_files :pull_request_files
279
+ alias pull_files pull_request_files
280
+
281
+ # Update a pull request branch
282
+ #
283
+ # @see https://developer.github.com/v3/pulls/#update-a-pull-request-branch
284
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
285
+ # @param number [Integer] Number of pull request
286
+ # @param options [Hash] Optional parameters (e.g. expected_head_sha)
287
+ # @return [Boolean] True if the pull request branch has been updated
288
+ def update_pull_request_branch(repo, number, options = {})
289
+ boolean_from_response(:put, "#{Repository.path repo}/pulls/#{number}/update-branch", options)
290
+ end
278
291
 
279
292
  # Merge a pull request
280
293
  #
@@ -283,8 +296,8 @@ module Octokit
283
296
  # @param number [Integer] Number of pull request
284
297
  # @param commit_message [String] Optional commit message for the merge commit
285
298
  # @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})
299
+ def merge_pull_request(repo, number, commit_message = '', options = {})
300
+ put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({ commit_message: commit_message })
288
301
  end
289
302
 
290
303
  # Check pull request merge status
@@ -296,8 +309,7 @@ module Octokit
296
309
  def pull_merged?(repo, number, options = {})
297
310
  boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
298
311
  end
299
- alias :pull_request_merged? :pull_merged?
300
-
312
+ alias pull_request_merged? pull_merged?
301
313
  end
302
314
  end
303
315
  end
@@ -1,17 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for API rate limiting info
5
6
  #
6
7
  # @see https://developer.github.com/v3/#rate-limiting
7
8
  module RateLimit
8
-
9
9
  # Get rate limit info from last response if available
10
10
  # or make a new request to fetch rate limit
11
11
  #
12
12
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
13
13
  # @return [Octokit::RateLimit] Rate limit info
14
- def rate_limit(options = {})
14
+ def rate_limit(_options = {})
15
15
  return rate_limit! if last_response.nil?
16
16
 
17
17
  Octokit::RateLimit.from_response(last_response)
@@ -22,8 +22,8 @@ module Octokit
22
22
  #
23
23
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
24
24
  # @return [Integer] Number of requests remaining in this period
25
- def rate_limit_remaining(options = {})
26
- octokit_warn "Deprecated: Please use .rate_limit.remaining"
25
+ def rate_limit_remaining(_options = {})
26
+ octokit_warn 'Deprecated: Please use .rate_limit.remaining'
27
27
  rate_limit.remaining
28
28
  end
29
29
  alias ratelimit_remaining rate_limit_remaining
@@ -32,8 +32,8 @@ module Octokit
32
32
  #
33
33
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
34
34
  # @return [Octokit::RateLimit] Rate limit info
35
- def rate_limit!(options = {})
36
- get "rate_limit"
35
+ def rate_limit!(_options = {})
36
+ get 'rate_limit'
37
37
  Octokit::RateLimit.from_response(last_response)
38
38
  end
39
39
  alias ratelimit! rate_limit!
@@ -42,13 +42,11 @@ module Octokit
42
42
  #
43
43
  # @see https://developer.github.com/v3/rate_limit/#rate-limit
44
44
  # @return [Integer] Number of requests remaining in this period
45
- def rate_limit_remaining!(options = {})
46
- octokit_warn "Deprecated: Please use .rate_limit!.remaining"
45
+ def rate_limit_remaining!(_options = {})
46
+ octokit_warn 'Deprecated: Please use .rate_limit!.remaining'
47
47
  rate_limit!.remaining
48
48
  end
49
49
  alias ratelimit_remaining! rate_limit_remaining!
50
-
51
50
  end
52
51
  end
53
52
  end
54
-