octokit 4.3.0 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -3
- data/lib/octokit/client.rb +4 -0
- data/lib/octokit/client/authorizations.rb +3 -2
- data/lib/octokit/client/commits.rb +1 -1
- data/lib/octokit/client/gists.rb +0 -1
- data/lib/octokit/client/issues.rb +37 -0
- data/lib/octokit/client/milestones.rb +10 -10
- data/lib/octokit/client/organizations.rb +14 -9
- data/lib/octokit/client/pages.rb +27 -1
- data/lib/octokit/client/pull_requests.rb +1 -1
- data/lib/octokit/client/reactions.rb +158 -0
- data/lib/octokit/client/releases.rb +1 -1
- data/lib/octokit/client/repositories.rb +36 -13
- data/lib/octokit/client/repository_invitations.rb +103 -0
- data/lib/octokit/client/source_import.rb +80 -12
- data/lib/octokit/client/stats.rb +1 -1
- data/lib/octokit/default.rb +1 -1
- data/lib/octokit/enterprise_admin_client.rb +2 -0
- data/lib/octokit/error.rb +32 -1
- data/lib/octokit/preview.rb +9 -5
- data/lib/octokit/repository.rb +5 -2
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca949068002176e1c5b3d59da31f46febae73fe5
|
4
|
+
data.tar.gz: 6b58185158a0115d1c2ce3e66ec01899684fb09a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64e36285a18bb0abeebfa514d6edce2fe1045c05e41bff62c96a2d94157e854f1d4cda4d32fd0a666f4cbef5dbcd60eeaf4e1af7b1fb0fb179ae82e4e2577dbf
|
7
|
+
data.tar.gz: 8c5c77fbe09bb78b3f1406e82e3f8e46d8f1cc5b57ad95975ce0d0d2f9dd139cd05f54a71f108ab734010e16e4606ab98bc7db2672c27096ce214597465156d9
|
data/README.md
CHANGED
@@ -8,6 +8,44 @@ Ruby toolkit for the GitHub API.
|
|
8
8
|
Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
9
9
|
[major version][semver].
|
10
10
|
|
11
|
+
## Table of Contents
|
12
|
+
|
13
|
+
1. [Philosophy](#philosophy)
|
14
|
+
2. [Quick start](#quick-start)
|
15
|
+
3. [Making requests](#making-requests)
|
16
|
+
4. [Consuming resources](#consuming-resources)
|
17
|
+
5. [Accessing HTTP responses](#accessing-http-responses)
|
18
|
+
6. [Authentication](#authentication)
|
19
|
+
1. [Basic Authentication](#basic-authentication)
|
20
|
+
2. [OAuth access tokens](#oauth-access-tokens)
|
21
|
+
3. [Two-Factor Authentication](#two-factor-authentication)
|
22
|
+
4. [Using a .netrc file](#using-a-netrc-file)
|
23
|
+
5. [Application authentication](#application-authentication)
|
24
|
+
7. [Pagination](#pagination)
|
25
|
+
1. [Auto pagination](#auto-pagination)
|
26
|
+
8. [Working with GitHub Enterprise](#working-with-github-enterprise)
|
27
|
+
1. [Interacting with the GitHub.com APIs in GitHub Enterprise](#interacting-with-the-githubcom-apis-in-github-enterprise)
|
28
|
+
2. [Interacting with the GitHub Enterprise Admin APIs](#interacting-with-the-github-enterprise-admin-apis)
|
29
|
+
3. [Interacting with the GitHub Enterprise Management Console APIs](#interacting-with-the-github-enterprise-management-console-apis)
|
30
|
+
9. [SSL Connection Errors](#ssl-connection-errors)
|
31
|
+
10. [Configuration and defaults](#configuration-and-defaults)
|
32
|
+
1. [Configuring module defaults](#configuring-module-defaults)
|
33
|
+
2. [Using ENV variables](#using-env-variables)
|
34
|
+
11. [Hypermedia agent](#hypermedia-agent)
|
35
|
+
1. [Hypermedia in Octokit](#hypermedia-in-octokit)
|
36
|
+
2. [URI templates](#uri-templates)
|
37
|
+
3. [The Full Hypermedia Experience™](#the-full-hypermedia-experience)
|
38
|
+
12. [Upgrading guide](#upgrading-guide)
|
39
|
+
1. [Upgrading from 1.x.x](#upgrading-from-1xx)
|
40
|
+
13. [Advanced usage](#advanced-usage)
|
41
|
+
1. [Debugging](#debugging)
|
42
|
+
2. [Caching](#caching)
|
43
|
+
14. [Hacking on Octokit.rb](#hacking-on-octokitrb)
|
44
|
+
1. [Running and writing new tests](#running-and-writing-new-tests)
|
45
|
+
15. [Supported Ruby Versions](#supported-ruby-versions)
|
46
|
+
16. [Versioning](#versioning)
|
47
|
+
17. [License](#license)
|
48
|
+
|
11
49
|
## Philosophy
|
12
50
|
|
13
51
|
API wrappers [should reflect the idioms of the language in which they were
|
@@ -279,7 +317,7 @@ The GitHub Enterprise Admin APIs are under a different client: `EnterpriseAdminC
|
|
279
317
|
``` ruby
|
280
318
|
admin_client = Octokit::EnterpriseAdminClient.new \
|
281
319
|
:access_token => "<your 40 char token>",
|
282
|
-
:api_endpoint
|
320
|
+
:api_endpoint => "https://<hostname>/api/v3/"
|
283
321
|
|
284
322
|
# or
|
285
323
|
Octokit.configure do |c|
|
@@ -433,7 +471,7 @@ pass `state` in the method options.
|
|
433
471
|
- adds support for new [Enterprise-only APIs](#working-with-github-enterprise).
|
434
472
|
- adds support for [Repository redirects][redirects].
|
435
473
|
|
436
|
-
[list-pulls]: https://github.com/octokit/octokit.rb/commit/e48e91f736d5fce51e3bf74d7c9022aaa52f5c5c
|
474
|
+
[list-pulls]: https://github.com/octokit/octokit.rb/commit/e48e91f736d5fce51e3bf74d7c9022aaa52f5c5c
|
437
475
|
[redirects]: https://developer.github.com/changes/2015-05-26-repository-redirects-are-coming/
|
438
476
|
|
439
477
|
Version 3.0 includes a couple breaking changes when upgrading from v2.x.x:
|
@@ -528,7 +566,7 @@ Next, construct your own Faraday middleware:
|
|
528
566
|
|
529
567
|
```ruby
|
530
568
|
stack = Faraday::RackBuilder.new do |builder|
|
531
|
-
builder.use Faraday::HttpCache
|
569
|
+
builder.use Faraday::HttpCache, serializer: Marshal, shared_cache: false
|
532
570
|
builder.use Octokit::Response::RaiseError
|
533
571
|
builder.adapter Faraday.default_adapter
|
534
572
|
end
|
@@ -614,6 +652,7 @@ implementations:
|
|
614
652
|
* Ruby 2.0
|
615
653
|
* Ruby 2.1
|
616
654
|
* Ruby 2.2
|
655
|
+
* Ruby 2.3
|
617
656
|
|
618
657
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
619
658
|
|
data/lib/octokit/client.rb
CHANGED
@@ -36,9 +36,11 @@ require 'octokit/client/pages'
|
|
36
36
|
require 'octokit/client/pub_sub_hubbub'
|
37
37
|
require 'octokit/client/pull_requests'
|
38
38
|
require 'octokit/client/rate_limit'
|
39
|
+
require 'octokit/client/reactions'
|
39
40
|
require 'octokit/client/refs'
|
40
41
|
require 'octokit/client/releases'
|
41
42
|
require 'octokit/client/repositories'
|
43
|
+
require 'octokit/client/repository_invitations'
|
42
44
|
require 'octokit/client/say'
|
43
45
|
require 'octokit/client/search'
|
44
46
|
require 'octokit/client/service_status'
|
@@ -85,9 +87,11 @@ module Octokit
|
|
85
87
|
include Octokit::Client::PubSubHubbub
|
86
88
|
include Octokit::Client::PullRequests
|
87
89
|
include Octokit::Client::RateLimit
|
90
|
+
include Octokit::Client::Reactions
|
88
91
|
include Octokit::Client::Refs
|
89
92
|
include Octokit::Client::Releases
|
90
93
|
include Octokit::Client::Repositories
|
94
|
+
include Octokit::Client::RepositoryInvitations
|
91
95
|
include Octokit::Client::Say
|
92
96
|
include Octokit::Client::Search
|
93
97
|
include Octokit::Client::ServiceStatus
|
@@ -230,10 +230,11 @@ module Octokit
|
|
230
230
|
raise Octokit::ApplicationCredentialsRequired.new "client_id required"
|
231
231
|
end
|
232
232
|
authorize_url = options.delete(:endpoint) || Octokit.web_endpoint
|
233
|
-
authorize_url
|
233
|
+
authorize_url << "login/oauth/authorize?client_id=#{app_id}"
|
234
234
|
|
235
|
+
require 'cgi'
|
235
236
|
options.each do |key, value|
|
236
|
-
authorize_url
|
237
|
+
authorize_url << "&#{key}=#{CGI.escape value}"
|
237
238
|
end
|
238
239
|
|
239
240
|
authorize_url
|
@@ -126,7 +126,7 @@ module Octokit
|
|
126
126
|
# @return [Array<Sawyer::Resource>] An array of hashes representing commits
|
127
127
|
# @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
|
128
128
|
# @example
|
129
|
-
# Octokit.
|
129
|
+
# Octokit.commits_between('octokit/octokit.rb', '2012-10-01', '2012-11-01')
|
130
130
|
def commits_between(*args)
|
131
131
|
arguments = Octokit::RepoArguments.new(args)
|
132
132
|
date = parse_date(arguments.shift)
|
data/lib/octokit/client/gists.rb
CHANGED
@@ -75,7 +75,6 @@ module Octokit
|
|
75
75
|
#
|
76
76
|
# @param options [Hash] Gist information.
|
77
77
|
# @option options [String] :description
|
78
|
-
# @option options [Boolean] :public Sets gist visibility
|
79
78
|
# @option options [Hash] :files Files that make up this gist. Keys
|
80
79
|
# should be the filename, the value a Hash with a :content key with text
|
81
80
|
# content of the Gist.
|
@@ -146,6 +146,30 @@ module Octokit
|
|
146
146
|
patch "#{Repository.path repo}/issues/#{number}", options.merge({:state => "open"})
|
147
147
|
end
|
148
148
|
|
149
|
+
# Lock an issue's conversation, limiting it to collaborators
|
150
|
+
#
|
151
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
152
|
+
# @param number [Integer] Number ID of the issue
|
153
|
+
# @return [Boolean] Success
|
154
|
+
# @see https://developer.github.com/v3/issues/#lock-an-issue
|
155
|
+
# @example Lock Issue #25 from octokit/octokit.rb
|
156
|
+
# Octokit.lock_issue("octokit/octokit.rb", "25")
|
157
|
+
def lock_issue(repo, number, options = {})
|
158
|
+
boolean_from_response :put, "#{Repository.path repo}/issues/#{number}/lock", options
|
159
|
+
end
|
160
|
+
|
161
|
+
# Unlock an issue's conversation, opening it to all viewers
|
162
|
+
#
|
163
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
164
|
+
# @param number [Integer] Number ID of the issue
|
165
|
+
# @return [Boolean] Success
|
166
|
+
# @see https://developer.github.com/v3/issues/#unlock-an-issue
|
167
|
+
# @example Unlock Issue #25 from octokit/octokit.rb
|
168
|
+
# Octokit.close_issue("octokit/octokit.rb", "25")
|
169
|
+
def unlock_issue(repo, number, options = {})
|
170
|
+
boolean_from_response :delete, "#{Repository.path repo}/issues/#{number}/lock", options
|
171
|
+
end
|
172
|
+
|
149
173
|
# Update an issue
|
150
174
|
#
|
151
175
|
# @overload update_issue(repo, number, title, body, options)
|
@@ -279,6 +303,19 @@ module Octokit
|
|
279
303
|
def delete_comment(repo, number, options = {})
|
280
304
|
boolean_from_response :delete, "#{Repository.path repo}/issues/comments/#{number}", options
|
281
305
|
end
|
306
|
+
|
307
|
+
# Get the timeline for an issue
|
308
|
+
#
|
309
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
310
|
+
# @param number [Integer] Number ID of the comment
|
311
|
+
# @return [Sawyer::Resource] The timeline for this issue
|
312
|
+
# @see https://developer.github.com/v3/issues/timeline/
|
313
|
+
# @example Get timeline for issue #1435 on octokit/octokit.rb
|
314
|
+
# Octokit.issue_timeline("octokit/octokit.rb", 1435)
|
315
|
+
def issue_timeline(repo, number, options = {})
|
316
|
+
options = ensure_api_media_type(:issue_timelines, options)
|
317
|
+
paginate "#{Repository.path repo}/issues/#{number}/timeline", options
|
318
|
+
end
|
282
319
|
end
|
283
320
|
end
|
284
321
|
end
|
@@ -8,7 +8,7 @@ module Octokit
|
|
8
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 "
|
22
|
+
paginate "#{Repository.path repository}/milestones", options
|
23
23
|
end
|
24
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 "
|
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 "
|
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 "
|
69
|
+
patch "#{Repository.path repository}/milestones/#{number}", options
|
70
70
|
end
|
71
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, "
|
83
|
+
boolean_from_response :delete, "#{Repository.path repository}/milestones/#{number}", options
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -230,21 +230,17 @@ module Octokit
|
|
230
230
|
# @param org [String, Integer] Organization GitHub login or id.
|
231
231
|
# @option options [String] :name Team name.
|
232
232
|
# @option options [Array<String>] :repo_names Repositories for the team.
|
233
|
-
# @option options [String, optional] :permission ('pull') Permissions the
|
234
|
-
# team has for team repositories.
|
235
|
-
#
|
236
|
-
# `pull` - team members can pull, but not push to or administer these repositories.
|
237
|
-
# `push` - team members can pull and push, but not administer these repositories.
|
238
|
-
# `admin` - team members can pull, push and administer these repositories.
|
239
233
|
# @return [Sawyer::Resource] Hash representing new team.
|
240
234
|
# @see https://developer.github.com/v3/orgs/teams/#create-team
|
241
235
|
# @example
|
242
236
|
# @client.create_team('github', {
|
243
237
|
# :name => 'Designers',
|
244
|
-
# :repo_names => ['github/dotfiles']
|
245
|
-
# :permission => 'push'
|
238
|
+
# :repo_names => ['github/dotfiles']
|
246
239
|
# })
|
247
240
|
def create_team(org, options = {})
|
241
|
+
if options.key?(:permission)
|
242
|
+
octokit_warn "Deprecated: Passing :permission option to #create_team. Assign team repository permission by passing :permission to #add_team_repository instead."
|
243
|
+
end
|
248
244
|
post "#{Organization.path org}/teams", options
|
249
245
|
end
|
250
246
|
|
@@ -406,19 +402,28 @@ module Octokit
|
|
406
402
|
|
407
403
|
# Add team repository
|
408
404
|
#
|
405
|
+
# This can also be used to update the permission of an existing team
|
406
|
+
#
|
409
407
|
# Requires authenticated user to be an owner of the organization that the
|
410
408
|
# team is associated with. Also, the repo must be owned by the
|
411
409
|
# organization, or a direct form of a repo owned by the organization.
|
412
410
|
#
|
413
411
|
# @param team_id [Integer] Team id.
|
414
412
|
# @param repo [String, Hash, Repository] A GitHub repository.
|
413
|
+
# @option options [String] :permission The permission to grant the team.
|
414
|
+
# Only valid on organization-owned repositories.
|
415
|
+
# Can be one of: <tt>pull</tt>, <tt>push</tt>, or <tt>admin</tt>.
|
416
|
+
# If not specified, the team's <tt>permission</tt> attribute will be
|
417
|
+
# used to determine what permission to grant the team on this repository.
|
415
418
|
# @return [Boolean] True if successful, false otherwise.
|
416
419
|
# @see Octokit::Repository
|
417
|
-
# @see https://developer.github.com/v3/orgs/teams/#add-team-repository
|
420
|
+
# @see https://developer.github.com/v3/orgs/teams/#add-or-update-team-repository
|
418
421
|
# @example
|
419
422
|
# @client.add_team_repository(100000, 'github/developer.github.com')
|
420
423
|
# @example
|
421
424
|
# @client.add_team_repo(100000, 'github/developer.github.com')
|
425
|
+
# @example Add a team with admin permissions
|
426
|
+
# @client.add_team_repository(100000, 'github/developer.github.com', permission: 'admin')
|
422
427
|
def add_team_repository(team_id, repo, options = {})
|
423
428
|
boolean_from_response :put, "teams/#{team_id}/repos/#{Repository.new(repo)}", options.merge(:name => Repository.new(repo))
|
424
429
|
end
|
data/lib/octokit/client/pages.rb
CHANGED
@@ -12,7 +12,21 @@ module Octokit
|
|
12
12
|
# @return Sawyer::Resource A GitHub Pages resource
|
13
13
|
# @see https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site
|
14
14
|
def pages(repo, options = {})
|
15
|
-
|
15
|
+
opts = ensure_api_media_type(:pages, options)
|
16
|
+
get "#{Repository.path repo}/pages", opts
|
17
|
+
end
|
18
|
+
|
19
|
+
# Get a specific Pages build by ID
|
20
|
+
#
|
21
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
22
|
+
# @param id [Integer, String] Build ID
|
23
|
+
# @return [Sawyer::Resource] Pages build information
|
24
|
+
# @see https://developer.github.com/v3/repos/pages/#list-a-specific-pages-build
|
25
|
+
# @example
|
26
|
+
# Octokit.pages_build("github/developer.github.com", 5472601)
|
27
|
+
def pages_build(repo, id, options = {})
|
28
|
+
opts = ensure_api_media_type(:pages, options)
|
29
|
+
get "#{Repository.path repo}/pages/builds/#{id}", opts
|
16
30
|
end
|
17
31
|
|
18
32
|
# List Pages builds for a repository
|
@@ -33,6 +47,18 @@ module Octokit
|
|
33
47
|
def latest_pages_build(repo, options = {})
|
34
48
|
get "#{Repository.path repo}/pages/builds/latest", options
|
35
49
|
end
|
50
|
+
|
51
|
+
# Request a page build for the latest revision of the default branch
|
52
|
+
#
|
53
|
+
# You can only request builds for your repositories
|
54
|
+
#
|
55
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
56
|
+
# @return [Sawyer::Resource] Request result
|
57
|
+
# @see https://developer.github.com/v3/repos/pages/#request-a-page-build
|
58
|
+
def request_page_build(repo, options = {})
|
59
|
+
opts = ensure_api_media_type(:pages, options)
|
60
|
+
post "#{Repository.path repo}/pages/builds", opts
|
61
|
+
end
|
36
62
|
end
|
37
63
|
end
|
38
64
|
end
|
@@ -222,7 +222,7 @@ module Octokit
|
|
222
222
|
# @return [Sawyer::Resource] Hash representing new comment
|
223
223
|
# @see https://developer.github.com/v3/pulls/comments/#create-a-comment
|
224
224
|
# @example
|
225
|
-
# @client.create_pull_request_comment_reply("octokit/octokit.rb",
|
225
|
+
# @client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)
|
226
226
|
def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})
|
227
227
|
options.merge!({
|
228
228
|
:body => body,
|
@@ -0,0 +1,158 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Methods for the Reacions API
|
5
|
+
#
|
6
|
+
# @see https://developer.github.com/v3/reactions/
|
7
|
+
module Reactions
|
8
|
+
|
9
|
+
# List reactions for a commit comment
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @param id [Integer] The id of the commit comment
|
13
|
+
# @see https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# @client.commit_comment_reactions("octokit/octokit.rb", 1)
|
17
|
+
#
|
18
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
19
|
+
def commit_comment_reactions(repo, id, options = {})
|
20
|
+
options = ensure_api_media_type(:reactions, options)
|
21
|
+
get "#{Repository.path repo}/comments/#{id}/reactions", options
|
22
|
+
end
|
23
|
+
|
24
|
+
# Create a reaction for a commit comment
|
25
|
+
#
|
26
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
27
|
+
# @param id [Integer] The id of the commit comment
|
28
|
+
# @param reaction [String] The Reaction
|
29
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment
|
30
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# @client.create_commit_comment_reactions("octokit/octokit.rb", 1)
|
34
|
+
#
|
35
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction
|
36
|
+
def create_commit_comment_reaction(repo, id, reaction, options = {})
|
37
|
+
options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
|
38
|
+
post "#{Repository.path repo}/comments/#{id}/reactions", options
|
39
|
+
end
|
40
|
+
|
41
|
+
# List reactions for an issue
|
42
|
+
#
|
43
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
44
|
+
# @param number [Integer] The Issue number
|
45
|
+
# @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# @client.issue_reactions("octokit/octokit.rb", 1)
|
49
|
+
#
|
50
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
51
|
+
def issue_reactions(repo, number, options = {})
|
52
|
+
options = ensure_api_media_type(:reactions, options)
|
53
|
+
get "#{Repository.path repo}/issues/#{number}/reactions", options
|
54
|
+
end
|
55
|
+
|
56
|
+
# Create reaction for an issue
|
57
|
+
#
|
58
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
59
|
+
# @param number [Integer] The Issue number
|
60
|
+
# @param reaction [String] The Reaction
|
61
|
+
#
|
62
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue
|
63
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
64
|
+
#
|
65
|
+
# @example
|
66
|
+
# @client.create_issue_reaction("octokit/octokit.rb", 1)
|
67
|
+
#
|
68
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
69
|
+
def create_issue_reaction(repo, number, reaction, options = {})
|
70
|
+
options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
|
71
|
+
post "#{Repository.path repo}/issues/#{number}/reactions", options
|
72
|
+
end
|
73
|
+
|
74
|
+
# List reactions for an issue comment
|
75
|
+
#
|
76
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
77
|
+
# @param id [Integer] The Issue comment id
|
78
|
+
#
|
79
|
+
# @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment
|
80
|
+
#
|
81
|
+
# @example
|
82
|
+
# @client.issue_comment_reactions("octokit/octokit.rb", 1)
|
83
|
+
#
|
84
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
85
|
+
def issue_comment_reactions(repo, id, options = {})
|
86
|
+
options = ensure_api_media_type(:reactions, options)
|
87
|
+
get "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
88
|
+
end
|
89
|
+
|
90
|
+
# Create reaction for an issue comment
|
91
|
+
#
|
92
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
93
|
+
# @param id [Integer] The Issue comment id
|
94
|
+
# @param reaction [String] The Reaction
|
95
|
+
#
|
96
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment
|
97
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
98
|
+
#
|
99
|
+
# @example
|
100
|
+
# @client.create_issue_comment_reaction("octokit/octokit.rb", 1)
|
101
|
+
#
|
102
|
+
# @return [<Sawyer::Resource>] Hashes representing the reaction.
|
103
|
+
def create_issue_comment_reaction(repo, id, reaction, options = {})
|
104
|
+
options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
|
105
|
+
post "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
106
|
+
end
|
107
|
+
|
108
|
+
# List reactions for a pull request review comment
|
109
|
+
#
|
110
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
111
|
+
# @param id [Integer] The Issue comment id
|
112
|
+
#
|
113
|
+
# @see https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# @client.pull_request_review_comment_reactions("octokit/octokit.rb", 1)
|
117
|
+
#
|
118
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
119
|
+
def pull_request_review_comment_reactions(repo, id, options = {})
|
120
|
+
options = ensure_api_media_type(:reactions, options)
|
121
|
+
get "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
122
|
+
end
|
123
|
+
|
124
|
+
# Create reaction for a pull request review comment
|
125
|
+
#
|
126
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
127
|
+
# @param id [Integer] The Issue comment id
|
128
|
+
# @param reaction [String] The Reaction
|
129
|
+
#
|
130
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment
|
131
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
132
|
+
#
|
133
|
+
# @example
|
134
|
+
# @client.create_pull_request_reiew_comment_reaction("octokit/octokit.rb", 1)
|
135
|
+
#
|
136
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
137
|
+
def create_pull_request_review_comment_reaction(repo, id, reaction, options = {})
|
138
|
+
options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
|
139
|
+
post "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
140
|
+
end
|
141
|
+
|
142
|
+
# Delete a reaction
|
143
|
+
#
|
144
|
+
# @param id [Integer] Reaction id
|
145
|
+
#
|
146
|
+
# @see https://developer.github.com/v3/reactions/#delete-a-reaction
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# @client.delete_reaction(1)
|
150
|
+
#
|
151
|
+
# @return [Boolean] Return true if reaction was deleted, false otherwise.
|
152
|
+
def delete_reaction(id, options = {})
|
153
|
+
options = ensure_api_media_type(:reactions, options)
|
154
|
+
boolean_from_response :delete, "reactions/#{id}", options
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -83,7 +83,7 @@ module Octokit
|
|
83
83
|
# @return [Sawyer::Resource] The release asset
|
84
84
|
# @see https://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
85
85
|
def upload_asset(release_url, path_or_file, options = {})
|
86
|
-
file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, "
|
86
|
+
file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, "rb")
|
87
87
|
options[:content_type] ||= content_type_from_file(file)
|
88
88
|
raise Octokit::MissingContentType.new if options[:content_type].nil?
|
89
89
|
unless name = options[:name]
|
@@ -152,13 +152,14 @@ module Octokit
|
|
152
152
|
# @return [Sawyer::Resource] Repository info for the new repository
|
153
153
|
# @see https://developer.github.com/v3/repos/#create
|
154
154
|
def create_repository(name, options = {})
|
155
|
-
|
156
|
-
|
155
|
+
opts = options.dup
|
156
|
+
organization = opts.delete :organization
|
157
|
+
opts.merge! :name => name
|
157
158
|
|
158
159
|
if organization.nil?
|
159
|
-
post 'user/repos',
|
160
|
+
post 'user/repos', opts
|
160
161
|
else
|
161
|
-
post "#{Organization.path organization}/repos",
|
162
|
+
post "#{Organization.path organization}/repos", opts
|
162
163
|
end
|
163
164
|
end
|
164
165
|
alias :create_repo :create_repository
|
@@ -291,16 +292,24 @@ module Octokit
|
|
291
292
|
|
292
293
|
# Add collaborator to repo
|
293
294
|
#
|
295
|
+
# This can also be used to update the permission of an existing collaborator
|
296
|
+
#
|
294
297
|
# Requires authenticated client.
|
295
298
|
#
|
296
299
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
297
300
|
# @param collaborator [String] Collaborator GitHub username to add.
|
301
|
+
# @option options [String] :permission The permission to grant the collaborator.
|
302
|
+
# Only valid on organization-owned repositories.
|
303
|
+
# Can be one of: <tt>pull</tt>, <tt>push</tt>, or <tt>admin</tt>.
|
304
|
+
# If not specified, defaults to <tt>push</tt>
|
298
305
|
# @return [Boolean] True if collaborator added, false otherwise.
|
299
306
|
# @see https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
|
300
307
|
# @example
|
301
308
|
# @client.add_collaborator('octokit/octokit.rb', 'holman')
|
302
309
|
# @example
|
303
310
|
# @client.add_collab('octokit/octokit.rb', 'holman')
|
311
|
+
# @example Add a collaborator with admin permissions
|
312
|
+
# @client.add_collaborator('octokit/octokit.rb', 'holman', permission: 'admin')
|
304
313
|
def add_collaborator(repo, collaborator, options = {})
|
305
314
|
boolean_from_response :put, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
306
315
|
end
|
@@ -496,14 +505,29 @@ module Octokit
|
|
496
505
|
# @example
|
497
506
|
# @client.protect_branch('octokit/octokit.rb', 'master', foo)
|
498
507
|
def protect_branch(repo, branch, required_status_checks = {}, options = {})
|
499
|
-
|
500
|
-
|
501
|
-
end
|
508
|
+
required_status_checks[:restrictions] ||= nil
|
509
|
+
required_status_checks[:required_status_checks] ||= nil
|
502
510
|
|
503
|
-
|
504
|
-
|
511
|
+
options = ensure_api_media_type(:branch_protection, options.merge(required_status_checks))
|
512
|
+
put "#{Repository.path repo}/branches/#{branch}/protection", options
|
513
|
+
end
|
505
514
|
|
506
|
-
|
515
|
+
# Get branch protection summary
|
516
|
+
#
|
517
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
518
|
+
# @param branch [String] Branch name
|
519
|
+
# @return [Sawyer::Resource, nil] Branch protection summary or nil if the branch
|
520
|
+
# is not protected
|
521
|
+
# @see https://developer.github.com/v3/repos/branches/#get-branch-protection
|
522
|
+
# @example
|
523
|
+
# @client.branch_protection('octokit/octokit.rb', 'master')
|
524
|
+
def branch_protection(repo, branch, options = {})
|
525
|
+
opts = ensure_api_media_type(:branch_protection, options)
|
526
|
+
begin
|
527
|
+
get "#{Repository.path repo}/branches/#{branch}/protection", opts
|
528
|
+
rescue Octokit::BranchNotProtected
|
529
|
+
nil
|
530
|
+
end
|
507
531
|
end
|
508
532
|
|
509
533
|
# Unlock a single branch from a repository
|
@@ -517,9 +541,8 @@ module Octokit
|
|
517
541
|
# @example
|
518
542
|
# @client.unprotect_branch('octokit/octokit.rb', 'master')
|
519
543
|
def unprotect_branch(repo, branch, options = {})
|
520
|
-
|
521
|
-
|
522
|
-
patch "#{Repository.path repo}/branches/#{branch}", options
|
544
|
+
options = ensure_api_media_type(:branch_protection, options)
|
545
|
+
delete "#{Repository.path repo}/branches/#{branch}/protection", options
|
523
546
|
end
|
524
547
|
|
525
548
|
# List users available for assigning to issues.
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Octokit
|
2
|
+
class Client
|
3
|
+
|
4
|
+
# Methods for the Repository Invitations API
|
5
|
+
#
|
6
|
+
# @see https://developer.github.com/v3/repos/invitations/
|
7
|
+
module RepositoryInvitations
|
8
|
+
|
9
|
+
# Invite a user to a repository
|
10
|
+
#
|
11
|
+
# Requires authenticated client
|
12
|
+
#
|
13
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
14
|
+
# @param user [String] User GitHub username to add
|
15
|
+
# @return [Sawyer::Resource] The repository invitation
|
16
|
+
# @see https://developer.github.com/v3/repos/invitations/#invite-a-user-to-a-repository
|
17
|
+
def invite_user_to_repository(repo, user, options = {})
|
18
|
+
options = ensure_api_media_type(:repository_invitations, options)
|
19
|
+
put "#{Repository.path repo}/collaborators/#{user}", options
|
20
|
+
end
|
21
|
+
alias invite_user_to_repo invite_user_to_repository
|
22
|
+
|
23
|
+
# List all invitations for a repository
|
24
|
+
#
|
25
|
+
# Requires authenticated client
|
26
|
+
#
|
27
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
28
|
+
# @return [Array<Sawyer::Resource>] A list of invitations
|
29
|
+
# @see https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository
|
30
|
+
def repository_invitations(repo, options = {})
|
31
|
+
options = ensure_api_media_type(:repository_invitations, options)
|
32
|
+
paginate "#{Repository.path repo}/invitations", options
|
33
|
+
end
|
34
|
+
alias repo_invitations repository_invitations
|
35
|
+
|
36
|
+
# Delete an invitation for a repository
|
37
|
+
#
|
38
|
+
# Requires authenticated client
|
39
|
+
#
|
40
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
41
|
+
# @param invitation_id [Integer] The id of the invitation
|
42
|
+
# @return [Boolean] True if the invitation was successfully deleted
|
43
|
+
# @see https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation
|
44
|
+
def delete_repository_invitation(repo, invitation_id, options = {})
|
45
|
+
options = ensure_api_media_type(:repository_invitations, options)
|
46
|
+
boolean_from_response :delete, "#{Repository.path repo}/invitations/#{invitation_id}", options
|
47
|
+
end
|
48
|
+
alias delete_repo_invitation delete_repository_invitation
|
49
|
+
|
50
|
+
# Update an invitation for a repository
|
51
|
+
#
|
52
|
+
# Requires authenticated client
|
53
|
+
#
|
54
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
55
|
+
# @param invitation_id [Integer] The id of the invitation
|
56
|
+
# @return [Sawyer::Resource] The updated repository invitation
|
57
|
+
# @see https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation
|
58
|
+
def update_repository_invitation(repo, invitation_id, options = {})
|
59
|
+
options = ensure_api_media_type(:repository_invitations, options)
|
60
|
+
patch "#{Repository.path repo}/invitations/#{invitation_id}", options
|
61
|
+
end
|
62
|
+
alias update_repo_invitation update_repository_invitation
|
63
|
+
|
64
|
+
# List all repository invitations for the user
|
65
|
+
#
|
66
|
+
# Requires authenticated client
|
67
|
+
#
|
68
|
+
# @return [Array<Sawyer::Resource>] The users repository invitations
|
69
|
+
# @see https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations
|
70
|
+
def user_repository_invitations(options = {})
|
71
|
+
options = ensure_api_media_type(:repository_invitations, options)
|
72
|
+
paginate "/user/repository_invitations", options
|
73
|
+
end
|
74
|
+
alias user_repo_invitations user_repository_invitations
|
75
|
+
|
76
|
+
# Accept a repository invitation
|
77
|
+
#
|
78
|
+
# Requires authenticated client
|
79
|
+
#
|
80
|
+
# @param invitation_id [Integer] The id of the invitation
|
81
|
+
# @return [Boolean] True if the acceptance of the invitation was successful
|
82
|
+
# @see https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation
|
83
|
+
def accept_repository_invitation(invitation_id, options = {})
|
84
|
+
options = ensure_api_media_type(:repository_invitations, options)
|
85
|
+
patch "/user/repository_invitations/#{invitation_id}", options
|
86
|
+
end
|
87
|
+
alias accept_repo_invitation accept_repository_invitation
|
88
|
+
|
89
|
+
# Decline a repository invitation
|
90
|
+
#
|
91
|
+
# Requires authenticated client
|
92
|
+
#
|
93
|
+
# @param invitation_id [Integer] The id of the invitation
|
94
|
+
# @return [Boolean] True if the acceptance of the invitation was successful
|
95
|
+
# @see https://developer.github.com/v3/repos/invitations/#decline-a-repository-invitation
|
96
|
+
def decline_repository_invitation(invitation_id, options = {})
|
97
|
+
options = ensure_api_media_type(:repository_invitations, options)
|
98
|
+
boolean_from_response :delete, "/user/repository_invitations/#{invitation_id}", options
|
99
|
+
end
|
100
|
+
alias decline_invitation decline_repository_invitation
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -3,29 +3,47 @@ module Octokit
|
|
3
3
|
|
4
4
|
# Methods for the Source Import API
|
5
5
|
#
|
6
|
-
# @see https://developer.github.com/v3/
|
6
|
+
# @see https://developer.github.com/v3/migration/source_imports
|
7
7
|
module SourceImport
|
8
8
|
|
9
9
|
# Start a source import to a GitHub repository using GitHub Importer.
|
10
10
|
#
|
11
|
-
# @
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
11
|
+
# @overload start_source_import(repo, vcs, vcs_url, options = {})
|
12
|
+
# @deprecated
|
13
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
14
|
+
# @param vcs [String] The originating VCS type. Can be one of "subversion", "git", "mercurial", or "tfvc".
|
15
|
+
# @param vcs_url [String] The URL of the originating repository.
|
16
|
+
# @param options [Hash]
|
17
|
+
# @option options [String] :vcs_username If authentication is required, the username to provide to vcs_url.
|
18
|
+
# @option options [String] :vcs_password If authentication is required, the password to provide to vcs_url.
|
19
|
+
# @option options [String] :tfvc_project For a tfvc import, the name of the project that is being imported.
|
20
|
+
# @overload start_source_import(repo, vcs_url, options = {})
|
21
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
22
|
+
# @param vcs_url [String] The URL of the originating repository.
|
23
|
+
# @param options [Hash]
|
24
|
+
# @param options [String] :vcs The originating VCS type. Can be one of "subversion", "git", "mercurial", or "tfvc".
|
25
|
+
# @option options [String] :vcs_username If authentication is required, the username to provide to vcs_url.
|
26
|
+
# @option options [String] :vcs_password If authentication is required, the password to provide to vcs_url.
|
27
|
+
# @option options [String] :tfvc_project For a tfvc import, the name of the project that is being imported.
|
18
28
|
# @return [Sawyer::Resource] Hash representing the repository import
|
19
29
|
# @see https://developer.github.com/v3/migration/source_imports/#start-an-import
|
20
30
|
#
|
21
31
|
# @example
|
22
|
-
# @client.
|
32
|
+
# @client.start_source_import("octokit/octokit.rb", "http://svn.mycompany.com/svn/myproject", {
|
33
|
+
# :vcs => "subversion",
|
23
34
|
# :vcs_username" => "octocat",
|
24
35
|
# :vcs_password => "secret"
|
25
36
|
# })
|
26
|
-
def start_source_import(
|
27
|
-
|
28
|
-
|
37
|
+
def start_source_import(*args)
|
38
|
+
arguments = Octokit::RepoArguments.new(args)
|
39
|
+
vcs_url = arguments.pop
|
40
|
+
vcs = arguments.pop
|
41
|
+
if vcs
|
42
|
+
octokit_warn "Octokit#start_source_import vcs parameter is now an option, please update your call before the next major Octokit version update."
|
43
|
+
arguments.options.merge!(:vcs => vcs)
|
44
|
+
end
|
45
|
+
options = ensure_api_media_type(:source_imports, arguments.options.merge(:vcs_url => vcs_url))
|
46
|
+
put "#{Repository.path arguments.repo}/import", options
|
29
47
|
end
|
30
48
|
|
31
49
|
# View the progress of an import.
|
@@ -41,6 +59,27 @@ module Octokit
|
|
41
59
|
get "#{Repository.path repo}/import", options
|
42
60
|
end
|
43
61
|
|
62
|
+
# Update source import with authentication or project choice
|
63
|
+
# Restart source import if no options are passed
|
64
|
+
#
|
65
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
66
|
+
# @return [Sawyer::Resource] Hash representing the repository import
|
67
|
+
# @see https://developer.github.com/v3/migration/source_imports/#update-existing-import
|
68
|
+
# @option options [String] :vcs_username If authentication is required, the username to provide to vcs_url.
|
69
|
+
# @option options [String] :vcs_password If authentication is required, the password to provide to vcs_url.
|
70
|
+
# @option options [String] To update project choice, please refer to the project_choice array from the progress return hash for the exact attributes.
|
71
|
+
# https://developer.github.com/v3/migration/source_imports/#update-existing-import
|
72
|
+
#
|
73
|
+
# @example
|
74
|
+
# @client.update_source_import("octokit/octokit.rb", {
|
75
|
+
# :vcs_username" => "octocat",
|
76
|
+
# :vcs_password => "secret"
|
77
|
+
# })
|
78
|
+
def update_source_import(repo, options = {})
|
79
|
+
options = ensure_api_media_type(:source_imports, options)
|
80
|
+
patch "#{Repository.path repo}/import", options
|
81
|
+
end
|
82
|
+
|
44
83
|
# List source import commit authors
|
45
84
|
#
|
46
85
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
@@ -88,6 +127,35 @@ module Octokit
|
|
88
127
|
options = ensure_api_media_type(:source_imports, options)
|
89
128
|
boolean_from_response :delete, "#{Repository.path repo}/import", options
|
90
129
|
end
|
130
|
+
|
131
|
+
# List source import large files
|
132
|
+
#
|
133
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
134
|
+
# @param options [Hash]
|
135
|
+
# @option options [Fixnum] :page Page of paginated results
|
136
|
+
# @return [Array<Sawyer::Resource>] Array of hashes representing files over 100MB.
|
137
|
+
# @see https://developer.github.com/v3/migration/source_imports/#get-large-files
|
138
|
+
#
|
139
|
+
# @example
|
140
|
+
# @client.source_import_large_files("octokit/octokit.rb")
|
141
|
+
def source_import_large_files(repo, options = {})
|
142
|
+
options = ensure_api_media_type(:source_imports, options)
|
143
|
+
get "#{Repository.path repo}/import/large_files", options
|
144
|
+
end
|
145
|
+
|
146
|
+
# Set preference for using Git LFS to import files over 100MB
|
147
|
+
#
|
148
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
149
|
+
# @param use_lfs [String] Preference for using Git LFS to import large files. Can be one of "opt_in" or "opt_out"
|
150
|
+
# @return [Sawyer::Resource] Hash representing the repository import
|
151
|
+
# @see https://developer.github.com/v3/migration/source_imports/#set-git-lfs-preference
|
152
|
+
#
|
153
|
+
# @example
|
154
|
+
# @client.opt_in_source_import_lfs("octokit/octokit.rb", "opt_in")
|
155
|
+
def set_source_import_lfs_preference(repo, use_lfs, options = {})
|
156
|
+
options = ensure_api_media_type(:source_imports, options.merge(:use_lfs => use_lfs))
|
157
|
+
patch "#{Repository.path repo}/import/lfs", options
|
158
|
+
end
|
91
159
|
end
|
92
160
|
end
|
93
161
|
end
|
data/lib/octokit/client/stats.rb
CHANGED
@@ -96,7 +96,7 @@ module Octokit
|
|
96
96
|
data = get("#{Repository.path repo}/stats/#{metric}", options)
|
97
97
|
return data if last_response.status == 200
|
98
98
|
return nil unless retry_timeout
|
99
|
-
return
|
99
|
+
return nil if Time.now >= timeout
|
100
100
|
sleep retry_wait if retry_wait
|
101
101
|
end
|
102
102
|
end
|
data/lib/octokit/default.rb
CHANGED
data/lib/octokit/error.rb
CHANGED
@@ -16,12 +16,13 @@ module Octokit
|
|
16
16
|
when 400 then Octokit::BadRequest
|
17
17
|
when 401 then error_for_401(headers)
|
18
18
|
when 403 then error_for_403(body)
|
19
|
-
when 404 then
|
19
|
+
when 404 then error_for_404(body)
|
20
20
|
when 405 then Octokit::MethodNotAllowed
|
21
21
|
when 406 then Octokit::NotAcceptable
|
22
22
|
when 409 then Octokit::Conflict
|
23
23
|
when 415 then Octokit::UnsupportedMediaType
|
24
24
|
when 422 then Octokit::UnprocessableEntity
|
25
|
+
when 451 then Octokit::UnavailableForLegalReasons
|
25
26
|
when 400..499 then Octokit::ClientError
|
26
27
|
when 500 then Octokit::InternalServerError
|
27
28
|
when 501 then Octokit::NotImplemented
|
@@ -68,11 +69,23 @@ module Octokit
|
|
68
69
|
Octokit::RepositoryUnavailable
|
69
70
|
elsif body =~ /email address must be verified/i
|
70
71
|
Octokit::UnverifiedEmail
|
72
|
+
elsif body =~ /account was suspended/i
|
73
|
+
Octokit::AccountSuspended
|
71
74
|
else
|
72
75
|
Octokit::Forbidden
|
73
76
|
end
|
74
77
|
end
|
75
78
|
|
79
|
+
# Return most appropriate error for 404 HTTP status code
|
80
|
+
# @private
|
81
|
+
def self.error_for_404(body)
|
82
|
+
if body =~ /Branch not protected/i
|
83
|
+
Octokit::BranchNotProtected
|
84
|
+
else
|
85
|
+
Octokit::NotFound
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
76
89
|
# Array of validation errors
|
77
90
|
# @return [Array<Hash>] Error info
|
78
91
|
def errors
|
@@ -83,6 +96,13 @@ module Octokit
|
|
83
96
|
end
|
84
97
|
end
|
85
98
|
|
99
|
+
# Status code returned by the GitHub server.
|
100
|
+
#
|
101
|
+
# @return [Integer]
|
102
|
+
def response_status
|
103
|
+
@response[:status]
|
104
|
+
end
|
105
|
+
|
86
106
|
private
|
87
107
|
|
88
108
|
def data
|
@@ -205,9 +225,17 @@ module Octokit
|
|
205
225
|
# and body matches 'email address must be verified'
|
206
226
|
class UnverifiedEmail < Forbidden; end
|
207
227
|
|
228
|
+
# Raised when GitHub returns a 403 HTTP status code
|
229
|
+
# and body matches 'account was suspended'
|
230
|
+
class AccountSuspended < Forbidden; end
|
231
|
+
|
208
232
|
# Raised when GitHub returns a 404 HTTP status code
|
209
233
|
class NotFound < ClientError; end
|
210
234
|
|
235
|
+
# Raised when GitHub returns a 404 HTTP status code
|
236
|
+
# and body matches 'Branch not protected'
|
237
|
+
class BranchNotProtected < ClientError; end
|
238
|
+
|
211
239
|
# Raised when GitHub returns a 405 HTTP status code
|
212
240
|
class MethodNotAllowed < ClientError; end
|
213
241
|
|
@@ -223,6 +251,9 @@ module Octokit
|
|
223
251
|
# Raised when GitHub returns a 422 HTTP status code
|
224
252
|
class UnprocessableEntity < ClientError; end
|
225
253
|
|
254
|
+
# Raised when GitHub returns a 451 HTTP status code
|
255
|
+
class UnavailableForLegalReasons < ClientError; end
|
256
|
+
|
226
257
|
# Raised on errors in the 500-599 range
|
227
258
|
class ServerError < Error; end
|
228
259
|
|
data/lib/octokit/preview.rb
CHANGED
@@ -4,10 +4,14 @@ module Octokit
|
|
4
4
|
module Preview
|
5
5
|
|
6
6
|
PREVIEW_TYPES = {
|
7
|
-
:branch_protection
|
8
|
-
:migrations
|
9
|
-
:licenses
|
10
|
-
:source_imports
|
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,
|
10
|
+
:source_imports => 'application/vnd.github.barred-rock-preview'.freeze,
|
11
|
+
:reactions => 'application/vnd.github.squirrel-girl-preview'.freeze,
|
12
|
+
:repository_invitations => 'application/vnd.github.swamp-thing-preview+json'.freeze,
|
13
|
+
:issue_timelines => 'application/vnd.github.mockingbird-preview+json'.freeze,
|
14
|
+
:pages => 'application/vnd.github.mister-fantastic-preview+json'.freeze
|
11
15
|
}
|
12
16
|
|
13
17
|
def ensure_api_media_type(type, options)
|
@@ -19,7 +23,7 @@ module Octokit
|
|
19
23
|
end
|
20
24
|
|
21
25
|
def warn_preview(type)
|
22
|
-
|
26
|
+
octokit_warn <<-EOS
|
23
27
|
WARNING: The preview version of the #{type.to_s.capitalize} API is not yet suitable for production use.
|
24
28
|
You can avoid this message by supplying an appropriate media type in the 'Accept' request
|
25
29
|
header.
|
data/lib/octokit/repository.rb
CHANGED
@@ -10,7 +10,10 @@ module Octokit
|
|
10
10
|
#
|
11
11
|
# @return [Repository]
|
12
12
|
def self.from_url(url)
|
13
|
-
|
13
|
+
new URI.parse(url).path[1..-1].
|
14
|
+
gsub(/^repos\//,'').
|
15
|
+
split('/', 3)[0..1].
|
16
|
+
join('/')
|
14
17
|
end
|
15
18
|
|
16
19
|
# @raise [Octokit::InvalidRepository] if the repository
|
@@ -78,7 +81,7 @@ module Octokit
|
|
78
81
|
private
|
79
82
|
|
80
83
|
def validate_owner_and_name!
|
81
|
-
if @owner.include?('/') || @name.include?('/') || !url.match(
|
84
|
+
if @owner.include?('/') || @name.include?('/') || !url.match(URI::ABS_URI)
|
82
85
|
raise_invalid_repository!
|
83
86
|
end
|
84
87
|
end
|
data/lib/octokit/version.rb
CHANGED
data/octokit.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.licenses = ['MIT']
|
16
16
|
spec.name = 'octokit'
|
17
17
|
spec.require_paths = ['lib']
|
18
|
-
spec.required_ruby_version = '>=
|
18
|
+
spec.required_ruby_version = '>= 2.0.0'
|
19
19
|
spec.required_rubygems_version = '>= 1.3.5'
|
20
20
|
spec.summary = "Ruby toolkit for working with the GitHub API"
|
21
21
|
spec.version = Octokit::VERSION.dup
|
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.
|
4
|
+
version: 4.4.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: 2016-
|
13
|
+
date: 2016-10-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -90,9 +90,11 @@ files:
|
|
90
90
|
- lib/octokit/client/pub_sub_hubbub.rb
|
91
91
|
- lib/octokit/client/pull_requests.rb
|
92
92
|
- lib/octokit/client/rate_limit.rb
|
93
|
+
- lib/octokit/client/reactions.rb
|
93
94
|
- lib/octokit/client/refs.rb
|
94
95
|
- lib/octokit/client/releases.rb
|
95
96
|
- lib/octokit/client/repositories.rb
|
97
|
+
- lib/octokit/client/repository_invitations.rb
|
96
98
|
- lib/octokit/client/say.rb
|
97
99
|
- lib/octokit/client/search.rb
|
98
100
|
- lib/octokit/client/service_status.rb
|
@@ -137,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
139
|
requirements:
|
138
140
|
- - ">="
|
139
141
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
142
|
+
version: 2.0.0
|
141
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
144
|
requirements:
|
143
145
|
- - ">="
|