octokit 4.2.0 → 4.3.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: 73f0bf2bde2a97e167a1fa41e45d4d5a71fb655c
4
- data.tar.gz: 30568c40a8b5f36a3856e68887d350156a52b99b
3
+ metadata.gz: 433f670467c277e091d184af708f336f2a019b5a
4
+ data.tar.gz: 4c29fdcfe9e156bec1a58b83c809ced9ff628748
5
5
  SHA512:
6
- metadata.gz: 2f35e8d8ea32a30434c9906744b15248905eda5cda4b53152d85ee3543673e1e6a96a64651168123506a1de6e247018e699396aac43cc6b65d646687b53bd4e8
7
- data.tar.gz: ccbc3c6e9392ca6ecccec7548d0e2653480cf792403916d1d56e083915bb302166e4def32f02c98e47d87786b6e427d18afbbf3d8713abeb297f08fa5a239a8c
6
+ metadata.gz: db2aa2a80a84de1d91da8b0414145e1f7adb28a01b957cc14dfe075208a110aeaf85886fb2a6af45ee2fb5688cc51847ff698aa7731da656d7519e40776d764c
7
+ data.tar.gz: d6bc2a4e82cef39bde7daf9c2149e2b58dc6c75e09c5ce1f41936725937f90f58f54449f676b1ac0098c412027e4974016d2f7b415fbaf5f361ad97c697b9db2
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009-2014 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
1
+ Copyright (c) 2009-2016 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -267,7 +267,7 @@ To interact with the "regular" GitHub.com APIs in GitHub Enterprise, simply conf
267
267
 
268
268
  ``` ruby
269
269
  Octokit.configure do |c|
270
- c.api_endpoint = "<hostname>/api/v3/"
270
+ c.api_endpoint = "https://<hostname>/api/v3/"
271
271
  end
272
272
  client = Octokit::Client.new(:access_token => "<your 40 char token>")
273
273
  ```
@@ -283,7 +283,7 @@ admin_client = Octokit::EnterpriseAdminClient.new \
283
283
 
284
284
  # or
285
285
  Octokit.configure do |c|
286
- c.api_endpoint = "https://hostname/api/v3/"
286
+ c.api_endpoint = "https://<hostname>/api/v3/"
287
287
  c.access_token = "<your 40 char token>"
288
288
  end
289
289
  admin_client = Octokit.enterprise_admin_client
@@ -320,7 +320,9 @@ Do remember to turn `:verify` back to `true`, as it's important for secure commu
320
320
  While `Octokit::Client` accepts a range of options when creating a new client
321
321
  instance, Octokit's configuration API allows you to set your configuration
322
322
  options at the module level. This is particularly handy if you're creating a
323
- number of client instances based on some shared defaults.
323
+ number of client instances based on some shared defaults. Changing options
324
+ affects new instances only and will not modify existing `Octokit::Client`
325
+ instances created with previous options.
324
326
 
325
327
  ### Configuring module defaults
326
328
 
@@ -408,6 +410,8 @@ the API root and follow link relations from there:
408
410
  ```ruby
409
411
  root = Octokit.root
410
412
  root.rels[:repository].get :uri => {:owner => "octokit", :repo => "octokit.rb" }
413
+ root.rels[:user_repositories].get :uri => { :user => "octokit" },
414
+ :query => { :type => "owner" }
411
415
  ```
412
416
 
413
417
  Octokit 3.0 aims to be hypermedia-driven, removing the internal URL
@@ -42,6 +42,7 @@ require 'octokit/client/repositories'
42
42
  require 'octokit/client/say'
43
43
  require 'octokit/client/search'
44
44
  require 'octokit/client/service_status'
45
+ require 'octokit/client/source_import'
45
46
  require 'octokit/client/stats'
46
47
  require 'octokit/client/statuses'
47
48
  require 'octokit/client/users'
@@ -90,6 +91,7 @@ module Octokit
90
91
  include Octokit::Client::Say
91
92
  include Octokit::Client::Search
92
93
  include Octokit::Client::ServiceStatus
94
+ include Octokit::Client::SourceImport
93
95
  include Octokit::Client::Stats
94
96
  include Octokit::Client::Statuses
95
97
  include Octokit::Client::Users
@@ -54,7 +54,7 @@ module Octokit
54
54
  # @see https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app
55
55
  # @example Create a new authorization for user ctshryock's project Zoidberg
56
56
  # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
57
- # client.create_authorization({:scopes => ["public_repo","gist"], :note => "Why not Zoidberg?", :note_url=> "https://en.wikipedia.org/wiki/Zoidberg"})
57
+ # client.create_authorization({:scopes => ["public_repo", "gist"], :note => "Why not Zoidberg?", :note_url=> "https://en.wikipedia.org/wiki/Zoidberg"})
58
58
  # @example Create a new OR return an existing authorization to be used by a specific client for user ctshryock's project Zoidberg
59
59
  # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
60
60
  # client.create_authorization({:idempotent => true, :client_id => 'xxxx', :client_secret => 'yyyy', :scopes => ["user"]})
@@ -207,25 +207,12 @@ module Octokit
207
207
  #
208
208
  # Applications can revoke all of their tokens in a single request
209
209
  #
210
- # @return [Boolean] Result
211
- # @see https://developer.github.com/v3/oauth_authorizations/#revoke-all-authorizations-for-an-application
212
- # @example
213
- # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
214
- # client.revoke_all_application_authorizations
210
+ # @deprecated As of January 25th, 2016: https://developer.github.com/changes/2014-04-08-reset-api-tokens/
211
+ # @return [Boolean] false
215
212
  def revoke_all_application_authorizations(options = {})
216
- opts = options.dup
217
- key = opts.delete(:client_id) || client_id
218
- secret = opts.delete(:client_secret) || client_secret
219
-
220
- as_app(key, secret) do |app_client|
221
- app_client.delete "/applications/#{client_id}/tokens", opts
222
-
223
- app_client.last_response.status == 204
224
- end
225
- rescue Octokit::NotFound
213
+ octokit_warn("Deprecated: If you need to revoke all tokens for your application, you can do so via the settings page for your application.")
226
214
  false
227
215
  end
228
- alias :delete_application_authorization :revoke_application_authorization
229
216
 
230
217
  # Get the URL to authorize a user for an application via the web flow
231
218
  #
@@ -48,6 +48,8 @@ module Octokit
48
48
  #
49
49
  # @param deployment_url [String] A URL for a deployment resource
50
50
  # @param state [String] The state: pending, success, failure, error
51
+ # @option options [String] :target_url The target URL to associate with this status. Default: ""
52
+ # @option options [String] :description A short description of the status. Maximum length of 140 characters. Default: ""
51
53
  # @return [Sawyer::Resource] A deployment status
52
54
  # @see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
53
55
  def create_deployment_status(deployment_url, state, options = {})
@@ -45,10 +45,16 @@ module Octokit
45
45
  # Get a single gist
46
46
  #
47
47
  # @param gist [String] ID of gist to fetch
48
+ # @option options [String] :sha Specific gist revision SHA
48
49
  # @return [Sawyer::Resource] Gist information
49
50
  # @see https://developer.github.com/v3/gists/#get-a-single-gist
51
+ # @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
50
52
  def gist(gist, options = {})
51
- get "gists/#{Gist.new(gist)}", options
53
+ if sha = options.delete(:sha)
54
+ get "gists/#{Gist.new(gist)}/#{sha}", options
55
+ else
56
+ get "gists/#{Gist.new(gist)}", options
57
+ end
52
58
  end
53
59
 
54
60
  # Create a gist
@@ -88,6 +94,17 @@ module Octokit
88
94
  patch "gists/#{Gist.new(gist)}", options
89
95
  end
90
96
 
97
+ # List gist commits
98
+ #
99
+ # @param gist [String] Gist ID
100
+ # @return [Array] List of commits to the gist
101
+ # @see https://developer.github.com/v3/gists/#list-gist-commits
102
+ # @example List commits for a gist
103
+ # @client.gist_commits('some_id')
104
+ def gist_commits(gist, options = {})
105
+ paginate "gists/#{Gist.new(gist)}/commits", options
106
+ end
107
+
91
108
  #
92
109
  # Star a gist
93
110
  #
@@ -125,6 +142,17 @@ module Octokit
125
142
  post "gists/#{Gist.new(gist)}/forks", options
126
143
  end
127
144
 
145
+ # List gist forks
146
+ #
147
+ # @param gist [String] Gist ID
148
+ # @return [Array] List of gist forks
149
+ # @see https://developer.github.com/v3/gists/#list-gist-forks
150
+ # @example List gist forks
151
+ # @client.gist_forks('some-id')
152
+ def gist_forks(gist, options = {})
153
+ paginate "gists/#{Gist.new(gist)}/forks", options
154
+ end
155
+
128
156
  # Delete a gist
129
157
  #
130
158
  # @param gist [String] Gist ID
@@ -148,17 +148,31 @@ module Octokit
148
148
  boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", options
149
149
  end
150
150
 
151
+ # Ping hook
152
+ #
153
+ # Requires authenticated client.
154
+ #
155
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
156
+ # @param id [Integer] Id of the hook to send a ping.
157
+ # @return [Boolean] Ping requested?
158
+ # @see https://developer.github.com/v3/repos/hooks/#ping-a-hook
159
+ # @example
160
+ # @client.ping_hook('octokit/octokit.rb', 1000000)
161
+ def ping_hook(repo, id, options={})
162
+ boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/pings", options
163
+ end
164
+
151
165
  # List org hooks
152
166
  #
153
167
  # Requires client authenticated as admin for the org.
154
168
  #
155
- # @param org [String] A GitHub organization login.
169
+ # @param org [String, Integer] Organization GitHub login or id.
156
170
  # @return [Array<Sawyer::Resource>] Array of hashes representing hooks.
157
171
  # @see https://developer.github.com/v3/orgs/hooks/#list-hooks
158
172
  # @example
159
173
  # @client.org_hooks('octokit')
160
174
  def org_hooks(org, options = {})
161
- paginate "orgs/#{org}/hooks", options
175
+ paginate "#{Organization.path org}/hooks", options
162
176
  end
163
177
  alias :list_org_hooks :org_hooks
164
178
 
@@ -166,21 +180,21 @@ module Octokit
166
180
  #
167
181
  # Requires client authenticated as admin for the org.
168
182
  #
169
- # @param org [String] A GitHub organization login.
183
+ # @param org [String, Integer] Organization GitHub login or id.
170
184
  # @param id [Integer] Id of the hook to get.
171
185
  # @return [Sawyer::Resource] Hash representing hook.
172
186
  # @see https://developer.github.com/v3/orgs/hooks/#get-single-hook
173
187
  # @example
174
188
  # @client.org_hook('octokit', 123)
175
189
  def org_hook(org, id, options = {})
176
- get "orgs/#{org}/hooks/#{id}", options
190
+ get "#{Organization.path org}/hooks/#{id}", options
177
191
  end
178
192
 
179
193
  # Create an org hook
180
194
  #
181
195
  # Requires client authenticated as admin for the org.
182
196
  #
183
- # @param org [String] A GitHub organization login.
197
+ # @param org [String, Integer] Organization GitHub login or id.
184
198
  # @param config [Hash] A Hash containing key/value pairs to provide
185
199
  # settings for this hook.
186
200
  # @option options [Array<String>] :events ('["push"]') Determines what
@@ -204,14 +218,14 @@ module Octokit
204
218
  # )
205
219
  def create_org_hook(org, config, options = {})
206
220
  options = { :name => "web", :config => config }.merge(options)
207
- post "orgs/#{org}/hooks", options
221
+ post "#{Organization.path org}/hooks", options
208
222
  end
209
223
 
210
224
  # Update an org hook
211
225
  #
212
226
  # Requires client authenticated as admin for the org.
213
227
  #
214
- # @param org [String] A GitHub organization login.
228
+ # @param org [String, Integer] Organization GitHub login or id.
215
229
  # @param id [Integer] Id of the hook to update.
216
230
  # @param config [Hash] A Hash containing key/value pairs to provide
217
231
  # settings for this hook.
@@ -237,7 +251,7 @@ module Octokit
237
251
  # )
238
252
  def edit_org_hook(org, id, config, options = {})
239
253
  options = { :config => config }.merge(options)
240
- patch "orgs/#{org}/hooks/#{id}", options
254
+ patch "#{Organization.path org}/hooks/#{id}", options
241
255
  end
242
256
  alias :update_org_hook :edit_org_hook
243
257
 
@@ -245,28 +259,28 @@ module Octokit
245
259
  #
246
260
  # Requires client authenticated as admin for the org.
247
261
  #
248
- # @param org [String] A GitHub organization login.
262
+ # @param org [String, Integer] Organization GitHub login or id.
249
263
  # @param id [Integer] Id of the hook to update.
250
264
  # @return [Boolean] Success
251
265
  # @see https://developer.github.com/v3/orgs/hooks/#ping-a-hook
252
266
  # @example
253
267
  # @client.ping_org_hook('octokit', 1000000)
254
268
  def ping_org_hook(org, id, options = {})
255
- boolean_from_response :post, "orgs/#{org}/hooks/#{id}/pings", options
269
+ boolean_from_response :post, "#{Organization.path org}/hooks/#{id}/pings", options
256
270
  end
257
271
 
258
272
  # Remove org hook
259
273
  #
260
274
  # Requires client authenticated as admin for the org.
261
275
  #
262
- # @param org [String] A GitHub organization login.
276
+ # @param org [String, Integer] Organization GitHub login or id.
263
277
  # @param id [Integer] Id of the hook to update.
264
278
  # @return [Boolean] True if hook removed, false otherwise.
265
279
  # @see https://developer.github.com/v3/orgs/hooks/#delete-a-hook
266
280
  # @example
267
281
  # @client.remove_org_hook('octokit', 1000000)
268
282
  def remove_org_hook(org, id, options = {})
269
- boolean_from_response :delete, "orgs/#{org}/hooks/#{id}", options
283
+ boolean_from_response :delete, "#{Organization.path org}/hooks/#{id}", options
270
284
  end
271
285
 
272
286
  # Parse payload string
@@ -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.
@@ -30,7 +30,7 @@ module Octokit
30
30
 
31
31
  # Returns the contents of the repository’s license file, if one is detected.
32
32
  #
33
- # @see https://developer.github.com/v3/licenses/#get-a-repositorys-license
33
+ # @see https://developer.github.com/v3/licenses/#get-the-contents-of-a-repositorys-license
34
34
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
35
35
  # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to 'master'.
36
36
  # @return [Sawyer::Resource] The detail of the license file
@@ -115,7 +115,7 @@ module Octokit
115
115
  # @return [Boolean] True if updated, false otherwise.
116
116
  # @see https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
117
117
  # @example
118
- # @client.mark_thread_as_ready(1, :read => false)
118
+ # @client.mark_thread_as_read(1, :read => false)
119
119
  def mark_thread_as_read(thread_id, options = {})
120
120
  request :patch, "notifications/threads/#{thread_id}", options
121
121
 
@@ -62,6 +62,7 @@ module Octokit
62
62
  # @param user [Integer, String] GitHub user login or id of the user to get
63
63
  # list of organizations.
64
64
  # @return [Array<Sawyer::Resource>] Array of hashes representing organizations.
65
+ # @see https://developer.github.com/v3/orgs/#list-your-organizations
65
66
  # @see https://developer.github.com/v3/orgs/#list-user-organizations
66
67
  # @example
67
68
  # Octokit.organizations('pengwynn')
@@ -393,7 +394,7 @@ module Octokit
393
394
  # @return [Boolean] True if managed by a team. False if not managed by
394
395
  # the team OR the requesting user does not have authorization to access
395
396
  # the team information.
396
- # @see https://developer.github.com/v3/orgs/teams/#get-team-repo
397
+ # @see https://developer.github.com/v3/orgs/teams/#check-if-a-team-manages-a-repository
397
398
  # @example
398
399
  # @client.team_repository?(8675309, 'octokit/octokit.rb')
399
400
  # @example
@@ -413,7 +414,7 @@ module Octokit
413
414
  # @param repo [String, Hash, Repository] A GitHub repository.
414
415
  # @return [Boolean] True if successful, false otherwise.
415
416
  # @see Octokit::Repository
416
- # @see https://developer.github.com/v3/orgs/teams/#add-team-repo
417
+ # @see https://developer.github.com/v3/orgs/teams/#add-team-repository
417
418
  # @example
418
419
  # @client.add_team_repository(100000, 'github/developer.github.com')
419
420
  # @example
@@ -433,7 +434,7 @@ module Octokit
433
434
  # @param repo [String, Hash, Repository] A GitHub repository.
434
435
  # @return [Boolean] Return true if repo removed from team, false otherwise.
435
436
  # @see Octokit::Repository
436
- # @see https://developer.github.com/v3/orgs/teams/#remove-team-repo
437
+ # @see https://developer.github.com/v3/orgs/teams/#remove-team-repository
437
438
  # @example
438
439
  # @client.remove_team_repository(100000, 'github/developer.github.com')
439
440
  # @example
@@ -604,12 +605,12 @@ module Octokit
604
605
  # @param repositories [Array<String>] :repositories Repositories for the organization.
605
606
  # @option options [Boolean, optional] :lock_repositories Indicates whether repositories should be locked during migration
606
607
  # @return [Sawyer::Resource] Hash representing the new migration.
607
- # @see https://developer.github.com/v3/orgs/teams/#create-team
608
608
  # @example
609
609
  # @client.start_migration('github', ['github/dotfiles'])
610
610
  # @see https://developer.github.com/v3/orgs/migrations/#start-a-migration
611
611
  def start_migration(org, repositories, options = {})
612
612
  options = ensure_api_media_type(:migrations, options)
613
+ options[:repositories] = repositories
613
614
  post "orgs/#{org}/migrations", options
614
615
  end
615
616
 
@@ -631,7 +632,7 @@ module Octokit
631
632
  #
632
633
  # @param org [String, Integer] Organization GitHub login or id.
633
634
  # @param id [Integer] ID number of the migration.
634
- # @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
635
+ # @see https://developer.github.com/v3/orgs/migrations/#get-the-status-of-a-migration
635
636
  def migration_status(org, id, options = {})
636
637
  options = ensure_api_media_type(:migrations, options)
637
638
  get "orgs/#{org}/migrations/#{id}", options
@@ -658,7 +659,7 @@ module Octokit
658
659
  #
659
660
  # @param org [String, Integer] Organization GitHub login or id.
660
661
  # @param id [Integer] ID number of the migration.
661
- # @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
662
+ # @see https://developer.github.com/v3/orgs/migrations/#delete-a-migration-archive
662
663
  def delete_migration_archive(org, id, options = {})
663
664
  options = ensure_api_media_type(:migrations, options)
664
665
  delete "orgs/#{org}/migrations/#{id}/archive", options
@@ -276,7 +276,7 @@ module Octokit
276
276
 
277
277
  # Merge a pull request
278
278
  #
279
- # @see https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade
279
+ # @see https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
280
280
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
281
281
  # @param number [Integer] Number of pull request
282
282
  # @param commit_message [String] Optional commit message for the merge commit
@@ -44,10 +44,11 @@ module Octokit
44
44
  # @return [Array<Sawyer::Resource>] The list of references, already containing the new one
45
45
  # @see https://developer.github.com/v3/git/refs/#create-a-reference
46
46
  # @example Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132
47
- # Octokit.create_ref("octocat/Hello-World","heads/master", "827efc6d56897b048c772eb4087f854f46256132")
47
+ # Octokit.create_ref("octocat/Hello-World", "heads/master", "827efc6d56897b048c772eb4087f854f46256132")
48
48
  def create_ref(repo, ref, sha, options = {})
49
+ ref = "refs/#{ref}" unless ref =~ %r{refs/}
49
50
  parameters = {
50
- :ref => "refs/#{ref}",
51
+ :ref => ref,
51
52
  :sha => sha
52
53
  }
53
54
  post "#{Repository.path repo}/git/refs", options.merge(parameters)
@@ -63,7 +64,7 @@ module Octokit
63
64
  # @return [Array<Sawyer::Resource>] The list of references updated
64
65
  # @see https://developer.github.com/v3/git/refs/#update-a-reference
65
66
  # @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
66
- # Octokit.update_ref("octocat/Hello-World","heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
67
+ # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
67
68
  def update_ref(repo, ref, sha, force = true, options = {})
68
69
  parameters = {
69
70
  :sha => sha,
@@ -132,6 +132,7 @@ module Octokit
132
132
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
133
133
  # @param tag_name [String] the name for a tag
134
134
  # @return [Sawyer::Resource] The release
135
+ # @see https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
135
136
  def release_for_tag(repo, tag_name, options = {})
136
137
  get "#{Repository.path repo}/releases/tags/#{tag_name}", options
137
138
  end
@@ -140,6 +141,7 @@ module Octokit
140
141
  #
141
142
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
142
143
  # @return [Sawyer::Resource] The release
144
+ # @see https://developer.github.com/v3/repos/releases/#get-the-latest-release
143
145
  def latest_release(repo, options = {})
144
146
  get "#{Repository.path repo}/releases/latest", options
145
147
  end
@@ -22,6 +22,7 @@ module Octokit
22
22
  # Get a single repository
23
23
  #
24
24
  # @see https://developer.github.com/v3/repos/#get
25
+ # @see https://developer.github.com/v3/licenses/#get-a-repositorys-license
25
26
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
26
27
  # @return [Sawyer::Resource] Repository information
27
28
  def repository(repo, options = {})
@@ -199,7 +200,7 @@ module Octokit
199
200
  #
200
201
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
201
202
  # @return [Array<Sawyer::Resource>] Array of hashes representing deploy keys.
202
- # @see https://developer.github.com/v3/repos/keys/#list
203
+ # @see https://developer.github.com/v3/repos/keys/#list-deploy-keys
203
204
  # @example
204
205
  # @client.deploy_keys('octokit/octokit.rb')
205
206
  # @example
@@ -214,7 +215,7 @@ module Octokit
214
215
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
215
216
  # @param id [Integer] Deploy key ID.
216
217
  # @return [Sawyer::Resource] Deploy key.
217
- # @see https://developer.github.com/v3/repos/keys/#get
218
+ # @see https://developer.github.com/v3/repos/keys/#get-a-deploy-key
218
219
  # @example
219
220
  # @client.deploy_key('octokit/octokit.rb', 8675309)
220
221
  def deploy_key(repo, id, options={})
@@ -229,7 +230,7 @@ module Octokit
229
230
  # @param title [String] Title reference for the deploy key.
230
231
  # @param key [String] Public key.
231
232
  # @return [Sawyer::Resource] Hash representing newly added key.
232
- # @see https://developer.github.com/v3/repos/keys/#create
233
+ # @see https://developer.github.com/v3/repos/keys/#add-a-new-deploy-key
233
234
  # @example
234
235
  # @client.add_deploy_key('octokit/octokit.rb', 'Staging server', 'ssh-rsa AAA...')
235
236
  def add_deploy_key(repo, title, key, options = {})
@@ -246,7 +247,7 @@ module Octokit
246
247
  # @return [Sawyer::Resource] Updated deploy key.
247
248
  # @deprecated This method is no longer supported in the API
248
249
  # @see https://developer.github.com/changes/2014-02-24-finer-grained-scopes-for-ssh-keys/
249
- # @see https://developer.github.com/v3/repos/keys/#edit
250
+ # @see https://developer.github.com/v3/repos/keys/#edit-a-deploy-key
250
251
  # @example Update the key for a deploy key.
251
252
  # @client.edit_deploy_key('octokit/octokit.rb', 8675309, :key => 'ssh-rsa BBB...')
252
253
  # @example
@@ -263,7 +264,7 @@ module Octokit
263
264
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
264
265
  # @param id [Integer] Id of the deploy key to remove.
265
266
  # @return [Boolean] True if key removed, false otherwise.
266
- # @see https://developer.github.com/v3/repos/keys/#delete
267
+ # @see https://developer.github.com/v3/repos/keys/#remove-a-deploy-key
267
268
  # @example
268
269
  # @client.remove_deploy_key('octokit/octokit.rb', 100000)
269
270
  def remove_deploy_key(repo, id, options = {})
@@ -276,7 +277,7 @@ module Octokit
276
277
  #
277
278
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
278
279
  # @return [Array<Sawyer::Resource>] Array of hashes representing collaborating users.
279
- # @see https://developer.github.com/v3/repos/collaborators/#list
280
+ # @see https://developer.github.com/v3/repos/collaborators/#list-collaborators
280
281
  # @example
281
282
  # Octokit.collaborators('octokit/octokit.rb')
282
283
  # @example
@@ -295,7 +296,7 @@ module Octokit
295
296
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
296
297
  # @param collaborator [String] Collaborator GitHub username to add.
297
298
  # @return [Boolean] True if collaborator added, false otherwise.
298
- # @see https://developer.github.com/v3/repos/collaborators/#add-collaborator
299
+ # @see https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
299
300
  # @example
300
301
  # @client.add_collaborator('octokit/octokit.rb', 'holman')
301
302
  # @example
@@ -312,7 +313,7 @@ module Octokit
312
313
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
313
314
  # @param collaborator [String] Collaborator GitHub username to remove.
314
315
  # @return [Boolean] True if collaborator removed, false otherwise.
315
- # @see https://developer.github.com/v3/repos/collaborators/#remove-collaborator
316
+ # @see https://developer.github.com/v3/repos/collaborators/#remove-user-as-a-collaborator
316
317
  # @example
317
318
  # @client.remove_collaborator('octokit/octokit.rb', 'holman')
318
319
  # @example
@@ -329,7 +330,7 @@ module Octokit
329
330
  # @param repo [Integer, String, Hash, Repository] A GitHub repository.
330
331
  # @param collaborator [String] Collaborator GitHub username to check.
331
332
  # @return [Boolean] True if user is a collaborator, false otherwise.
332
- # @see https://developer.github.com/v3/repos/collaborators/#get
333
+ # @see https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
333
334
  # @example
334
335
  # @client.collaborator?('octokit/octokit.rb', 'holman')
335
336
  def collaborator?(repo, collaborator, options={})
@@ -0,0 +1,93 @@
1
+ module Octokit
2
+ class Client
3
+
4
+ # Methods for the Source Import API
5
+ #
6
+ # @see https://developer.github.com/v3/repos/source_imports
7
+ module SourceImport
8
+
9
+ # Start a source import to a GitHub repository using GitHub Importer.
10
+ #
11
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
12
+ # @param vcs [String] The originating VCS type. Can be one of "subversion", "git", "mercurial", or "tfvc".
13
+ # @param vcs_url [String] The URL of the originating repository.
14
+ # @param options [Hash]
15
+ # @option options [String] :vcs_username If authentication is required, the username to provide to vcs_url.
16
+ # @option options [String] :vcs_password If authentication is required, the password to provide to vcs_url.
17
+ # @option options [String] :tfvc_project For a tfvc import, the name of the project that is being imported.
18
+ # @return [Sawyer::Resource] Hash representing the repository import
19
+ # @see https://developer.github.com/v3/migration/source_imports/#start-an-import
20
+ #
21
+ # @example
22
+ # @client.import("octokit/octokit.rb", "subversion", "http://svn.mycompany.com/svn/myproject" {
23
+ # :vcs_username" => "octocat",
24
+ # :vcs_password => "secret"
25
+ # })
26
+ def start_source_import(repo, vcs, vcs_url, options = {})
27
+ options = ensure_api_media_type(:source_imports, options.merge(:vcs => vcs, :vcs_url => vcs_url))
28
+ put "#{Repository.path repo}/import", options
29
+ end
30
+
31
+ # View the progress of an import.
32
+ #
33
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
34
+ # @return [Sawyer::Resource] Hash representing the progress of the import
35
+ # @see https://developer.github.com/v3/migration/source_imports/#get-import-progress
36
+ #
37
+ # @example
38
+ # @client.source_import_progress("octokit/octokit.rb")
39
+ def source_import_progress(repo, options = {})
40
+ options = ensure_api_media_type(:source_imports, options)
41
+ get "#{Repository.path repo}/import", options
42
+ end
43
+
44
+ # List source import commit authors
45
+ #
46
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
47
+ # @param options [Hash]
48
+ # @option options [String] :since Only authors found after this id are returned.
49
+ # @return [Array<Sawyer::Resource>] Array of hashes representing commit_authors.
50
+ # @see https://developer.github.com/v3/migration/source_imports/#get-commit-authors
51
+ #
52
+ # @example
53
+ # @client.source_import_commit_authors("octokit/octokit.rb")
54
+ def source_import_commit_authors(repo, options = {})
55
+ options = ensure_api_media_type(:source_imports, options)
56
+ get "#{Repository.path repo}/import/authors", options
57
+ end
58
+
59
+ # Update an author's identity for the import.
60
+ #
61
+ # @param author_url [String] The source import API url for the commit author
62
+ # @param values [Hash] The updated author attributes
63
+ # @option values [String] :email The new Git author email.
64
+ # @option values [String] :name The new Git author name.
65
+ # @return [Sawyer::Resource] Hash representing the updated commit author
66
+ # @see https://developer.github.com/v3/migration/source_imports/#map-a-commit-author
67
+ #
68
+ # @example
69
+ # author_url = "https://api.github.com/repos/octokit/octokit.rb/import/authors/1"
70
+ # @client.map_source_import_commit_author(author_url, {
71
+ # :email => "hubot@github.com",
72
+ # :name => "Hubot the Robot"
73
+ # })
74
+ def map_source_import_commit_author(author_url, values, options = {})
75
+ options = ensure_api_media_type(:source_imports, options.merge(values))
76
+ patch author_url, options
77
+ end
78
+
79
+ # Stop an import for a repository.
80
+ #
81
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
82
+ # @return [Boolean] True if the import has been cancelled, false otherwise.
83
+ # @see https://developer.github.com/v3/migration/source_imports/#cancel-an-import
84
+ #
85
+ # @example
86
+ # @client.cancel_source_import("octokit/octokit.rb")
87
+ def cancel_source_import(repo, options = {})
88
+ options = ensure_api_media_type(:source_imports, options)
89
+ boolean_from_response :delete, "#{Repository.path repo}/import", options
90
+ end
91
+ end
92
+ end
93
+ end
@@ -9,8 +9,10 @@ module Octokit
9
9
  # Get contributors list with additions, deletions, and commit counts
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
12
+ # @option retry_timeout [Number] How long Octokit should keep trying to get stats (in seconds)
13
+ # @option retry_wait [Number] How long Octokit should wait between retries.
12
14
  # @return [Array<Sawyer::Resource>] Array of contributor stats
13
- # @see https://developer.github.com/v3/repos/statistics/#contributors
15
+ # @see https://developer.github.com/v3/repos/statistics/#get-contributors-list-with-additions-deletions-and-commit-counts
14
16
  # @example Get contributor stats for octokit
15
17
  # @client.contributors_stats('octokit/octokit.rb')
16
18
  def contributors_stats(repo, options = {})
@@ -21,9 +23,11 @@ module Octokit
21
23
  # Get the last year of commit activity data
22
24
  #
23
25
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
26
+ # @option retry_timeout [Number] How long Octokit should keep trying to get stats (in seconds)
27
+ # @option retry_wait [Number] How long Octokit should wait between retries.
24
28
  # @return [Array<Sawyer::Resource>] The last year of commit activity grouped by
25
29
  # week. The days array is a group of commits per day, starting on Sunday.
26
- # @see https://developer.github.com/v3/repos/statistics/#commit-activity
30
+ # @see https://developer.github.com/v3/repos/statistics/#get-the-last-year-of-commit-activity-data
27
31
  # @example Get commit activity for octokit
28
32
  # @client.commit_activity_stats('octokit/octokit.rb')
29
33
  def commit_activity_stats(repo, options = {})
@@ -33,9 +37,11 @@ module Octokit
33
37
  # Get the number of additions and deletions per week
34
38
  #
35
39
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
40
+ # @option retry_timeout [Number] How long Octokit should keep trying to get stats (in seconds)
41
+ # @option retry_wait [Number] How long Octokit should wait between retries.
36
42
  # @return [Array<Sawyer::Resource>] Weekly aggregate of the number of additions
37
43
  # and deletions pushed to a repository.
38
- # @see https://developer.github.com/v3/repos/statistics/#code-frequency
44
+ # @see https://developer.github.com/v3/repos/statistics/#get-the-number-of-additions-and-deletions-per-week
39
45
  # @example Get code frequency stats for octokit
40
46
  # @client.code_frequency_stats('octokit/octokit.rb')
41
47
  def code_frequency_stats(repo, options = {})
@@ -45,11 +51,13 @@ module Octokit
45
51
  # Get the weekly commit count for the repo owner and everyone else
46
52
  #
47
53
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
54
+ # @option retry_timeout [Number] How long Octokit should keep trying to get stats (in seconds)
55
+ # @option retry_wait [Number] How long Octokit should wait between retries.
48
56
  # @return [Sawyer::Resource] Total commit counts for the owner and total commit
49
57
  # counts in all. all is everyone combined, including the owner in the last
50
58
  # 52 weeks. If you’d like to get the commit counts for non-owners, you can
51
59
  # subtract all from owner.
52
- # @see https://developer.github.com/v3/repos/statistics/#participation
60
+ # @see https://developer.github.com/v3/repos/statistics/#get-the-weekly-commit-count-for-the-repository-owner-and-everyone-else
53
61
  # @example Get weekly commit counts for octokit
54
62
  # @client.participation_stats("octokit/octokit.rb")
55
63
  def participation_stats(repo, options = {})
@@ -59,9 +67,11 @@ module Octokit
59
67
  # Get the number of commits per hour in each day
60
68
  #
61
69
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
70
+ # @option retry_timeout [Number] How long Octokit should keep trying to get stats (in seconds)
71
+ # @option retry_wait [Number] How long Octokit should wait between retries.
62
72
  # @return [Array<Array>] Arrays containing the day number, hour number, and
63
73
  # number of commits
64
- # @see https://developer.github.com/v3/repos/statistics/#punch-card
74
+ # @see https://developer.github.com/v3/repos/statistics/#get-the-number-of-commits-per-hour-in-each-day
65
75
  # @example Get octokit punch card
66
76
  # @octokit.punch_card_stats
67
77
  def punch_card_stats(repo, options = {})
@@ -75,11 +85,20 @@ module Octokit
75
85
  #
76
86
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
77
87
  # @param metric [String] The metrics you are looking for
78
- # @return [Array<Sawyer::Resource>] Magical unicorn stats
88
+ # @return [Array<Sawyer::Resource> or nil] Stats in metric-specific format, or nil if not yet calculated.
89
+ # @see https://developer.github.com/v3/repos/statistics/
79
90
  def get_stats(repo, metric, options = {})
80
- data = get("#{Repository.path repo}/stats/#{metric}", options)
81
-
82
- last_response.status == 202 ? nil : data
91
+ if retry_timeout = options.delete(:retry_timeout)
92
+ retry_wait = options.delete(:retry_wait) || 0.5
93
+ timeout = Time.now + retry_timeout
94
+ end
95
+ loop do
96
+ data = get("#{Repository.path repo}/stats/#{metric}", options)
97
+ return data if last_response.status == 200
98
+ return nil unless retry_timeout
99
+ return data if Time.now >= timeout
100
+ sleep retry_wait if retry_wait
101
+ end
83
102
  end
84
103
  end
85
104
  end
@@ -49,10 +49,10 @@ module Octokit
49
49
 
50
50
  attr_accessor :access_token, :auto_paginate, :client_id,
51
51
  :client_secret, :default_media_type, :connection_options,
52
- :management_console_endpoint, :management_console_password,
53
52
  :middleware, :netrc, :netrc_file,
54
53
  :per_page, :proxy, :user_agent
55
- attr_writer :password, :web_endpoint, :api_endpoint, :login
54
+ attr_writer :password, :web_endpoint, :api_endpoint, :login,
55
+ :management_console_endpoint, :management_console_password
56
56
 
57
57
  class << self
58
58
 
@@ -17,6 +17,8 @@ module Octokit
17
17
  # @example
18
18
  # @admin_client.create_organization('SuchAGreatOrg', 'gjtorikian')
19
19
  def create_organization(login, admin, options = {})
20
+ options[:login] = login
21
+ options[:admin] = admin
20
22
  post "admin/organizations", options
21
23
  end
22
24
 
@@ -58,8 +58,8 @@ module Octokit
58
58
  # @see https://developer.github.com/v3/users/administration/#delete-a-user
59
59
  # @example
60
60
  # @admin_client.delete_key(1)
61
- def delete_user(id, options = {})
62
- boolean_from_response :delete, "admin/users/#{id}", options
61
+ def delete_user(username, options = {})
62
+ boolean_from_response :delete, "admin/users/#{username}", options
63
63
  end
64
64
 
65
65
  # Suspend a user.
@@ -6,7 +6,8 @@ module Octokit
6
6
  PREVIEW_TYPES = {
7
7
  :branch_protection => 'application/vnd.github.loki-preview+json'.freeze,
8
8
  :migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
9
- :licenses => 'application/vnd.github.drax-preview+json'.freeze
9
+ :licenses => 'application/vnd.github.drax-preview+json'.freeze,
10
+ :source_imports => 'application/vnd.github.barred-rock-preview'.freeze,
10
11
  }
11
12
 
12
13
  def ensure_api_media_type(type, options)
@@ -5,7 +5,7 @@ module Octokit
5
5
 
6
6
  # Current minor release.
7
7
  # @return [Integer]
8
- MINOR = 2
8
+ MINOR = 3
9
9
 
10
10
  # Current patch level.
11
11
  # @return [Integer]
@@ -5,7 +5,7 @@ require 'octokit/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.add_development_dependency 'bundler', '~> 1.0'
8
- spec.add_dependency 'sawyer', '>= 0.5.3', '~> 0.6.0'
8
+ spec.add_dependency 'sawyer', '>= 0.5.3', '~> 0.7.0'
9
9
  spec.authors = ["Wynn Netherland", "Erik Michaels-Ober", "Clint Shryock"]
10
10
  spec.description = %q{Simple wrapper for the GitHub API}
11
11
  spec.email = ['wynn.netherland@gmail.com', 'sferik@gmail.com', 'clint@ctshryock.com']
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.2.0
4
+ version: 4.3.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-11-17 00:00:00.000000000 Z
13
+ date: 2016-03-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: 0.5.3
36
36
  - - "~>"
37
37
  - !ruby/object:Gem::Version
38
- version: 0.6.0
38
+ version: 0.7.0
39
39
  type: :runtime
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: 0.5.3
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 0.6.0
48
+ version: 0.7.0
49
49
  description: Simple wrapper for the GitHub API
50
50
  email:
51
51
  - wynn.netherland@gmail.com
@@ -96,6 +96,7 @@ files:
96
96
  - lib/octokit/client/say.rb
97
97
  - lib/octokit/client/search.rb
98
98
  - lib/octokit/client/service_status.rb
99
+ - lib/octokit/client/source_import.rb
99
100
  - lib/octokit/client/stats.rb
100
101
  - lib/octokit/client/statuses.rb
101
102
  - lib/octokit/client/users.rb