octokit 4.13.0 → 4.14.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
  SHA256:
3
- metadata.gz: 62cc9f95627d52ebe1950974e93a4ddf3a24709dd23d24f7124ef9f4befc7a94
4
- data.tar.gz: b0390bb087b9cfda51e942ee3958c9ea600750697e4f6b825aa0dd40947574b1
3
+ metadata.gz: da3e4a3c93344024b60cb7d3c5e13bc90742576c6e43dc3e438f3e16819cdc9f
4
+ data.tar.gz: 9a47ad957027e32a4f74ca93250476ae46627d961b6bd349cf62a632da04477f
5
5
  SHA512:
6
- metadata.gz: efd51d1fb7f93e55da8d616c90ec6840688873f9070f63816a3782d3900587e41b3f4f50e49450bc2b721d088042038dec16d66dbc93b3356191404919932ca4
7
- data.tar.gz: faa042b6c7afa1aa67eed9b0904e8319a178f0c79d4bc4be8467ce2fa5604a2c413d93ede232d739083085cdd94fcfa5d6b22854583b5807f0ed0978fc221d48
6
+ metadata.gz: 22921fbc5478cbdcbe17f033b7a63666dc69ff63b1b2fda1f47f37eb2967cd055539c1935a5a767d46e24ed427c2d64457c6057141f77caa3bfdf2ebcd6bd179
7
+ data.tar.gz: 1bc0add3fdff8b42dc752c3886f95ba51e8ffd234ff3f0091b7dc7a22dbfd8286b0df2d043646a859cdc0bb2837663b6259339c82a0602296dc9cb305b68ab4a
data/README.md CHANGED
@@ -30,6 +30,7 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
30
30
  10. [Configuration and defaults](#configuration-and-defaults)
31
31
  1. [Configuring module defaults](#configuring-module-defaults)
32
32
  2. [Using ENV variables](#using-env-variables)
33
+ 3. [Timeouts](#timeouts)
33
34
  11. [Hypermedia agent](#hypermedia-agent)
34
35
  1. [Hypermedia in Octokit](#hypermedia-in-octokit)
35
36
  2. [URI templates](#uri-templates)
@@ -427,6 +428,27 @@ Deprecation warnings and API endpoints in development preview warnings are
427
428
  printed to STDOUT by default, these can be disabled by setting the ENV
428
429
  `OCTOKIT_SILENT=true`.
429
430
 
431
+ ### Timeouts
432
+
433
+ By default, Octokit does not timeout network requests. To set a timeout, pass in Faraday timeout settings to Octokit's `connection_options` setting.
434
+
435
+ ```ruby
436
+ Octokit.configure do |c|
437
+ c.api_endpoint = ENV.fetch('GITHUB_API_ENDPOINT', 'https://api.github.com/')
438
+ c.connection_options = {
439
+ request: {
440
+ open_timeout: 5,
441
+ timeout: 5
442
+ }
443
+ }
444
+ end
445
+ ```
446
+ You should set a timeout in order to avoid Ruby’s Timeout module, which can hose your server. Here are some resources for more information on this:
447
+
448
+ - [The Oldest Bug In Ruby - Why Rack::Timeout Might Hose your Server](https://www.schneems.com/2017/02/21/the-oldest-bug-in-ruby-why-racktimeout-might-hose-your-server/)
449
+ - [Timeout: Ruby's Most Dangerous API](https://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/)
450
+ - [The Ultimate Guide to Ruby Timeouts](https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts)
451
+
430
452
  ## Hypermedia agent
431
453
 
432
454
  Starting in version 2.0, Octokit is [hypermedia][]-enabled. Under the hood,
@@ -693,6 +715,7 @@ implementations:
693
715
  * Ruby 2.3
694
716
  * Ruby 2.4
695
717
  * Ruby 2.5
718
+ * Ruby 2.6
696
719
 
697
720
  If something doesn't work on one of these Ruby versions, it's a bug.
698
721
 
@@ -12,6 +12,7 @@ require 'octokit/organization'
12
12
  require 'octokit/preview'
13
13
  require 'octokit/client/apps'
14
14
  require 'octokit/client/authorizations'
15
+ require 'octokit/client/checks'
15
16
  require 'octokit/client/commits'
16
17
  require 'octokit/client/commit_comments'
17
18
  require 'octokit/client/community_profile'
@@ -69,6 +70,7 @@ module Octokit
69
70
  include Octokit::Preview
70
71
  include Octokit::Warnable
71
72
  include Octokit::Client::Authorizations
73
+ include Octokit::Client::Checks
72
74
  include Octokit::Client::Commits
73
75
  include Octokit::Client::CommitComments
74
76
  include Octokit::Client::CommunityProfile
@@ -119,7 +121,8 @@ module Octokit
119
121
  def initialize(options = {})
120
122
  # Use options passed in, but fall back to module defaults
121
123
  Octokit::Configurable.keys.each do |key|
122
- instance_variable_set(:"@#{key}", options[key] || Octokit.instance_variable_get(:"@#{key}"))
124
+ value = options.key?(key) ? options[key] : Octokit.instance_variable_get(:"@#{key}")
125
+ instance_variable_set(:"@#{key}", value)
123
126
  end
124
127
 
125
128
  login_from_netrc unless user_authenticated? || application_authenticated?
@@ -132,16 +135,12 @@ module Octokit
132
135
  inspected = super
133
136
 
134
137
  # mask password
135
- inspected = inspected.gsub! @password, "*******" if @password
136
- inspected = inspected.gsub! @management_console_password, "*******" if @management_console_password
137
- inspected = inspected.gsub! @bearer_token, '********' if @bearer_token
138
+ inspected.gsub! @password, '*******' if @password
139
+ inspected.gsub! @management_console_password, '*******' if @management_console_password
140
+ inspected.gsub! @bearer_token, '********' if @bearer_token
138
141
  # Only show last 4 of token, secret
139
- if @access_token
140
- inspected = inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}"
141
- end
142
- if @client_secret
143
- inspected = inspected.gsub! @client_secret, "#{'*'*36}#{@client_secret[36..-1]}"
144
- end
142
+ inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}" if @access_token
143
+ inspected.gsub! @client_secret, "#{'*'*36}#{@client_secret[36..-1]}" if @client_secret
145
144
 
146
145
  inspected
147
146
  end
@@ -0,0 +1,211 @@
1
+ module Octokit
2
+ class Client
3
+
4
+ # Methods for the Checks API
5
+ #
6
+ # @see https://developer.github.com/v3/checks/
7
+ module Checks
8
+
9
+ # Methods for Check Runs
10
+ #
11
+ # @see https://developer.github.com/v3/checks/runs/
12
+
13
+ # Create a check run
14
+ #
15
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
16
+ # @param name [String] The name of the check
17
+ # @param head_sha [String] The SHA of the commit to check
18
+ # @return [Sawyer::Resource] A hash representing the new check run
19
+ # @see https://developer.github.com/v3/checks/runs/#create-a-check-run
20
+ # @example Create a check run
21
+ # check_run = @client.create_check_run("octocat/Hello-World", "my-check", "7638417db6d59f3c431d3e1f261cc637155684cd")
22
+ # check_run.name # => "my-check"
23
+ # check_run.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
24
+ # check_run.status # => "queued"
25
+ def create_check_run(repo, name, head_sha, options = {})
26
+ ensure_api_media_type(:checks, options)
27
+ options[:name] = name
28
+ options[:head_sha] = head_sha
29
+
30
+ post "#{Repository.path repo}/check-runs", options
31
+ end
32
+
33
+ # Update a check run
34
+ #
35
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
36
+ # @param id [Integer] The ID of the check run
37
+ # @return [Sawyer::Resource] A hash representing the updated check run
38
+ # @see https://developer.github.com/v3/checks/runs/#update-a-check-run
39
+ # @example Update a check run
40
+ # check_run = @client.update_check_run("octocat/Hello-World", 51295429, status: "in_progress")
41
+ # check_run.id # => 51295429
42
+ # check_run.status # => "in_progress"
43
+ def update_check_run(repo, id, options = {})
44
+ ensure_api_media_type(:checks, options)
45
+
46
+ patch "#{Repository.path repo}/check-runs/#{id}", options
47
+ end
48
+
49
+ # List check runs for a specific ref
50
+ #
51
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
52
+ # @param ref [String] A SHA, branch name, or tag name
53
+ # @param options [Hash] A set of optional filters
54
+ # @option options [String] :check_name Returns check runs with the specified <tt>name</tt>
55
+ # @option options [String] :status Returns check runs with the specified <tt>status</tt>
56
+ # @option options [String] :filter Filters check runs by their <tt>completed_at</tt> timestamp
57
+ # @return [Sawyer::Resource] A hash representing a collection of check runs
58
+ # @see https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref
59
+ # @example List check runs for a specific ref
60
+ # result = @client.check_runs_for_ref("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd", status: "in_progress")
61
+ # result.total_count # => 1
62
+ # result.check_runs.count # => 1
63
+ # result.check_runs[0].id # => 51295429
64
+ # result.check_runs[0].status # => "in_progress"
65
+ def check_runs_for_ref(repo, ref, options = {})
66
+ ensure_api_media_type(:checks, options)
67
+
68
+ get "#{Repository.path repo}/commits/#{ref}/check-runs", options
69
+ end
70
+ alias :list_check_runs_for_ref :check_runs_for_ref
71
+
72
+ # List check runs in a check suite
73
+ #
74
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
75
+ # @param id [Integer] The ID of the check suite
76
+ # @param options [Hash] A set of optional filters
77
+ # @option options [String] :check_name Returns check runs with the specified <tt>name</tt>
78
+ # @option options [String] :status Returns check runs with the specified <tt>status</tt>
79
+ # @option options [String] :filter Filters check runs by their <tt>completed_at</tt> timestamp
80
+ # @return [Sawyer::Resource] A hash representing a collection of check runs
81
+ # @see https://developer.github.com/v3/checks/runs/#list-check-runs-in-a-check-suite
82
+ # @example List check runs in a check suite
83
+ # result = @client.check_runs_for_check_suite("octocat/Hello-World", 50440400, status: "in_progress")
84
+ # result.total_count # => 1
85
+ # result.check_runs.count # => 1
86
+ # result.check_runs[0].check_suite.id # => 50440400
87
+ # result.check_runs[0].status # => "in_progress"
88
+ def check_runs_for_check_suite(repo, id, options = {})
89
+ ensure_api_media_type(:checks, options)
90
+
91
+ get "#{Repository.path repo}/check-suites/#{id}/check-runs", options
92
+ end
93
+ alias :list_check_runs_for_check_suite :check_runs_for_check_suite
94
+
95
+ # Get a single check run
96
+ #
97
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
98
+ # @param id [Integer] The ID of the check run
99
+ # @return [Sawyer::Resource] A hash representing the check run
100
+ # @see https://developer.github.com/v3/checks/runs/#get-a-single-check-run
101
+ def check_run(repo, id, options = {})
102
+ ensure_api_media_type(:checks, options)
103
+
104
+ get "#{Repository.path repo}/check-runs/#{id}", options
105
+ end
106
+
107
+ # List annotations for a check run
108
+ #
109
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
110
+ # @param id [Integer] The ID of the check run
111
+ # @return [Array<Sawyer::Resource>] An array of hashes representing check run annotations
112
+ # @see https://developer.github.com/v3/checks/runs/#list-annotations-for-a-check-run
113
+ # @example List annotations for a check run
114
+ # annotations = @client.check_run_annotations("octocat/Hello-World", 51295429)
115
+ # annotations.count # => 1
116
+ # annotations[0].path # => "README.md"
117
+ # annotations[0].message # => "Looks good!"
118
+ def check_run_annotations(repo, id, options = {})
119
+ ensure_api_media_type(:checks, options)
120
+
121
+ get "#{Repository.path repo}/check-runs/#{id}/annotations", options
122
+ end
123
+
124
+ # Methods for Check Suites
125
+ #
126
+ # @see https://developer.github.com/v3/checks/suites/
127
+
128
+ # Get a single check suite
129
+ #
130
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
131
+ # @param id [Integer] The ID of the check suite
132
+ # @return [Sawyer::Resource] A hash representing the check suite
133
+ # @see https://developer.github.com/v3/checks/suites/#get-a-single-check-suite
134
+ def check_suite(repo, id, options = {})
135
+ ensure_api_media_type(:checks, options)
136
+
137
+ get "#{Repository.path repo}/check-suites/#{id}", options
138
+ end
139
+
140
+ # List check suites for a specific ref
141
+ #
142
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
143
+ # @param ref [String] A SHA, branch name, or tag name
144
+ # @param options [Hash] A set of optional filters
145
+ # @option options [Integer] :app_id Filters check suites by GitHub App <tt>id</tt>
146
+ # @option options [String] :check_name Filters checks suites by the <tt>name</tt> of the check run
147
+ # @return [Sawyer::Resource] A hash representing a collection of check suites
148
+ # @see https://developer.github.com/v3/checks/suites/#list-check-suites-for-a-specific-ref
149
+ # @example List check suites for a specific ref
150
+ # result = @client.check_suites_for_ref("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd", app_id: 76765)
151
+ # result.total_count # => 1
152
+ # result.check_suites.count # => 1
153
+ # result.check_suites[0].id # => 50440400
154
+ # result.check_suites[0].app.id # => 76765
155
+ def check_suites_for_ref(repo, ref, options = {})
156
+ ensure_api_media_type(:checks, options)
157
+
158
+ get "#{Repository.path repo}/commits/#{ref}/check-suites", options
159
+ end
160
+ alias :list_check_suites_for_ref :check_suites_for_ref
161
+
162
+ # Set preferences for check suites on a repository
163
+ #
164
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
165
+ # @param options [Hash] Preferences to set
166
+ # @return [Sawyer::Resource] A hash representing the repository's check suite preferences
167
+ # @see https://developer.github.com/v3/checks/suites/#set-preferences-for-check-suites-on-a-repository
168
+ # @example Set preferences for check suites on a repository
169
+ # result = @client.set_check_suite_preferences("octocat/Hello-World", auto_trigger_checks: [{ app_id: 76765, setting: false }])
170
+ # result.preferences.auto_trigger_checks.count # => 1
171
+ # result.preferences.auto_trigger_checks[0].app_id # => 76765
172
+ # result.preferences.auto_trigger_checks[0].setting # => false
173
+ # result.repository.full_name # => "octocat/Hello-World"
174
+ def set_check_suite_preferences(repo, options = {})
175
+ ensure_api_media_type(:checks, options)
176
+
177
+ patch "#{Repository.path repo}/check-suites/preferences", options
178
+ end
179
+
180
+ # Create a check suite
181
+ #
182
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
183
+ # @param head_sha [String] The SHA of the commit to check
184
+ # @return [Sawyer::Resource] A hash representing the new check suite
185
+ # @see https://developer.github.com/v3/checks/suites/#create-a-check-suite
186
+ # @example Create a check suite
187
+ # check_suite = @client.create_check_suite("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd")
188
+ # check_suite.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
189
+ # check_suite.status # => "queued"
190
+ def create_check_suite(repo, head_sha, options = {})
191
+ ensure_api_media_type(:checks, options)
192
+ options[:head_sha] = head_sha
193
+
194
+ post "#{Repository.path repo}/check-suites", options
195
+ end
196
+
197
+ # Rerequest check suite
198
+ #
199
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
200
+ # @param id [Integer] The ID of the check suite
201
+ # @return [Boolean] True if successful, raises an error otherwise
202
+ # @see https://developer.github.com/v3/checks/suites/#rerequest-check-suite
203
+ def rerequest_check_suite(repo, id, options = {})
204
+ ensure_api_media_type(:checks, options)
205
+
206
+ post "#{Repository.path repo}/check-suites/#{id}/rerequest", options
207
+ true
208
+ end
209
+ end
210
+ end
211
+ end
@@ -51,7 +51,7 @@ module Octokit
51
51
  # @client.org_projects("octokit")
52
52
  def org_projects(org, options = {})
53
53
  opts = ensure_api_media_type(:projects, options)
54
- get "orgs/#{org}/projects", opts
54
+ paginate "orgs/#{org}/projects", opts
55
55
  end
56
56
  alias :organization_projects :org_projects
57
57
 
@@ -10,7 +10,7 @@ module Octokit
10
10
  #
11
11
  # @see https://developer.github.com/v3/repos/#get
12
12
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
13
- # @return [Sawyer::Resource] if a repository exists, false otherwise
13
+ # @return [Boolean]
14
14
  def repository?(repo, options = {})
15
15
  !!repository(repo, options)
16
16
  rescue Octokit::InvalidRepository
@@ -293,7 +293,7 @@ module Octokit
293
293
  #
294
294
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
295
295
  # @option options [String] :affiliation Filters the return array by affiliation.
296
- # Can be one of: <tt>outside</tt> or <tt>all</tt>.
296
+ # Can be one of: <tt>outside</tt>, <tt>direct</tt>, or <tt>all</tt>.
297
297
  # If not specified, defaults to <tt>all</tt>
298
298
  # @return [Array<Sawyer::Resource>] Array of hashes representing collaborating users.
299
299
  # @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
@@ -175,7 +175,15 @@ 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
+ if conn_opts[:ssl].nil?
179
+ conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode
180
+ else
181
+ if @connection_options[:ssl][:verify] == false
182
+ conn_opts[:ssl] = { :verify_mode => 0}
183
+ else
184
+ conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode }
185
+ end
186
+ end
179
187
  opts[:faraday] = Faraday.new(conn_opts)
180
188
 
181
189
  opts
@@ -5,6 +5,7 @@ module Octokit
5
5
 
6
6
  PREVIEW_TYPES = {
7
7
  :branch_protection => 'application/vnd.github.loki-preview+json'.freeze,
8
+ :checks => 'application/vnd.github.antiope-preview+json'.freeze,
8
9
  :commit_search => 'application/vnd.github.cloak-preview+json'.freeze,
9
10
  :migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
10
11
  :licenses => 'application/vnd.github.drax-preview+json'.freeze,
@@ -88,7 +88,7 @@ module Octokit
88
88
 
89
89
  def raise_invalid_repository!(repo)
90
90
  msg = "#{repo.inspect} is invalid as a repository identifier. " +
91
- "Use the repo/user (String) format, or the repository ID (Integer), or a hash containing :repo and :user keys."
91
+ "Use the user/repo (String) format, or the repository ID (Integer), or a hash containing :repo and :user keys."
92
92
  raise Octokit::InvalidRepository, msg
93
93
  end
94
94
  end
@@ -5,7 +5,7 @@ module Octokit
5
5
 
6
6
  # Current minor release.
7
7
  # @return [Integer]
8
- MINOR = 13
8
+ MINOR = 14
9
9
 
10
10
  # Current patch level.
11
11
  # @return [Integer]
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'octokit/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.add_development_dependency 'bundler', '~> 1.0'
7
+ spec.add_development_dependency 'bundler', '>= 1', '< 3'
8
8
  spec.add_dependency 'sawyer', '>= 0.5.3', '~> 0.8.0'
9
9
  spec.authors = ["Wynn Netherland", "Erik Michaels-Ober", "Clint Shryock"]
10
10
  spec.description = %q{Simple wrapper for the GitHub API}
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.13.0
4
+ version: 4.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -10,22 +10,28 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-10-11 00:00:00.000000000 Z
13
+ date: 2019-03-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '1'
22
+ - - "<"
20
23
  - !ruby/object:Gem::Version
21
- version: '1.0'
24
+ version: '3'
22
25
  type: :development
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
- - - "~>"
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '1'
32
+ - - "<"
27
33
  - !ruby/object:Gem::Version
28
- version: '1.0'
34
+ version: '3'
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: sawyer
31
37
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +73,7 @@ files:
67
73
  - lib/octokit/client.rb
68
74
  - lib/octokit/client/apps.rb
69
75
  - lib/octokit/client/authorizations.rb
76
+ - lib/octokit/client/checks.rb
70
77
  - lib/octokit/client/commit_comments.rb
71
78
  - lib/octokit/client/commits.rb
72
79
  - lib/octokit/client/community_profile.rb
@@ -153,8 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
160
  - !ruby/object:Gem::Version
154
161
  version: 1.3.5
155
162
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.7.7
163
+ rubygems_version: 3.0.3
158
164
  signing_key:
159
165
  specification_version: 4
160
166
  summary: Ruby toolkit for working with the GitHub API