octokit 4.1.1 → 4.2.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: 94d991c0ebb91eff8b87688e204c80b3820bcdbc
4
- data.tar.gz: e81a6b01eadef14a4a2680dc192e6915a750af7c
3
+ metadata.gz: 73f0bf2bde2a97e167a1fa41e45d4d5a71fb655c
4
+ data.tar.gz: 30568c40a8b5f36a3856e68887d350156a52b99b
5
5
  SHA512:
6
- metadata.gz: a000cbae7cfd114165a405ca9cba6dc2ed847d979ec5b9a427ca5516ccda7705af72494eb82a5ba64c880c30acc9e40ef74b6cce7232d897ef17d39f77dbb5d8
7
- data.tar.gz: ad4876a4392214c9a8b2c353bb7ff76f81d028c27c765e6b7c2da5c7404ec3c8801cd59a175d0377f129aab1f5c8cc688be846b33ff12d018fe2fbcf59804503
6
+ metadata.gz: 2f35e8d8ea32a30434c9906744b15248905eda5cda4b53152d85ee3543673e1e6a96a64651168123506a1de6e247018e699396aac43cc6b65d646687b53bd4e8
7
+ data.tar.gz: ccbc3c6e9392ca6ecccec7548d0e2653480cf792403916d1d56e083915bb302166e4def32f02c98e47d87786b6e427d18afbbf3d8713abeb297f08fa5a239a8c
@@ -18,5 +18,5 @@
18
18
  11. [Submit a pull request.][pr]
19
19
 
20
20
  [fork]: https://help.github.com/articles/fork-a-repo
21
- [branch]: http://learn.github.com/p/branching.html
21
+ [branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
22
22
  [pr]: https://help.github.com/articles/using-pull-requests
@@ -66,7 +66,12 @@ module Octokit
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
68
68
 
69
- put "authorizations/clients/#{client_id}", options.merge(:client_secret => client_secret)
69
+ if fingerprint = options.delete(:fingerprint)
70
+ put "authorizations/clients/#{client_id}/#{fingerprint}", options.merge(:client_secret => client_secret)
71
+ else
72
+ put "authorizations/clients/#{client_id}", options.merge(:client_secret => client_secret)
73
+ end
74
+
70
75
  else
71
76
  post 'authorizations', options
72
77
  end
@@ -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 [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
18
+ # @option options [Array<String>] :labels List of 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.
@@ -38,7 +38,7 @@ module Octokit
38
38
  # @param options [Sawyer::Resource] A customizable set of options.
39
39
  # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
40
40
  # @option options [String] :state (open) State: <tt>open</tt>, <tt>closed</tt>, or <tt>all</tt>.
41
- # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
41
+ # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
42
42
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
43
43
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
44
44
  # @option options [Integer] :page (1) Page number.
@@ -59,7 +59,7 @@ module Octokit
59
59
  # @param options [Sawyer::Resource] A customizable set of options.
60
60
  # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
61
61
  # @option options [String] :state (open) State: <tt>open</tt>, <tt>closed</tt>, or <tt>all</tt>.
62
- # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
62
+ # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
63
63
  # @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
64
64
  # @option options [String] :direction (desc) Direction: <tt>asc</tt> or <tt>desc</tt>.
65
65
  # @option options [Integer] :page (1) Page number.
@@ -121,7 +121,7 @@ module Octokit
121
121
  # @param options [Hash] A customizable set of options.
122
122
  # @option options [String] :assignee User login.
123
123
  # @option options [Integer] :milestone Milestone number.
124
- # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
124
+ # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
125
125
  # @return [Sawyer::Resource] The updated Issue
126
126
  # @see https://developer.github.com/v3/issues/#edit-an-issue
127
127
  # @example Close Issue #25 from octokit/octokit.rb
@@ -137,7 +137,7 @@ module Octokit
137
137
  # @param options [Hash] A customizable set of options.
138
138
  # @option options [String] :assignee User login.
139
139
  # @option options [Integer] :milestone Milestone number.
140
- # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
140
+ # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
141
141
  # @return [Sawyer::Resource] The updated Issue
142
142
  # @see https://developer.github.com/v3/issues/#edit-an-issue
143
143
  # @example Reopen Issue #25 from octokit/octokit.rb
@@ -167,7 +167,7 @@ module Octokit
167
167
  # @option options [String] :body Updated body of the issue
168
168
  # @option options [String] :assignee User login.
169
169
  # @option options [Integer] :milestone Milestone number.
170
- # @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
170
+ # @option options [Array<String>] :labels List of Label names. Example: <tt>['bug', 'ui', '@high']</tt>.
171
171
  # @option options [String] :state State of the issue. <tt>open</tt> or <tt>closed</tt>
172
172
  # @return [Sawyer::Resource] The updated Issue
173
173
  # @see https://developer.github.com/v3/issues/#edit-an-issue
@@ -27,6 +27,19 @@ module Octokit
27
27
  options = ensure_api_media_type(:licenses, options)
28
28
  get "licenses/#{license_name}", options
29
29
  end
30
+
31
+ # Returns the contents of the repository’s license file, if one is detected.
32
+ #
33
+ # @see https://developer.github.com/v3/licenses/#get-a-repositorys-license
34
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
35
+ # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to 'master'.
36
+ # @return [Sawyer::Resource] The detail of the license file
37
+ # @example
38
+ # Octokit.license_contents 'benbalter/licensee'
39
+ def repository_license_contents(repo, options = {})
40
+ options = ensure_api_media_type(:licenses, options)
41
+ get "#{Repository.path repo}/license", options
42
+ end
30
43
  end
31
44
  end
32
45
  end
@@ -498,7 +498,7 @@ module Octokit
498
498
  # @return [Array<Sawyer::Resource>] Array of team resources.
499
499
  # @see https://developer.github.com/v3/orgs/teams/#list-user-teams
500
500
  def user_teams(options = {})
501
- paginate "/user/teams", options
501
+ paginate "user/teams", options
502
502
  end
503
503
 
504
504
  # Check if a user has a team membership.
@@ -483,6 +483,44 @@ module Octokit
483
483
  end
484
484
  alias :get_branch :branch
485
485
 
486
+ # Lock a single branch from a repository
487
+ #
488
+ # Requires authenticated client
489
+ #
490
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
491
+ # @param branch [String] Branch name
492
+ # @param required_status_checks [Hash]
493
+ # @return [Sawyer::Resource] The protected branch
494
+ # @see https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
495
+ # @example
496
+ # @client.protect_branch('octokit/octokit.rb', 'master', foo)
497
+ def protect_branch(repo, branch, required_status_checks = {}, options = {})
498
+ if !required_status_checks.empty?
499
+ required_status_checks = { :required_status_checks => required_status_checks }
500
+ end
501
+
502
+ protection = { :protection => { :enabled => true }.merge(required_status_checks) }
503
+ options = ensure_api_media_type(:branch_protection, options.merge(protection))
504
+
505
+ patch "#{Repository.path repo}/branches/#{branch}", options
506
+ end
507
+
508
+ # Unlock a single branch from a repository
509
+ #
510
+ # Requires authenticated client
511
+ #
512
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
513
+ # @param branch [String] Branch name
514
+ # @return [Sawyer::Resource] The unprotected branch
515
+ # @see https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
516
+ # @example
517
+ # @client.unprotect_branch('octokit/octokit.rb', 'master')
518
+ def unprotect_branch(repo, branch, options = {})
519
+ protection = { :protection => { :enabled => false } }
520
+ options = ensure_api_media_type(:branch_protection, options.merge(protection))
521
+ patch "#{Repository.path repo}/branches/#{branch}", options
522
+ end
523
+
486
524
  # List users available for assigning to issues.
487
525
  #
488
526
  # Requires authenticated client for private repos.
@@ -52,6 +52,16 @@ module Octokit
52
52
  patch "admin/users/#{old_login}", options
53
53
  end
54
54
 
55
+ # Deletes a user.
56
+ #
57
+ # @param username [String] The username to delete.
58
+ # @see https://developer.github.com/v3/users/administration/#delete-a-user
59
+ # @example
60
+ # @admin_client.delete_key(1)
61
+ def delete_user(id, options = {})
62
+ boolean_from_response :delete, "admin/users/#{id}", options
63
+ end
64
+
55
65
  # Suspend a user.
56
66
  #
57
67
  # @param user [String] Username of the user to suspend.
@@ -66,6 +66,8 @@ module Octokit
66
66
  Octokit::AbuseDetected
67
67
  elsif body =~ /repository access blocked/i
68
68
  Octokit::RepositoryUnavailable
69
+ elsif body =~ /email address must be verified/i
70
+ Octokit::UnverifiedEmail
69
71
  else
70
72
  Octokit::Forbidden
71
73
  end
@@ -199,6 +201,10 @@ module Octokit
199
201
  # and body matches 'repository access blocked'
200
202
  class RepositoryUnavailable < Forbidden; end
201
203
 
204
+ # Raised when GitHub returns a 403 HTTP status code
205
+ # and body matches 'email address must be verified'
206
+ class UnverifiedEmail < Forbidden; end
207
+
202
208
  # Raised when GitHub returns a 404 HTTP status code
203
209
  class NotFound < ClientError; end
204
210
 
@@ -4,14 +4,15 @@ module Octokit
4
4
  module Preview
5
5
 
6
6
  PREVIEW_TYPES = {
7
- :migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
8
- :licenses => 'application/vnd.github.drax-preview+json'.freeze
7
+ :branch_protection => 'application/vnd.github.loki-preview+json'.freeze,
8
+ :migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
9
+ :licenses => 'application/vnd.github.drax-preview+json'.freeze
9
10
  }
10
11
 
11
12
  def ensure_api_media_type(type, options)
12
13
  if options[:accept].nil?
13
14
  options[:accept] = PREVIEW_TYPES[type]
14
- warn_preview(:migrations)
15
+ warn_preview(type)
15
16
  end
16
17
  options
17
18
  end
@@ -5,11 +5,11 @@ module Octokit
5
5
 
6
6
  # Current minor release.
7
7
  # @return [Integer]
8
- MINOR = 1
8
+ MINOR = 2
9
9
 
10
10
  # Current patch level.
11
11
  # @return [Integer]
12
- PATCH = 1
12
+ PATCH = 0
13
13
 
14
14
  # Full release version.
15
15
  # @return [String]
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.1.1
4
+ version: 4.2.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: 2015-09-24 00:00:00.000000000 Z
13
+ date: 2015-11-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: 1.3.5
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.2.3
147
+ rubygems_version: 2.4.5.1
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Ruby toolkit for working with the GitHub API