octokit 4.8.0 → 4.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f3b264edbac32970be83bf7b14081732f130d12
4
- data.tar.gz: 15af8a2c6a80cfe94fdd14bb56a68dfbc772cb45
3
+ metadata.gz: 6b938b8240c566e33d75ff8a0d65c797f652e0ec
4
+ data.tar.gz: 9b9dc7920741ba14a93c6dd9be7cf26b750453bf
5
5
  SHA512:
6
- metadata.gz: 7a77fc4d18fbc0dac671774e2486ba93aee5a434490db33579afa768a0386fbf12fcc251ff19fa514fa4f0bf564c643538b6b6a33360311bd05d789bfa6914e0
7
- data.tar.gz: 134a0f49e4ade9f5b0ffc377b9394d4597c6fe69a871d27b2c90912024b4cd52ab1efc7de6019fcf3140fb756a2a9023f1fa742443227f63888113217ede8a16
6
+ metadata.gz: 0b72eef6e4954f798f45dfb49f990805b06411ac8f9cff2affe66738d6803f98d2e666d18248bb5742bbf1625aafd2cfd3989991642dc5af697569e19566df32
7
+ data.tar.gz: d026883962480255da7515279a57423b5c43e38b2743553727ec132e10dc1156d53688a6634f99d820cebc858d221b07f8cf8940a4eacc6017c3d45b04d968c4
@@ -222,6 +222,7 @@ module Octokit
222
222
  conn_opts[:url] = @api_endpoint
223
223
  conn_opts[:builder] = @middleware.dup if @middleware
224
224
  conn_opts[:proxy] = @proxy if @proxy
225
+ conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode
225
226
  conn = Faraday.new(conn_opts) do |http|
226
227
  if basic_authenticated?
227
228
  http.basic_auth(@login, @password)
@@ -10,7 +10,7 @@ module Octokit
10
10
  #
11
11
  # @see https://developer.github.com/v3/apps/#find-installations
12
12
  #
13
- # @return [Array<Sawyer::Resource>] A list of installations
13
+ # @return [Array<Sawyer::Resource>] the total_count and an array of installations
14
14
  def find_app_installations(options = {})
15
15
  opts = ensure_api_media_type(:integrations, options)
16
16
  paginate "app/installations", opts
@@ -33,10 +33,12 @@ module Octokit
33
33
  #
34
34
  # @see https://developer.github.com/v3/apps/#list-installations-for-user
35
35
  #
36
- # @return [Array<Sawyer::Resource>] A list of installations
36
+ # @return [Sawyer::Resource] the total_count and an array of installations
37
37
  def find_user_installations(options = {})
38
38
  opts = ensure_api_media_type(:integrations, options)
39
- paginate "user/installations", opts
39
+ paginate("user/installations", opts) do |data, last_response|
40
+ data.installations.concat last_response.data.installations
41
+ end
40
42
  end
41
43
 
42
44
  # Get a single installation
@@ -80,10 +82,12 @@ module Octokit
80
82
  # @param options [Hash] A customizable set of options
81
83
  # @see https://developer.github.com/v3/apps/installations/#list-repositories
82
84
  #
83
- # @return [Array<Sawyer::Resource>] A list of repositories
85
+ # @return [Sawyer::Resource] the total_count and an array of repositories
84
86
  def list_app_installation_repositories(options = {})
85
87
  opts = ensure_api_media_type(:integrations, options)
86
- paginate "installation/repositories", opts
88
+ paginate("installation/repositories", opts) do |data, last_response|
89
+ data.repositories.concat last_response.data.repositories
90
+ end
87
91
  end
88
92
  alias list_installation_repos list_app_installation_repositories
89
93
 
@@ -154,10 +158,12 @@ module Octokit
154
158
  #
155
159
  # @see https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/identifying-users-for-github-apps/
156
160
  #
157
- # @return [Array<Sawyer::Resource>] A list of repositories
161
+ # @return [Sawyer::Resource] the total_count and an array of repositories
158
162
  def find_installation_repositories_for_user(installation, options = {})
159
163
  opts = ensure_api_media_type(:integrations, options)
160
- paginate "user/installations/#{installation}/repositories", opts
164
+ paginate("user/installations/#{installation}/repositories", opts) do |data, last_response|
165
+ data.repositories.concat last_response.data.repositories
166
+ end
161
167
  end
162
168
  end
163
169
  end
@@ -61,7 +61,7 @@ module Octokit
61
61
  def create_authorization(options = {})
62
62
  # Techincally we can omit scopes as GitHub has a default, however the
63
63
  # API will reject us if we send a POST request with an empty body.
64
-
64
+ options = options.dup
65
65
  if options.delete :idempotent
66
66
  client_id, client_secret = fetch_client_id_and_secret(options)
67
67
  raise ArgumentError.new("Client ID and Secret required for idempotent authorizations") unless client_id && client_secret
@@ -122,6 +122,7 @@ module Octokit
122
122
  # @return [Array<String>] OAuth scopes
123
123
  # @see https://developer.github.com/v3/oauth/#scopes
124
124
  def scopes(token = @access_token, options = {})
125
+ options= options.dup
125
126
  raise ArgumentError.new("Access token required") if token.nil?
126
127
 
127
128
  auth = { "Authorization" => "token #{token}" }
@@ -226,6 +227,7 @@ module Octokit
226
227
  # @example
227
228
  # @client.authorize_url('xxxx')
228
229
  def authorize_url(app_id = client_id, options = {})
230
+ opts = options.dup
229
231
  if app_id.to_s.empty?
230
232
  raise Octokit::ApplicationCredentialsRequired.new "client_id required"
231
233
  end
@@ -30,6 +30,7 @@ module Octokit
30
30
  # @example List the contents of lib/octokit.rb
31
31
  # Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb')
32
32
  def contents(repo, options={})
33
+ options = options.dup
33
34
  repo_path = options.delete :path
34
35
  url = "#{Repository.path repo}/contents/#{repo_path}"
35
36
  get url, options
@@ -54,6 +55,7 @@ module Octokit
54
55
  # "File content",
55
56
  # :branch => "my-new-feature")
56
57
  def create_contents(*args)
58
+ args = args.map { |item| item && item.dup }
57
59
  options = args.last.is_a?(Hash) ? args.pop : {}
58
60
  repo = args.shift
59
61
  path = args.shift
@@ -6,6 +6,16 @@ module Octokit
6
6
  # @see https://developer.github.com/v3/repos/commits/deployments/
7
7
  module Deployments
8
8
 
9
+ # Fetch a single deployment for a repository
10
+ #
11
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
12
+ # @param deployment_id [Integer, String, Repository, Hash] A GitHub repository
13
+ # @return <Sawyer::Resource> A single deployment
14
+ # @see https://developer.github.com/v3/repos/deployments/#get-a-single-deployment
15
+ def deployment(repo, deployment_id, options = {})
16
+ get("#{Repository.path repo}/deployments/#{deployment_id}", options)
17
+ end
18
+
9
19
  # List all deployments for a repository
10
20
  #
11
21
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -50,6 +50,7 @@ module Octokit
50
50
  # @see https://developer.github.com/v3/gists/#get-a-single-gist
51
51
  # @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
52
52
  def gist(gist, options = {})
53
+ options = options.dup
53
54
  if sha = options.delete(:sha)
54
55
  get "gists/#{Gist.new(gist)}/#{sha}", options
55
56
  else
@@ -261,7 +261,7 @@ module Octokit
261
261
  # @return [Sawyer::Resource] The specific comment in question
262
262
  # @see https://developer.github.com/v3/issues/comments/#get-a-single-comment
263
263
  # @example Get comment #1194549 from an issue on octokit/octokit.rb
264
- # Octokit.issue_comments("octokit/octokit.rb", 1194549)
264
+ # Octokit.issue_comment("octokit/octokit.rb", 1194549)
265
265
  def issue_comment(repo, number, options = {})
266
266
  paginate "#{Repository.path repo}/issues/comments/#{number}", options
267
267
  end
@@ -329,6 +329,23 @@ module Octokit
329
329
  def add_assignees(repo, number, assignees, options = {})
330
330
  post "#{Repository.path repo}/issues/#{number}/assignees", options.merge({:assignees => assignees})
331
331
  end
332
+
333
+ # Remove assignees from an issue
334
+ #
335
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
336
+ # @param number [Integer] Issue number
337
+ # @param assignees [Array] Assignees to be removed
338
+ # @return [Sawyer::Resource] Issue
339
+ # @see https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue
340
+ # @example Remove assignees "pengwynn" and "joeyw" from Issue #23 on octokit/octokit.rb
341
+ # Octokit.remove_assignees("octokit/octokit.rb", 23, ["pengwynn", "joeyw"])
342
+ #
343
+ # @example Remove assignees "pengwynn" from Issue #23 on octokit/octokit.rb
344
+ # Octokit.remove_assignees("octokit/octokit.rb", 23, ["pengwynn"],
345
+ # :accept => "application/vnd.github.v3+json")
346
+ def remove_assignees(repo, number, assignees, options = {})
347
+ delete "#{Repository.path repo}/issues/#{number}/assignees", options.merge({:assignees => assignees})
348
+ end
332
349
  end
333
350
  end
334
351
  end
@@ -26,7 +26,7 @@ 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
31
  get "#{Repository.path repo}/labels/#{name}", options
32
32
  end
@@ -142,6 +142,7 @@ module Octokit
142
142
  # @example
143
143
  # Octokit.org_members('github')
144
144
  def organization_members(org, options = {})
145
+ options = options.dup
145
146
  path = "public_" if options.delete(:public)
146
147
  paginate "#{Organization.path org}/#{path}members", options
147
148
  end
@@ -664,6 +665,7 @@ module Octokit
664
665
  # @see https://developer.github.com/v3/orgs/members/#get-your-organization-membership
665
666
  # @see https://developer.github.com/v3/orgs/members/#get-organization-membership
666
667
  def organization_membership(org, options = {})
668
+ options = options.dup
667
669
  if user = options.delete(:user)
668
670
  get "#{Organization.path(org)}/memberships/#{user}", options
669
671
  else
@@ -682,6 +684,7 @@ module Octokit
682
684
  # @see https://developer.github.com/v3/orgs/members/#edit-your-organization-membership
683
685
  # @see https://developer.github.com/v3/orgs/members/#add-or-update-organization-membership
684
686
  def update_organization_membership(org, options = {})
687
+ options = options.dup
685
688
  if user = options.delete(:user)
686
689
  put "orgs/#{org}/memberships/#{user}", options
687
690
  else
@@ -696,9 +699,11 @@ module Octokit
696
699
  # @return [Boolean] Success
697
700
  # @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
698
701
  def remove_organization_membership(org, options = {})
702
+ options = options.dup
699
703
  user = options.delete(:user)
700
704
  user && boolean_from_response(:delete, "orgs/#{org}/memberships/#{user}", options)
701
705
  end
706
+ alias :remove_org_membership :remove_organization_membership
702
707
 
703
708
  # Initiates the generation of a migration archive.
704
709
  #
@@ -151,8 +151,8 @@ module Octokit
151
151
  #
152
152
  # @example Get review comments, sort by updated asc since a time
153
153
  # @client.pull_requests_comments("octokit/octokit.rb", {
154
- # :sort => 'asc',
155
- # :direction => 'down',
154
+ # :sort => 'updated',
155
+ # :direction => 'asc',
156
156
  # :since => '2010-05-04T23:45:02Z'
157
157
  # })
158
158
  def pull_requests_comments(repo, options = {})
@@ -44,6 +44,7 @@ module Octokit
44
44
  # Update a release
45
45
  #
46
46
  # @param url [String] URL for the release as returned from .releases
47
+ # @option options [String] :tag_name Git tag from which to create release
47
48
  # @option options [String] :target_commitish Specifies the commitish value that determines where the Git tag is created from.
48
49
  # @option options [String] :name Name for the release
49
50
  # @option options [String] :body Content for release notes
@@ -3,7 +3,7 @@ module Octokit
3
3
 
4
4
  # Methods for the Reviews API
5
5
  #
6
- # @see https://developer.github.com/v3/reviews/
6
+ # @see https://developer.github.com/v3/pulls/reviews/
7
7
  module Reviews
8
8
 
9
9
  # List reviews on a pull request
@@ -123,7 +123,7 @@ module Octokit
123
123
  # @see https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review
124
124
  #
125
125
  # @example
126
- # @client.dismiss_pull_request_review('octokit/octokit.rb', 825, 6505518)
126
+ # @client.dismiss_pull_request_review('octokit/octokit.rb', 825, 6505518, 'The message.')
127
127
  #
128
128
  # @return [Sawyer::Resource] Hash representing the dismissed review
129
129
  def dismiss_pull_request_review(repo, number, review, message, options = {})
@@ -20,6 +20,21 @@ module Octokit
20
20
  search "search/code", query, options
21
21
  end
22
22
 
23
+ # Search commits
24
+ #
25
+ # @param query [String] Search terms and qualifiers
26
+ # @param options [Hash] Sort and pagination options
27
+ # @option options [String] :sort Sort field
28
+ # @option options [String] :order Sort order (asc or desc)
29
+ # @option options [Integer] :page Page of paginated results
30
+ # @option options [Integer] :per_page Number of items per page
31
+ # @return [Sawyer::Resource] Search results object
32
+ # @see https://developer.github.com/v3/search/#search-commits
33
+ def search_commits(query, options = {})
34
+ options = ensure_api_media_type(:commit_search, options)
35
+ search "search/commits", query, options
36
+ end
37
+
23
38
  # Search issues
24
39
  #
25
40
  # @param query [String] Search term and qualifiers
@@ -88,6 +88,7 @@ module Octokit
88
88
  # @return [Array<Sawyer::Resource> or nil] Stats in metric-specific format, or nil if not yet calculated.
89
89
  # @see https://developer.github.com/v3/repos/statistics/
90
90
  def get_stats(repo, metric, options = {})
91
+ options = options.dup
91
92
  if retry_timeout = options.delete(:retry_timeout)
92
93
  retry_wait = options.delete(:retry_wait) || 0.5
93
94
  timeout = Time.now + retry_timeout
@@ -45,6 +45,9 @@ module Octokit
45
45
  # @!attribute proxy
46
46
  # @see https://github.com/lostisland/faraday
47
47
  # @return [String] URI for proxy server
48
+ # @!attribute ssl_verify_mode
49
+ # @see https://github.com/lostisland/faraday
50
+ # @return [String] SSL verify mode for ssl connections
48
51
  # @!attribute user_agent
49
52
  # @return [String] Configure User-Agent header for requests.
50
53
  # @!attribute web_endpoint
@@ -53,7 +56,7 @@ module Octokit
53
56
  attr_accessor :access_token, :auto_paginate, :bearer_token, :client_id,
54
57
  :client_secret, :default_media_type, :connection_options,
55
58
  :middleware, :netrc, :netrc_file,
56
- :per_page, :proxy, :user_agent
59
+ :per_page, :proxy, :ssl_verify_mode, :user_agent
57
60
  attr_writer :password, :web_endpoint, :api_endpoint, :login,
58
61
  :management_console_endpoint, :management_console_password
59
62
 
@@ -80,6 +83,7 @@ module Octokit
80
83
  :per_page,
81
84
  :password,
82
85
  :proxy,
86
+ :ssl_verify_mode,
83
87
  :user_agent,
84
88
  :web_endpoint
85
89
  ]
@@ -153,7 +153,7 @@ module Octokit
153
153
  end
154
154
  end
155
155
 
156
- @last_response = response = agent.call(method, URI::Parser.new.escape(path.to_s), data, options)
156
+ @last_response = response = agent.call(method, Addressable::URI.parse(path.to_s).normalize.to_s, data, options)
157
157
  response.data
158
158
  end
159
159
 
@@ -175,6 +175,7 @@ module Octokit
175
175
  conn_opts = @connection_options
176
176
  conn_opts[:builder] = @middleware if @middleware
177
177
  conn_opts[:proxy] = @proxy if @proxy
178
+ conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode
178
179
  opts[:faraday] = Faraday.new(conn_opts)
179
180
 
180
181
  opts
@@ -137,6 +137,15 @@ module Octokit
137
137
  ENV['OCTOKIT_PROXY']
138
138
  end
139
139
 
140
+ # Default SSL verify mode from ENV
141
+ # @return [Integer]
142
+ def ssl_verify_mode
143
+ # 0 is OpenSSL::SSL::VERIFY_NONE
144
+ # 1 is OpenSSL::SSL::SSL_VERIFY_PEER
145
+ # the standard default for SSL is SSL_VERIFY_PEER which requires a server certificate check on the client
146
+ ENV['OCTOKIT_SSL_VERIFY_MODE'] || 1
147
+ end
148
+
140
149
  # Default User-Agent header string from ENV or {USER_AGENT}
141
150
  # @return [String]
142
151
  def user_agent
@@ -5,6 +5,7 @@ module Octokit
5
5
 
6
6
  PREVIEW_TYPES = {
7
7
  :branch_protection => 'application/vnd.github.loki-preview+json'.freeze,
8
+ :commit_search => 'application/vnd.github.cloak-preview+json'.freeze,
8
9
  :migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
9
10
  :licenses => 'application/vnd.github.drax-preview+json'.freeze,
10
11
  :source_imports => 'application/vnd.github.barred-rock-preview'.freeze,
@@ -5,7 +5,7 @@ module Octokit
5
5
 
6
6
  # Current minor release.
7
7
  # @return [Integer]
8
- MINOR = 8
8
+ MINOR = 9
9
9
 
10
10
  # Current patch level.
11
11
  # @return [Integer]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.0
4
+ version: 4.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-12-20 00:00:00.000000000 Z
13
+ date: 2018-05-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: 1.3.5
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.5.2
156
+ rubygems_version: 2.5.2.2
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Ruby toolkit for working with the GitHub API