octokit 4.2.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.md +14 -13
  3. data/LICENSE.md +1 -1
  4. data/README.md +275 -127
  5. data/Rakefile +20 -14
  6. data/lib/ext/sawyer/relation.rb +12 -0
  7. data/lib/octokit/arguments.rb +3 -3
  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 +161 -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 +259 -0
  15. data/lib/octokit/client/checks.rb +200 -0
  16. data/lib/octokit/client/code_scanning.rb +190 -0
  17. data/lib/octokit/client/codespaces_secrets.rb +108 -0
  18. data/lib/octokit/client/commit_branches.rb +20 -0
  19. data/lib/octokit/client/commit_comments.rb +8 -8
  20. data/lib/octokit/client/commit_pulls.rb +20 -0
  21. data/lib/octokit/client/commits.rb +32 -35
  22. data/lib/octokit/client/community_profile.rb +21 -0
  23. data/lib/octokit/client/contents.rb +24 -21
  24. data/lib/octokit/client/dependabot_secrets.rb +108 -0
  25. data/lib/octokit/client/deployments.rb +29 -7
  26. data/lib/octokit/client/downloads.rb +5 -6
  27. data/lib/octokit/client/emojis.rb +3 -3
  28. data/lib/octokit/client/environments.rb +58 -0
  29. data/lib/octokit/client/events.rb +4 -4
  30. data/lib/octokit/client/feeds.rb +4 -5
  31. data/lib/octokit/client/gists.rb +36 -8
  32. data/lib/octokit/client/gitignore.rb +3 -3
  33. data/lib/octokit/client/hooks.rb +34 -30
  34. data/lib/octokit/client/issues.rb +97 -14
  35. data/lib/octokit/client/labels.rb +17 -17
  36. data/lib/octokit/client/legacy_search.rb +3 -3
  37. data/lib/octokit/client/licenses.rb +5 -8
  38. data/lib/octokit/client/markdown.rb +3 -3
  39. data/lib/octokit/client/marketplace.rb +56 -0
  40. data/lib/octokit/client/meta.rb +4 -5
  41. data/lib/octokit/client/milestones.rb +14 -14
  42. data/lib/octokit/client/notifications.rb +7 -11
  43. data/lib/octokit/client/oauth_applications.rb +116 -0
  44. data/lib/octokit/client/objects.rb +14 -14
  45. data/lib/octokit/client/organizations.rb +256 -73
  46. data/lib/octokit/client/pages.rb +26 -3
  47. data/lib/octokit/client/projects.rb +294 -0
  48. data/lib/octokit/client/pull_requests.rb +74 -51
  49. data/lib/octokit/client/rate_limit.rb +11 -13
  50. data/lib/octokit/client/reactions.rb +204 -0
  51. data/lib/octokit/client/refs.rb +34 -20
  52. data/lib/octokit/client/releases.rb +16 -13
  53. data/lib/octokit/client/repositories.rb +276 -60
  54. data/lib/octokit/client/repository_invitations.rb +96 -0
  55. data/lib/octokit/client/reviews.rb +227 -0
  56. data/lib/octokit/client/say.rb +4 -5
  57. data/lib/octokit/client/search.rb +46 -17
  58. data/lib/octokit/client/service_status.rb +19 -9
  59. data/lib/octokit/client/source_import.rb +156 -0
  60. data/lib/octokit/client/stats.rb +39 -17
  61. data/lib/octokit/client/statuses.rb +6 -6
  62. data/lib/octokit/client/tokens.rb +31 -0
  63. data/lib/octokit/client/traffic.rb +64 -0
  64. data/lib/octokit/client/users.rb +133 -25
  65. data/lib/octokit/client.rb +85 -19
  66. data/lib/octokit/configurable.rb +60 -32
  67. data/lib/octokit/connection.rb +45 -21
  68. data/lib/octokit/default.rb +82 -35
  69. data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
  70. data/lib/octokit/enterprise_admin_client/license.rb +4 -5
  71. data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
  72. data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
  73. data/lib/octokit/enterprise_admin_client/users.rb +19 -18
  74. data/lib/octokit/enterprise_admin_client.rb +11 -3
  75. data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
  76. data/lib/octokit/enterprise_management_console_client.rb +9 -3
  77. data/lib/octokit/error.rb +144 -26
  78. data/lib/octokit/gist.rb +4 -5
  79. data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
  80. data/lib/octokit/manage_ghes_client.rb +64 -0
  81. data/lib/octokit/middleware/follow_redirects.rb +18 -14
  82. data/lib/octokit/organization.rb +3 -1
  83. data/lib/octokit/rate_limit.rb +11 -9
  84. data/lib/octokit/repo_arguments.rb +3 -4
  85. data/lib/octokit/repository.rb +35 -23
  86. data/lib/octokit/response/base_middleware.rb +10 -0
  87. data/lib/octokit/response/feed_parser.rb +5 -9
  88. data/lib/octokit/response/raise_error.rb +4 -6
  89. data/lib/octokit/user.rb +4 -2
  90. data/lib/octokit/version.rb +3 -1
  91. data/lib/octokit/warnable.rb +4 -5
  92. data/lib/octokit.rb +30 -8
  93. data/octokit.gemspec +12 -10
  94. metadata +47 -24
  95. data/lib/octokit/client/authorizations.rb +0 -256
  96. data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
  97. data/lib/octokit/preview.rb +0 -28
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Issues API
5
6
  #
6
7
  # @see https://developer.github.com/v3/issues/
7
8
  module Issues
8
-
9
9
  # List issues for the authenticated user or repository
10
10
  #
11
11
  # @param repository [Integer, String, Repository, Hash] A GitHub repository.
@@ -15,7 +15,7 @@ module Octokit
15
15
  # @option options [String] :assignee User login.
16
16
  # @option options [String] :creator User login.
17
17
  # @option options [String] :mentioned User login.
18
- # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
18
+ # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
19
19
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
20
20
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
21
21
  # @option options [Integer] :page (1) Page number.
@@ -28,10 +28,10 @@ module Octokit
28
28
  # @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
29
29
  # @client.list_issues
30
30
  def list_issues(repository = nil, options = {})
31
- path = repository ? "#{Repository.new(repository).path}/issues" : "issues"
31
+ path = repository ? "#{Repository.new(repository).path}/issues" : 'issues'
32
32
  paginate path, options
33
33
  end
34
- alias :issues :list_issues
34
+ alias issues list_issues
35
35
 
36
36
  # List all issues across owned and member repositories for the authenticated user
37
37
  #
@@ -81,6 +81,7 @@ module Octokit
81
81
  # @param body [String] An optional concise description
82
82
  # @param options [Hash] A customizable set of options.
83
83
  # @option options [String] :assignee User login.
84
+ # @option options [Array<String>] :assignees User login.
84
85
  # @option options [Integer] :milestone Milestone number.
85
86
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
86
87
  # @return [Sawyer::Resource] Your newly created issue
@@ -90,17 +91,17 @@ module Octokit
90
91
  def create_issue(repo, title, body = nil, options = {})
91
92
  options[:labels] = case options[:labels]
92
93
  when String
93
- options[:labels].split(",").map(&:strip)
94
+ options[:labels].split(',').map(&:strip)
94
95
  when Array
95
96
  options[:labels]
96
97
  else
97
98
  []
98
99
  end
99
- parameters = { :title => title }
100
+ parameters = { title: title }
100
101
  parameters[:body] = body unless body.nil?
101
102
  post "#{Repository.path repo}/issues", options.merge(parameters)
102
103
  end
103
- alias :open_issue :create_issue
104
+ alias open_issue create_issue
104
105
 
105
106
  # Get a single issue from a repository
106
107
  #
@@ -120,6 +121,7 @@ module Octokit
120
121
  # @param number [Integer] Number ID of the issue
121
122
  # @param options [Hash] A customizable set of options.
122
123
  # @option options [String] :assignee User login.
124
+ # @option options [Array<String>] :assignees User login.
123
125
  # @option options [Integer] :milestone Milestone number.
124
126
  # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
125
127
  # @return [Sawyer::Resource] The updated Issue
@@ -127,7 +129,7 @@ module Octokit
127
129
  # @example Close Issue #25 from octokit/octokit.rb
128
130
  # Octokit.close_issue("octokit/octokit.rb", "25")
129
131
  def close_issue(repo, number, options = {})
130
- patch "#{Repository.path repo}/issues/#{number}", options.merge({:state => "closed"})
132
+ patch "#{Repository.path repo}/issues/#{number}", options.merge({ state: 'closed' })
131
133
  end
132
134
 
133
135
  # Reopen an issue
@@ -136,6 +138,7 @@ module Octokit
136
138
  # @param number [Integer] Number ID of the issue
137
139
  # @param options [Hash] A customizable set of options.
138
140
  # @option options [String] :assignee User login.
141
+ # @option options [Array<String>] :assignees User login.
139
142
  # @option options [Integer] :milestone Milestone number.
140
143
  # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
141
144
  # @return [Sawyer::Resource] The updated Issue
@@ -143,7 +146,31 @@ module Octokit
143
146
  # @example Reopen Issue #25 from octokit/octokit.rb
144
147
  # Octokit.reopen_issue("octokit/octokit.rb", "25")
145
148
  def reopen_issue(repo, number, options = {})
146
- patch "#{Repository.path repo}/issues/#{number}", options.merge({:state => "open"})
149
+ patch "#{Repository.path repo}/issues/#{number}", options.merge({ state: 'open' })
150
+ end
151
+
152
+ # Lock an issue's conversation, limiting it to collaborators
153
+ #
154
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
155
+ # @param number [Integer] Number ID of the issue
156
+ # @return [Boolean] Success
157
+ # @see https://developer.github.com/v3/issues/#lock-an-issue
158
+ # @example Lock Issue #25 from octokit/octokit.rb
159
+ # Octokit.lock_issue("octokit/octokit.rb", "25")
160
+ def lock_issue(repo, number, options = {})
161
+ boolean_from_response :put, "#{Repository.path repo}/issues/#{number}/lock", options
162
+ end
163
+
164
+ # Unlock an issue's conversation, opening it to all viewers
165
+ #
166
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
167
+ # @param number [Integer] Number ID of the issue
168
+ # @return [Boolean] Success
169
+ # @see https://developer.github.com/v3/issues/#unlock-an-issue
170
+ # @example Unlock Issue #25 from octokit/octokit.rb
171
+ # Octokit.close_issue("octokit/octokit.rb", "25")
172
+ def unlock_issue(repo, number, options = {})
173
+ boolean_from_response :delete, "#{Repository.path repo}/issues/#{number}/lock", options
147
174
  end
148
175
 
149
176
  # Update an issue
@@ -155,6 +182,7 @@ module Octokit
155
182
  # @param body [String] Updated body of the issue
156
183
  # @param options [Hash] A customizable set of options.
157
184
  # @option options [String] :assignee User login.
185
+ # @option options [Array<String>] :assignees User login.
158
186
  # @option options [Integer] :milestone Milestone number.
159
187
  # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
160
188
  # @option options [String] :state State of the issue. <tt>open</tt> or <tt>closed</tt>
@@ -166,6 +194,7 @@ module Octokit
166
194
  # @option options [String] :title Updated title for the issue
167
195
  # @option options [String] :body Updated body of the issue
168
196
  # @option options [String] :assignee User login.
197
+ # @option options [Array<String>] :assignees User login.
169
198
  # @option options [Integer] :milestone Milestone number.
170
199
  # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
171
200
  # @option options [String] :state State of the issue. <tt>open</tt> or <tt>closed</tt>
@@ -181,7 +210,7 @@ module Octokit
181
210
  arguments = Arguments.new(args)
182
211
  opts = arguments.options
183
212
 
184
- if arguments.length > 0
213
+ unless arguments.empty?
185
214
  opts[:title] = arguments.shift
186
215
  opts[:body] = arguments.shift
187
216
  end
@@ -237,7 +266,7 @@ module Octokit
237
266
  # @return [Sawyer::Resource] The specific comment in question
238
267
  # @see https://developer.github.com/v3/issues/comments/#get-a-single-comment
239
268
  # @example Get comment #1194549 from an issue on octokit/octokit.rb
240
- # Octokit.issue_comments("octokit/octokit.rb", 1194549)
269
+ # Octokit.issue_comment("octokit/octokit.rb", 1194549)
241
270
  def issue_comment(repo, number, options = {})
242
271
  paginate "#{Repository.path repo}/issues/comments/#{number}", options
243
272
  end
@@ -252,7 +281,7 @@ module Octokit
252
281
  # @example Add the comment "Almost to v1" to Issue #23 on octokit/octokit.rb
253
282
  # Octokit.add_comment("octokit/octokit.rb", 23, "Almost to v1")
254
283
  def add_comment(repo, number, comment, options = {})
255
- post "#{Repository.path repo}/issues/#{number}/comments", options.merge({:body => comment})
284
+ post "#{Repository.path repo}/issues/#{number}/comments", options.merge({ body: comment })
256
285
  end
257
286
 
258
287
  # Update a single comment on an issue
@@ -265,7 +294,7 @@ module Octokit
265
294
  # @example Update the comment #1194549 with body "I've started this on my 25-issue-comments-v3 fork" on an issue on octokit/octokit.rb
266
295
  # Octokit.update_comment("octokit/octokit.rb", 1194549, "Almost to v1, added this on my fork")
267
296
  def update_comment(repo, number, comment, options = {})
268
- patch "#{Repository.path repo}/issues/comments/#{number}", options.merge({:body => comment})
297
+ patch "#{Repository.path repo}/issues/comments/#{number}", options.merge({ body: comment })
269
298
  end
270
299
 
271
300
  # Delete a single comment
@@ -279,6 +308,60 @@ module Octokit
279
308
  def delete_comment(repo, number, options = {})
280
309
  boolean_from_response :delete, "#{Repository.path repo}/issues/comments/#{number}", options
281
310
  end
311
+
312
+ # Get the timeline for an issue
313
+ #
314
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
315
+ # @param number [Integer] Number ID of the comment
316
+ # @return [Sawyer::Resource] The timeline for this issue
317
+ # @see https://developer.github.com/v3/issues/timeline/
318
+ # @example Get timeline for issue #1435 on octokit/octokit.rb
319
+ # Octokit.issue_timeline("octokit/octokit.rb", 1435)
320
+ def issue_timeline(repo, number, options = {})
321
+ paginate "#{Repository.path repo}/issues/#{number}/timeline", options
322
+ end
323
+
324
+ # Lists the available assignees for issues in a repository.
325
+ #
326
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
327
+ # @return [Array<Sawyer::Resource>] List of GitHub users.
328
+ # @see https://developer.github.com/v3/issues/assignees/#list-assignees
329
+ # @example Get available assignees on repository octokit/octokit.rb
330
+ # Octokit.list_assignees("octokit/octokit.rb")
331
+ def list_assignees(repo, options = {})
332
+ paginate "#{Repository.path repo}/assignees", options
333
+ end
334
+
335
+ # Add assignees to an issue
336
+ #
337
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
338
+ # @param number [Integer] Issue number
339
+ # @param assignees [Array<String>] Assignees to be added
340
+ # @return [Sawyer::Resource] Issue
341
+ # @see https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue
342
+ # @example Add assignees "pengwynn" and "joeyw" to Issue #23 on octokit/octokit.rb
343
+ # Octokit.add_assignees("octokit/octokit.rb", 23, ["pengwynn", "joeyw"])
344
+ def add_assignees(repo, number, assignees, options = {})
345
+ post "#{Repository.path repo}/issues/#{number}/assignees", options.merge({ assignees: assignees })
346
+ end
347
+
348
+ # Remove assignees from an issue
349
+ #
350
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
351
+ # @param number [Integer] Issue number
352
+ # @param assignees [Array<String>] Assignees to be removed
353
+ # @param options [Hash] Header params for request
354
+ # @return [Sawyer::Resource] Issue
355
+ # @see https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue
356
+ # @example Remove assignees "pengwynn" and "joeyw" from Issue #23 on octokit/octokit.rb
357
+ # Octokit.remove_assignees("octokit/octokit.rb", 23, ["pengwynn", "joeyw"])
358
+ #
359
+ # @example Remove assignees "pengwynn" from Issue #23 on octokit/octokit.rb
360
+ # Octokit.remove_assignees("octokit/octokit.rb", 23, ["pengwynn"],
361
+ # :accept => "application/vnd.github.v3+json")
362
+ def remove_assignees(repo, number, assignees, options = {})
363
+ delete "#{Repository.path repo}/issues/#{number}/assignees", options.merge({ assignees: assignees })
364
+ end
282
365
  end
283
366
  end
284
367
  end
@@ -1,13 +1,13 @@
1
- require 'cgi'
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
2
4
 
3
5
  module Octokit
4
6
  class Client
5
-
6
7
  # Methods for the Issue Labels API
7
8
  #
8
9
  # @see https://developer.github.com/v3/issues/labels/
9
10
  module Labels
10
-
11
11
  # List available labels for a repository
12
12
  #
13
13
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -26,9 +26,9 @@ module Octokit
26
26
  # @return [Sawyer::Resource] A single label from the repository
27
27
  # @see https://developer.github.com/v3/issues/labels/#get-a-single-label
28
28
  # @example Get the "V3 Addition" label from octokit/octokit.rb
29
- # Octokit.labels("octokit/octokit.rb", "V3 Addition")
29
+ # Octokit.label("octokit/octokit.rb", "V3 Addition")
30
30
  def label(repo, name, options = {})
31
- get "#{Repository.path repo}/labels/#{name}", options
31
+ get "#{Repository.path repo}/labels/#{ERB::Util.url_encode(name)}", options
32
32
  end
33
33
 
34
34
  # Add a label to a repository
@@ -40,8 +40,8 @@ module Octokit
40
40
  # @see https://developer.github.com/v3/issues/labels/#create-a-label
41
41
  # @example Add a new label "Version 1.0" with color "#cccccc"
42
42
  # Octokit.add_label("octokit/octokit.rb", "Version 1.0", "cccccc")
43
- def add_label(repo, label, color="ffffff", options = {})
44
- post "#{Repository.path repo}/labels", options.merge({:name => label, :color => color})
43
+ def add_label(repo, label, color = 'ffffff', options = {})
44
+ post "#{Repository.path repo}/labels", options.merge({ name: label, color: color })
45
45
  end
46
46
 
47
47
  # Update a label
@@ -56,7 +56,7 @@ module Octokit
56
56
  # @example Update the label "Version 1.0" with new color "#cceeaa"
57
57
  # Octokit.update_label("octokit/octokit.rb", "Version 1.0", {:color => "cceeaa"})
58
58
  def update_label(repo, label, options = {})
59
- patch "#{Repository.path repo}/labels/#{label}", options
59
+ patch "#{Repository.path repo}/labels/#{ERB::Util.url_encode(label)}", options
60
60
  end
61
61
 
62
62
  # Delete a label from a repository.
@@ -70,7 +70,7 @@ module Octokit
70
70
  # @example Delete the label "Version 1.0" from the repository.
71
71
  # Octokit.delete_label!("octokit/octokit.rb", "Version 1.0")
72
72
  def delete_label!(repo, label, options = {})
73
- boolean_from_response :delete, "#{Repository.path repo}/labels/#{label}", options
73
+ boolean_from_response :delete, "#{Repository.path repo}/labels/#{ERB::Util.url_encode(label)}", options
74
74
  end
75
75
 
76
76
  # Remove a label from an Issue
@@ -78,14 +78,14 @@ module Octokit
78
78
  # This removes the label from the Issue
79
79
  #
80
80
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
81
- # @param number [Fixnum] Number ID of the issue
81
+ # @param number [Integer] Number ID of the issue
82
82
  # @param label [String] String name of the label
83
83
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
84
84
  # @see https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue
85
85
  # @example Remove the label "Version 1.0" from the repository.
86
86
  # Octokit.remove_label("octokit/octokit.rb", 23, "Version 1.0")
87
87
  def remove_label(repo, number, label, options = {})
88
- delete "#{Repository.path repo}/issues/#{number}/labels/#{label}", options
88
+ delete "#{Repository.path repo}/issues/#{number}/labels/#{ERB::Util.url_encode(label)}", options
89
89
  end
90
90
 
91
91
  # Remove all label from an Issue
@@ -93,7 +93,7 @@ module Octokit
93
93
  # This removes the label from the Issue
94
94
  #
95
95
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
96
- # @param number [Fixnum] Number ID of the issue
96
+ # @param number [Integer] Number ID of the issue
97
97
  # @return [Boolean] Success of operation
98
98
  # @see https://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue
99
99
  # @example Remove all labels from Issue #23
@@ -105,7 +105,7 @@ module Octokit
105
105
  # List labels for a given issue
106
106
  #
107
107
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
108
- # @param number [Fixnum] Number ID of the issue
108
+ # @param number [Integer] Number ID of the issue
109
109
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
110
110
  # @see https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
111
111
  # @example List labels for octokit/octokit.rb, issue # 1
@@ -117,7 +117,7 @@ module Octokit
117
117
  # Add label(s) to an Issue
118
118
  #
119
119
  # @param repo [Integer, String, Repository, Hash] A Github repository
120
- # @param number [Fixnum] Number ID of the issue
120
+ # @param number [Integer] Number ID of the issue
121
121
  # @param labels [Array] An array of labels to apply to this Issue
122
122
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
123
123
  # @see https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue
@@ -130,20 +130,20 @@ module Octokit
130
130
  # Replace all labels on an Issue
131
131
  #
132
132
  # @param repo [Integer, String, Repository, Hash] A Github repository
133
- # @param number [Fixnum] Number ID of the issue
133
+ # @param number [Integer] Number ID of the issue
134
134
  # @param labels [Array] An array of labels to use as replacement
135
135
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
136
136
  # @see https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue
137
137
  # @example Replace labels for octokit/octokit.rb Issue #10
138
138
  # Octokit.replace_all_labels("octokit/octokit.rb", 10, ['V3 Transition', 'Improvement'])
139
- def replace_all_labels(repo, number, labels, options = {})
139
+ def replace_all_labels(repo, number, labels, _options = {})
140
140
  put "#{Repository.path repo}/issues/#{number}/labels", labels
141
141
  end
142
142
 
143
143
  # Get labels for every issue in a milestone
144
144
  #
145
145
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
146
- # @param number [Fixnum] Number ID of the milestone
146
+ # @param number [Integer] Number ID of the milestone
147
147
  # @return [Array<Sawyer::Resource>] A list of the labels across the milestone
148
148
  # @see http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
149
149
  # @example List all labels for milestone #2 on octokit/octokit.rb
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Legacy Search API
5
6
  #
6
7
  # @see https://developer.github.com/v3/search/
7
8
  module LegacySearch
8
-
9
9
  # Legacy repository search
10
10
  #
11
11
  # @see https://developer.github.com/v3/search/#search-repositories
@@ -23,7 +23,7 @@ module Octokit
23
23
  # @return [Array<Sawyer::Resource>] A list of issues matching the search term and state
24
24
  # @example Search for 'test' in the open issues for sferik/rails_admin
25
25
  # Octokit.search_issues("sferik/rails_admin", 'test', 'open')
26
- def legacy_search_issues(repo, search_term, state='open', options = {})
26
+ def legacy_search_issues(repo, search_term, state = 'open', options = {})
27
27
  get("legacy/issues/search/#{Repository.new(repo)}/#{state}/#{search_term}", options)['issues']
28
28
  end
29
29
 
@@ -1,10 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for licenses API
5
6
  #
6
7
  module Licenses
7
-
8
8
  # List all licenses
9
9
  #
10
10
  # @see https://developer.github.com/v3/licenses/#list-all-licenses
@@ -12,8 +12,7 @@ module Octokit
12
12
  # @example
13
13
  # Octokit.licenses
14
14
  def licenses(options = {})
15
- options = ensure_api_media_type(:licenses, options)
16
- paginate "licenses", options
15
+ paginate 'licenses', options
17
16
  end
18
17
 
19
18
  # List an individual license
@@ -24,20 +23,18 @@ module Octokit
24
23
  # @example
25
24
  # Octokit.license 'mit'
26
25
  def license(license_name, options = {})
27
- options = ensure_api_media_type(:licenses, options)
28
26
  get "licenses/#{license_name}", options
29
27
  end
30
28
 
31
29
  # Returns the contents of the repository’s license file, if one is detected.
32
30
  #
33
- # @see https://developer.github.com/v3/licenses/#get-a-repositorys-license
31
+ # @see https://developer.github.com/v3/licenses/#get-the-contents-of-a-repositorys-license
34
32
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
35
33
  # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to 'master'.
36
34
  # @return [Sawyer::Resource] The detail of the license file
37
35
  # @example
38
- # Octokit.license_contents 'benbalter/licensee'
36
+ # Octokit.repository_license_contents 'benbalter/licensee'
39
37
  def repository_license_contents(repo, options = {})
40
- options = ensure_api_media_type(:licenses, options)
41
38
  get "#{Repository.path repo}/license", options
42
39
  end
43
40
  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 Markdown API
5
6
  #
6
7
  # @see https://developer.github.com/v3/markdown/
7
8
  module Markdown
8
-
9
9
  # Render an arbitrary Markdown document
10
10
  #
11
11
  # @param text [String] Markdown source
@@ -20,7 +20,7 @@ module Octokit
20
20
  options[:repo] = Repository.new(options[:repo]) if options[:repo]
21
21
  options[:accept] = 'application/vnd.github.raw'
22
22
 
23
- post "markdown", options
23
+ post 'markdown', options
24
24
  end
25
25
  end
26
26
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+ # Methods for the Marketplace Listing API
6
+ #
7
+ # @see https://developer.github.com/v3/apps/marketplace/
8
+ module Marketplace
9
+ # List all plans for an app's marketplace listing
10
+ #
11
+ # @param options [Hash] A customizable set of options
12
+ #
13
+ # @see https://developer.github.com/v3/apps/marketplace/#list-all-plans-for-your-marketplace-listing
14
+ #
15
+ # @return [Array<Sawyer::Resource>] A list of plans
16
+ def list_plans(options = {})
17
+ paginate '/marketplace_listing/plans', options
18
+ end
19
+
20
+ # List all GitHub accounts on a specific plan
21
+ #
22
+ # @param plan_id [Integer] The id of the GitHub plan
23
+ # @param options [Hash] A customizable set of options
24
+ #
25
+ # @see https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan
26
+ #
27
+ # @return [Array<Sawyer::Resource>] A list of accounts
28
+ def list_accounts_for_plan(plan_id, options = {})
29
+ paginate "/marketplace_listing/plans/#{plan_id}/accounts", options
30
+ end
31
+
32
+ # Get the plan associated with a given GitHub account
33
+ #
34
+ # @param account_id [Integer] The id of the GitHub account
35
+ # @param options [Hash] A customizable set of options
36
+ #
37
+ # @see https://developer.github.com/v3/apps/marketplace/#check-if-a-github-account-is-associated-with-any-marketplace-listing
38
+ #
39
+ # @return <Sawyer::Resource> Account with plan details, or nil
40
+ def plan_for_account(account_id, options = {})
41
+ get "/marketplace_listing/accounts/#{account_id}", options
42
+ end
43
+
44
+ # Get user's Marketplace purchases
45
+ #
46
+ # @param options [Hash] A customizable set of options
47
+ #
48
+ # @see https://developer.github.com/v3/apps/marketplace/#get-a-users-marketplace-purchases
49
+ #
50
+ # @return [Array<Sawyer::Resource>] A list of Marketplace purchases
51
+ def marketplace_purchases(options = {})
52
+ get '/user/marketplace_purchases', options
53
+ end
54
+ end
55
+ end
56
+ end
@@ -1,21 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Meta API
5
6
  #
6
7
  # @see https://developer.github.com/v3/meta/
7
8
  module Meta
8
-
9
9
  # Get meta information about GitHub.com, the service.
10
10
  # @see https://developer.github.com/v3/meta/#meta
11
11
  # @return [Sawyer::Resource] Hash with meta information.
12
12
  # @example Get GitHub meta information
13
13
  # @client.github_meta
14
14
  def meta(options = {})
15
- get "meta", options
15
+ get 'meta', options
16
16
  end
17
- alias :github_meta :meta
18
-
17
+ alias github_meta meta
19
18
  end
20
19
  end
21
20
  end
@@ -1,14 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Issues Milestones API
5
6
  #
6
7
  # @see https://developer.github.com/v3/issues/milestones/
7
8
  module Milestones
8
-
9
9
  # List milestones for a repository
10
10
  #
11
- # @param repository [String, Repository, Hash] A GitHub repository.
11
+ # @param repository [Integer, String, Repository, Hash] A GitHub repository
12
12
  # @param options [Hash] A customizable set of options.
13
13
  # @option options [Integer] :milestone Milestone number.
14
14
  # @option options [String] :state (open) State: <tt>open</tt>, <tt>closed</tt>, or <tt>all</tt>.
@@ -19,13 +19,13 @@ module Octokit
19
19
  # @example List milestones for a repository
20
20
  # Octokit.list_milestones("octokit/octokit.rb")
21
21
  def list_milestones(repository, options = {})
22
- paginate "repos/#{Repository.new(repository)}/milestones", options
22
+ paginate "#{Repository.path repository}/milestones", options
23
23
  end
24
- alias :milestones :list_milestones
24
+ alias milestones list_milestones
25
25
 
26
26
  # Get a single milestone for a repository
27
27
  #
28
- # @param repository [String, Repository, Hash] A GitHub repository.
28
+ # @param repository [Integer, String, Repository, Hash] A GitHub repository
29
29
  # @param options [Hash] A customizable set of options.
30
30
  # @option options [Integer] :milestone Milestone number.
31
31
  # @return [Sawyer::Resource] A single milestone from a repository.
@@ -33,12 +33,12 @@ module Octokit
33
33
  # @example Get a single milestone for a repository
34
34
  # Octokit.milestone("octokit/octokit.rb", 1)
35
35
  def milestone(repository, number, options = {})
36
- get "repos/#{Repository.new(repository)}/milestones/#{number}", options
36
+ get "#{Repository.path repository}/milestones/#{number}", options
37
37
  end
38
38
 
39
39
  # Create a milestone for a repository
40
40
  #
41
- # @param repository [String, Repository, Hash] A GitHub repository.
41
+ # @param repository [Integer, String, Repository, Hash] A GitHub repository
42
42
  # @param title [String] A unique title.
43
43
  # @param options [Hash] A customizable set of options.
44
44
  # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
@@ -49,12 +49,12 @@ module Octokit
49
49
  # @example Create a milestone for a repository
50
50
  # Octokit.create_milestone("octokit/octokit.rb", "0.7.0", {:description => 'Add support for v3 of Github API'})
51
51
  def create_milestone(repository, title, options = {})
52
- post "repos/#{Repository.new(repository)}/milestones", options.merge({:title => title})
52
+ post "#{Repository.path repository}/milestones", options.merge({ title: title })
53
53
  end
54
54
 
55
55
  # Update a milestone for a repository
56
56
  #
57
- # @param repository [String, Repository, Hash] A GitHub repository.
57
+ # @param repository [Integer, String, Repository, Hash] A GitHub repository
58
58
  # @param number [String, Integer] ID of the milestone
59
59
  # @param options [Hash] A customizable set of options.
60
60
  # @option options [String] :title A unique title.
@@ -66,13 +66,13 @@ module Octokit
66
66
  # @example Update a milestone for a repository
67
67
  # Octokit.update_milestone("octokit/octokit.rb", 1, {:description => 'Add support for v3 of Github API'})
68
68
  def update_milestone(repository, number, options = {})
69
- patch "repos/#{Repository.new(repository)}/milestones/#{number}", options
69
+ patch "#{Repository.path repository}/milestones/#{number}", options
70
70
  end
71
- alias :edit_milestone :update_milestone
71
+ alias edit_milestone update_milestone
72
72
 
73
73
  # Delete a single milestone for a repository
74
74
  #
75
- # @param repository [String, Repository, Hash] A GitHub repository.
75
+ # @param repository [Integer, String, Repository, Hash] A GitHub repository
76
76
  # @param options [Hash] A customizable set of options.
77
77
  # @option options [Integer] :milestone Milestone number.
78
78
  # @return [Boolean] Success
@@ -80,7 +80,7 @@ module Octokit
80
80
  # @example Delete a single milestone from a repository
81
81
  # Octokit.delete_milestone("octokit/octokit.rb", 1)
82
82
  def delete_milestone(repository, number, options = {})
83
- boolean_from_response :delete, "repos/#{Repository.new(repository)}/milestones/#{number}", options
83
+ boolean_from_response :delete, "#{Repository.path repository}/milestones/#{number}", options
84
84
  end
85
85
  end
86
86
  end