octokit 4.15.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +2 -4
- data/README.md +104 -80
- data/Rakefile +5 -3
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +12 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +59 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +125 -0
- data/lib/octokit/client/actions_workflows.rb +68 -0
- data/lib/octokit/client/apps.rb +53 -53
- data/lib/octokit/client/checks.rb +18 -29
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +2 -2
- data/lib/octokit/client/commits.rb +31 -34
- data/lib/octokit/client/community_profile.rb +2 -3
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/deployments.rb +16 -6
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +6 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +9 -19
- data/lib/octokit/client/issues.rb +14 -15
- data/lib/octokit/client/labels.rb +10 -10
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +3 -6
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +4 -4
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +5 -5
- data/lib/octokit/client/notifications.rb +6 -6
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +112 -70
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +44 -64
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +52 -42
- data/lib/octokit/client/rate_limit.rb +9 -11
- data/lib/octokit/client/reactions.rb +6 -11
- data/lib/octokit/client/refs.rb +32 -19
- data/lib/octokit/client/releases.rb +13 -13
- data/lib/octokit/client/repositories.rb +123 -69
- data/lib/octokit/client/repository_invitations.rb +3 -3
- data/lib/octokit/client/reviews.rb +7 -7
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +24 -11
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +7 -12
- data/lib/octokit/client/stats.rb +10 -9
- data/lib/octokit/client/statuses.rb +5 -5
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +104 -24
- data/lib/octokit/client.rb +44 -18
- data/lib/octokit/configurable.rb +34 -30
- data/lib/octokit/connection.rb +28 -26
- data/lib/octokit/default.rb +46 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
- data/lib/octokit/enterprise_admin_client/license.rb +3 -4
- data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
- data/lib/octokit/enterprise_admin_client/users.rb +5 -4
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +32 -32
- data/lib/octokit/enterprise_management_console_client.rb +8 -2
- data/lib/octokit/error.rb +72 -27
- data/lib/octokit/gist.rb +2 -3
- data/lib/octokit/middleware/follow_redirects.rb +15 -11
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +3 -3
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +24 -24
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +4 -2
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +15 -8
- data/octokit.gemspec +12 -10
- metadata +25 -17
- data/lib/octokit/client/authorizations.rb +0 -250
- data/lib/octokit/preview.rb +0 -46
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Checks API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/checks/
|
7
8
|
module Checks
|
8
|
-
|
9
9
|
# Methods for Check Runs
|
10
10
|
#
|
11
11
|
# @see https://developer.github.com/v3/checks/runs/
|
@@ -23,7 +23,6 @@ module Octokit
|
|
23
23
|
# check_run.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
|
24
24
|
# check_run.status # => "queued"
|
25
25
|
def create_check_run(repo, name, head_sha, options = {})
|
26
|
-
ensure_api_media_type(:checks, options)
|
27
26
|
options[:name] = name
|
28
27
|
options[:head_sha] = head_sha
|
29
28
|
|
@@ -41,8 +40,6 @@ module Octokit
|
|
41
40
|
# check_run.id # => 51295429
|
42
41
|
# check_run.status # => "in_progress"
|
43
42
|
def update_check_run(repo, id, options = {})
|
44
|
-
ensure_api_media_type(:checks, options)
|
45
|
-
|
46
43
|
patch "#{Repository.path repo}/check-runs/#{id}", options
|
47
44
|
end
|
48
45
|
|
@@ -63,11 +60,12 @@ module Octokit
|
|
63
60
|
# result.check_runs[0].id # => 51295429
|
64
61
|
# result.check_runs[0].status # => "in_progress"
|
65
62
|
def check_runs_for_ref(repo, ref, options = {})
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
paginate "#{Repository.path repo}/commits/#{ref}/check-runs", options do |data, last_response|
|
64
|
+
data.check_runs.concat last_response.data.check_runs
|
65
|
+
data.total_count += last_response.data.total_count
|
66
|
+
end
|
69
67
|
end
|
70
|
-
alias
|
68
|
+
alias list_check_runs_for_ref check_runs_for_ref
|
71
69
|
|
72
70
|
# List check runs in a check suite
|
73
71
|
#
|
@@ -86,11 +84,12 @@ module Octokit
|
|
86
84
|
# result.check_runs[0].check_suite.id # => 50440400
|
87
85
|
# result.check_runs[0].status # => "in_progress"
|
88
86
|
def check_runs_for_check_suite(repo, id, options = {})
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
paginate "#{Repository.path repo}/check-suites/#{id}/check-runs", options do |data, last_response|
|
88
|
+
data.check_runs.concat last_response.data.check_runs
|
89
|
+
data.total_count += last_response.data.total_count
|
90
|
+
end
|
92
91
|
end
|
93
|
-
alias
|
92
|
+
alias list_check_runs_for_check_suite check_runs_for_check_suite
|
94
93
|
|
95
94
|
# Get a single check run
|
96
95
|
#
|
@@ -99,8 +98,6 @@ module Octokit
|
|
99
98
|
# @return [Sawyer::Resource] A hash representing the check run
|
100
99
|
# @see https://developer.github.com/v3/checks/runs/#get-a-single-check-run
|
101
100
|
def check_run(repo, id, options = {})
|
102
|
-
ensure_api_media_type(:checks, options)
|
103
|
-
|
104
101
|
get "#{Repository.path repo}/check-runs/#{id}", options
|
105
102
|
end
|
106
103
|
|
@@ -116,9 +113,7 @@ module Octokit
|
|
116
113
|
# annotations[0].path # => "README.md"
|
117
114
|
# annotations[0].message # => "Looks good!"
|
118
115
|
def check_run_annotations(repo, id, options = {})
|
119
|
-
|
120
|
-
|
121
|
-
get "#{Repository.path repo}/check-runs/#{id}/annotations", options
|
116
|
+
paginate "#{Repository.path repo}/check-runs/#{id}/annotations", options
|
122
117
|
end
|
123
118
|
|
124
119
|
# Methods for Check Suites
|
@@ -132,8 +127,6 @@ module Octokit
|
|
132
127
|
# @return [Sawyer::Resource] A hash representing the check suite
|
133
128
|
# @see https://developer.github.com/v3/checks/suites/#get-a-single-check-suite
|
134
129
|
def check_suite(repo, id, options = {})
|
135
|
-
ensure_api_media_type(:checks, options)
|
136
|
-
|
137
130
|
get "#{Repository.path repo}/check-suites/#{id}", options
|
138
131
|
end
|
139
132
|
|
@@ -153,11 +146,12 @@ module Octokit
|
|
153
146
|
# result.check_suites[0].id # => 50440400
|
154
147
|
# result.check_suites[0].app.id # => 76765
|
155
148
|
def check_suites_for_ref(repo, ref, options = {})
|
156
|
-
|
157
|
-
|
158
|
-
|
149
|
+
paginate "#{Repository.path repo}/commits/#{ref}/check-suites", options do |data, last_response|
|
150
|
+
data.check_suites.concat last_response.data.check_suites
|
151
|
+
data.total_count += last_response.data.total_count
|
152
|
+
end
|
159
153
|
end
|
160
|
-
alias
|
154
|
+
alias list_check_suites_for_ref check_suites_for_ref
|
161
155
|
|
162
156
|
# Set preferences for check suites on a repository
|
163
157
|
#
|
@@ -172,8 +166,6 @@ module Octokit
|
|
172
166
|
# result.preferences.auto_trigger_checks[0].setting # => false
|
173
167
|
# result.repository.full_name # => "octocat/Hello-World"
|
174
168
|
def set_check_suite_preferences(repo, options = {})
|
175
|
-
ensure_api_media_type(:checks, options)
|
176
|
-
|
177
169
|
patch "#{Repository.path repo}/check-suites/preferences", options
|
178
170
|
end
|
179
171
|
|
@@ -188,7 +180,6 @@ module Octokit
|
|
188
180
|
# check_suite.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
|
189
181
|
# check_suite.status # => "queued"
|
190
182
|
def create_check_suite(repo, head_sha, options = {})
|
191
|
-
ensure_api_media_type(:checks, options)
|
192
183
|
options[:head_sha] = head_sha
|
193
184
|
|
194
185
|
post "#{Repository.path repo}/check-suites", options
|
@@ -201,8 +192,6 @@ module Octokit
|
|
201
192
|
# @return [Boolean] True if successful, raises an error otherwise
|
202
193
|
# @see https://developer.github.com/v3/checks/suites/#rerequest-check-suite
|
203
194
|
def rerequest_check_suite(repo, id, options = {})
|
204
|
-
ensure_api_media_type(:checks, options)
|
205
|
-
|
206
195
|
post "#{Repository.path repo}/check-suites/#{id}/rerequest", options
|
207
196
|
true
|
208
197
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Branches for HEAD API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/repos/commits/
|
8
|
+
module CommitBranches
|
9
|
+
# List branches for a single HEAD commit
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @param sha [String] The SHA of the commit whose branches will be fetched
|
13
|
+
# @return [Array] List of branches
|
14
|
+
# @see https://developer.github.com/v3/repos/commits/#list-branches-for-head-commit
|
15
|
+
def commit_branches(repo, sha, options = {})
|
16
|
+
paginate "#{Repository.path repo}/commits/#{sha}/branches-where-head", options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Commit Comments API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/comments/
|
7
8
|
module CommitComments
|
8
|
-
|
9
9
|
# List all commit comments
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -53,12 +53,12 @@ module Octokit
|
|
53
53
|
# comment.path # => "README.md"
|
54
54
|
# comment.line # => 10
|
55
55
|
# comment.position # => 1
|
56
|
-
def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, options = {})
|
56
|
+
def create_commit_comment(repo, sha, body, path = nil, line = nil, position = nil, options = {})
|
57
57
|
params = {
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
58
|
+
body: body,
|
59
|
+
path: path,
|
60
|
+
line: line,
|
61
|
+
position: position
|
62
62
|
}
|
63
63
|
post "#{Repository.path repo}/commits/#{sha}/comments", options.merge(params)
|
64
64
|
end
|
@@ -76,7 +76,7 @@ module Octokit
|
|
76
76
|
# comment.body # => "Updated commit comment"
|
77
77
|
def update_commit_comment(repo, id, body, options = {})
|
78
78
|
params = {
|
79
|
-
:
|
79
|
+
body: body
|
80
80
|
}
|
81
81
|
patch "#{Repository.path repo}/comments/#{id}", options.merge(params)
|
82
82
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Commit Pulls API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/comments/
|
7
8
|
module CommitPulls
|
8
|
-
|
9
9
|
# List pulls for a single commit
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
|
3
5
|
module Octokit
|
4
6
|
class Client
|
5
|
-
|
6
7
|
# Methods for the Commits API
|
7
8
|
#
|
8
9
|
# @see https://developer.github.com/v3/repos/commits/
|
9
10
|
module Commits
|
10
|
-
|
11
11
|
# List commits
|
12
12
|
#
|
13
13
|
# @overload commits(repo, sha_or_branch, options = {})
|
@@ -23,12 +23,10 @@ module Octokit
|
|
23
23
|
def commits(*args)
|
24
24
|
arguments = Octokit::RepoArguments.new(args)
|
25
25
|
sha_or_branch = arguments.pop
|
26
|
-
if sha_or_branch
|
27
|
-
arguments.options[:sha] = sha_or_branch
|
28
|
-
end
|
26
|
+
arguments.options[:sha] = sha_or_branch if sha_or_branch
|
29
27
|
paginate "#{Repository.new(arguments.repo).path}/commits", arguments.options
|
30
28
|
end
|
31
|
-
alias
|
29
|
+
alias list_commits commits
|
32
30
|
|
33
31
|
# Get commits after a specified date
|
34
32
|
#
|
@@ -48,13 +46,11 @@ module Octokit
|
|
48
46
|
# Octokit.commits_since('octokit/octokit.rb', '2012-10-01')
|
49
47
|
def commits_since(*args)
|
50
48
|
arguments = Octokit::RepoArguments.new(args)
|
51
|
-
date
|
49
|
+
date = parse_date(arguments.shift)
|
52
50
|
params = arguments.options
|
53
|
-
params.merge!(:
|
51
|
+
params.merge!(since: iso8601(date))
|
54
52
|
sha_or_branch = arguments.pop
|
55
|
-
if sha_or_branch
|
56
|
-
params[:sha] = sha_or_branch
|
57
|
-
end
|
53
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
58
54
|
commits(arguments.repo, params)
|
59
55
|
end
|
60
56
|
|
@@ -74,13 +70,11 @@ module Octokit
|
|
74
70
|
# Octokit.commits_before('octokit/octokit.rb', '2012-10-01')
|
75
71
|
def commits_before(*args)
|
76
72
|
arguments = Octokit::RepoArguments.new(args)
|
77
|
-
date
|
73
|
+
date = parse_date(arguments.shift)
|
78
74
|
params = arguments.options
|
79
|
-
params.merge!(:
|
75
|
+
params.merge!(until: iso8601(date))
|
80
76
|
sha_or_branch = arguments.pop
|
81
|
-
if sha_or_branch
|
82
|
-
params[:sha] = sha_or_branch
|
83
|
-
end
|
77
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
84
78
|
commits(arguments.repo, params)
|
85
79
|
end
|
86
80
|
|
@@ -100,14 +94,12 @@ module Octokit
|
|
100
94
|
# Octokit.commits_on('octokit/octokit.rb', '2012-10-01')
|
101
95
|
def commits_on(*args)
|
102
96
|
arguments = Octokit::RepoArguments.new(args)
|
103
|
-
date
|
97
|
+
date = parse_date(arguments.shift)
|
104
98
|
params = arguments.options
|
105
99
|
end_date = date + 1
|
106
|
-
params.merge!(:
|
100
|
+
params.merge!(since: iso8601(date), until: iso8601(end_date))
|
107
101
|
sha_or_branch = arguments.pop
|
108
|
-
if sha_or_branch
|
109
|
-
params[:sha] = sha_or_branch
|
110
|
-
end
|
102
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
111
103
|
commits(arguments.repo, params)
|
112
104
|
end
|
113
105
|
|
@@ -129,16 +121,16 @@ module Octokit
|
|
129
121
|
# Octokit.commits_between('octokit/octokit.rb', '2012-10-01', '2012-11-01')
|
130
122
|
def commits_between(*args)
|
131
123
|
arguments = Octokit::RepoArguments.new(args)
|
132
|
-
date
|
133
|
-
end_date
|
134
|
-
|
124
|
+
date = parse_date(arguments.shift)
|
125
|
+
end_date = parse_date(arguments.shift)
|
126
|
+
if date > end_date
|
127
|
+
raise ArgumentError, "Start date #{date} does not precede #{end_date}"
|
128
|
+
end
|
135
129
|
|
136
130
|
params = arguments.options
|
137
|
-
params.merge!(:
|
131
|
+
params.merge!(since: iso8601(date), until: iso8601(end_date))
|
138
132
|
sha_or_branch = arguments.pop
|
139
|
-
if sha_or_branch
|
140
|
-
params[:sha] = sha_or_branch
|
141
|
-
end
|
133
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
142
134
|
commits(arguments.repo, params)
|
143
135
|
end
|
144
136
|
|
@@ -181,21 +173,26 @@ module Octokit
|
|
181
173
|
# commit.tree.sha # => "827efc6d56897b048c772eb4087f854f46256132"
|
182
174
|
# commit.message # => "My commit message"
|
183
175
|
# commit.committer # => { "name" => "Wynn Netherland", "email" => "wynn@github.com", ... }
|
184
|
-
def create_commit(repo, message, tree, parents=nil, options = {})
|
185
|
-
params = { :
|
176
|
+
def create_commit(repo, message, tree, parents = nil, options = {})
|
177
|
+
params = { message: message, tree: tree }
|
186
178
|
params[:parents] = [parents].flatten if parents
|
187
179
|
post "#{Repository.path repo}/git/commits", options.merge(params)
|
188
180
|
end
|
189
181
|
|
190
182
|
# Compare two commits
|
191
183
|
#
|
184
|
+
# When using auto_pagination, commits from all pages will be concatenated
|
185
|
+
# into the <tt>commits</tt> attribute of the first page's response.
|
186
|
+
#
|
192
187
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
193
188
|
# @param start [String] The sha of the starting commit
|
194
189
|
# @param endd [String] The sha of the ending commit
|
195
190
|
# @return [Sawyer::Resource] A hash representing the comparison
|
196
191
|
# @see https://developer.github.com/v3/repos/commits/#compare-two-commits
|
197
192
|
def compare(repo, start, endd, options = {})
|
198
|
-
|
193
|
+
paginate "#{Repository.path repo}/compare/#{start}...#{endd}", options do |data, last_response|
|
194
|
+
data.commits.concat last_response.data.commits
|
195
|
+
end
|
199
196
|
end
|
200
197
|
|
201
198
|
# Merge a branch or sha
|
@@ -208,8 +205,8 @@ module Octokit
|
|
208
205
|
# @see https://developer.github.com/v3/repos/merging/#perform-a-merge
|
209
206
|
def merge(repo, base, head, options = {})
|
210
207
|
params = {
|
211
|
-
:
|
212
|
-
:
|
208
|
+
base: base,
|
209
|
+
head: head
|
213
210
|
}.merge(options)
|
214
211
|
post "#{Repository.path repo}/merges", params
|
215
212
|
end
|
@@ -220,7 +217,7 @@ module Octokit
|
|
220
217
|
if date.respond_to?(:iso8601)
|
221
218
|
date.iso8601
|
222
219
|
else
|
223
|
-
date.strftime(
|
220
|
+
date.strftime('%Y-%m-%dT%H:%M:%S%Z')
|
224
221
|
end
|
225
222
|
end
|
226
223
|
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Community Profile API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/community/
|
7
8
|
module CommunityProfile
|
8
|
-
|
9
9
|
# Get community profile metrics for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -14,7 +14,6 @@ module Octokit
|
|
14
14
|
# @example Get community profile metrics for octokit/octokit.rb
|
15
15
|
# @client.community_profile('octokit/octokit.rb')
|
16
16
|
def community_profile(repo, options = {})
|
17
|
-
options = ensure_api_media_type(:community_profile, options)
|
18
17
|
get "#{Repository.path repo}/community/profile", options
|
19
18
|
end
|
20
19
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'base64'
|
2
4
|
|
3
5
|
module Octokit
|
4
6
|
class Client
|
5
|
-
|
6
7
|
# Methods for the Repo Contents API
|
7
8
|
#
|
8
9
|
# @see https://developer.github.com/v3/repos/contents/
|
9
10
|
module Contents
|
10
|
-
|
11
11
|
# Receive the default Readme for a repository
|
12
12
|
#
|
13
13
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -16,7 +16,9 @@ module Octokit
|
|
16
16
|
# @see https://developer.github.com/v3/repos/contents/#get-the-readme
|
17
17
|
# @example Get the readme file for a repo
|
18
18
|
# Octokit.readme("octokit/octokit.rb")
|
19
|
-
|
19
|
+
# @example Get the readme file for a particular branch of the repo
|
20
|
+
# Octokit.readme("octokit/octokit.rb", :query => {:ref => 'some-other-branch'})
|
21
|
+
def readme(repo, options = {})
|
20
22
|
get "#{Repository.path repo}/readme", options
|
21
23
|
end
|
22
24
|
|
@@ -29,13 +31,15 @@ module Octokit
|
|
29
31
|
# @see https://developer.github.com/v3/repos/contents/#get-contents
|
30
32
|
# @example List the contents of lib/octokit.rb
|
31
33
|
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb')
|
32
|
-
|
34
|
+
# @example Lists the contents of lib /octokit.rb on a particular branch
|
35
|
+
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb', :query => {:ref => 'some-other-branch'})
|
36
|
+
def contents(repo, options = {})
|
33
37
|
options = options.dup
|
34
38
|
repo_path = options.delete :path
|
35
39
|
url = "#{Repository.path repo}/contents/#{repo_path}"
|
36
40
|
get url, options
|
37
41
|
end
|
38
|
-
alias
|
42
|
+
alias content contents
|
39
43
|
|
40
44
|
# Add content to a repository
|
41
45
|
#
|
@@ -55,7 +59,7 @@ module Octokit
|
|
55
59
|
# "File content",
|
56
60
|
# :branch => "my-new-feature")
|
57
61
|
def create_contents(*args)
|
58
|
-
args = args.map { |item| item
|
62
|
+
args = args.map { |item| item&.dup }
|
59
63
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
60
64
|
repo = args.shift
|
61
65
|
path = args.shift
|
@@ -65,7 +69,7 @@ module Octokit
|
|
65
69
|
case file
|
66
70
|
when String
|
67
71
|
if File.exist?(file)
|
68
|
-
file = File.open(file,
|
72
|
+
file = File.open(file, 'r')
|
69
73
|
content = file.read
|
70
74
|
file.close
|
71
75
|
end
|
@@ -74,17 +78,16 @@ module Octokit
|
|
74
78
|
file.close
|
75
79
|
end
|
76
80
|
end
|
77
|
-
raise ArgumentError
|
78
|
-
|
79
|
-
|
80
|
-
Base64.encode64(content).delete("\n") # Ruby 1.9.2
|
81
|
+
raise ArgumentError, 'content or :file option required' if content.nil?
|
82
|
+
|
83
|
+
options[:content] = Base64.strict_encode64(content)
|
81
84
|
options[:message] = message
|
82
85
|
url = "#{Repository.path repo}/contents/#{path}"
|
83
86
|
put url, options
|
84
87
|
end
|
85
|
-
alias
|
86
|
-
alias
|
87
|
-
alias
|
88
|
+
alias create_content create_contents
|
89
|
+
alias add_content create_contents
|
90
|
+
alias add_contents create_contents
|
88
91
|
|
89
92
|
# Update content in a repository
|
90
93
|
#
|
@@ -112,10 +115,10 @@ module Octokit
|
|
112
115
|
message = args.shift
|
113
116
|
sha = args.shift
|
114
117
|
content = args.shift
|
115
|
-
options.merge!(:
|
118
|
+
options.merge!(sha: sha)
|
116
119
|
create_contents(repo, path, message, content, options)
|
117
120
|
end
|
118
|
-
alias
|
121
|
+
alias update_content update_contents
|
119
122
|
|
120
123
|
# Delete content in a repository
|
121
124
|
#
|
@@ -138,9 +141,9 @@ module Octokit
|
|
138
141
|
url = "#{Repository.path repo}/contents/#{path}"
|
139
142
|
delete url, options
|
140
143
|
end
|
141
|
-
alias
|
142
|
-
alias
|
143
|
-
alias
|
144
|
+
alias delete_content delete_contents
|
145
|
+
alias remove_content delete_contents
|
146
|
+
alias remove_contents delete_contents
|
144
147
|
|
145
148
|
# This method will provide a URL to download a tarball or zipball archive for a repository.
|
146
149
|
#
|
@@ -151,8 +154,8 @@ module Octokit
|
|
151
154
|
# @see https://developer.github.com/v3/repos/contents/#get-archive-link
|
152
155
|
# @example Get archive link for octokit/octokit.rb
|
153
156
|
# Octokit.archive_link("octokit/octokit.rb")
|
154
|
-
def archive_link(repo, options={})
|
155
|
-
repo_ref = options.delete
|
157
|
+
def archive_link(repo, options = {})
|
158
|
+
repo_ref = ERB::Util.url_encode(options.delete(:ref))
|
156
159
|
format = (options.delete :format) || 'tarball'
|
157
160
|
url = "#{Repository.path repo}/#{format}/#{repo_ref}"
|
158
161
|
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Deployments API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/commits/deployments/
|
7
8
|
module Deployments
|
8
|
-
|
9
9
|
# Fetch a single deployment for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -24,7 +24,7 @@ module Octokit
|
|
24
24
|
def deployments(repo, options = {})
|
25
25
|
get("#{Repository.path repo}/deployments", options)
|
26
26
|
end
|
27
|
-
alias
|
27
|
+
alias list_deployments deployments
|
28
28
|
|
29
29
|
# Create a deployment for a ref
|
30
30
|
#
|
@@ -43,16 +43,26 @@ module Octokit
|
|
43
43
|
post("#{Repository.path repo}/deployments", options)
|
44
44
|
end
|
45
45
|
|
46
|
+
# Delete a Deployment
|
47
|
+
#
|
48
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
49
|
+
# @param deployment_id [Integer, String, Repository, Hash] A GitHub repository
|
50
|
+
# @return [No Content]
|
51
|
+
# @see https://developer.github.com/v3/repos/deployments/#delete-a-deployment
|
52
|
+
def delete_deployment(repo, deployment_id, options = {})
|
53
|
+
delete("#{Repository.path repo}/deployments/#{deployment_id}", options)
|
54
|
+
end
|
55
|
+
|
46
56
|
# List all statuses for a Deployment
|
47
57
|
#
|
48
58
|
# @param deployment_url [String] A URL for a deployment resource
|
49
59
|
# @return [Array<Sawyer::Resource>] A list of deployment statuses
|
50
60
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
|
51
61
|
def deployment_statuses(deployment_url, options = {})
|
52
|
-
deployment = get(deployment_url, :
|
62
|
+
deployment = get(deployment_url, accept: options[:accept])
|
53
63
|
get(deployment.rels[:statuses].href, options)
|
54
64
|
end
|
55
|
-
alias
|
65
|
+
alias list_deployment_statuses deployment_statuses
|
56
66
|
|
57
67
|
# Create a deployment status for a Deployment
|
58
68
|
#
|
@@ -63,7 +73,7 @@ module Octokit
|
|
63
73
|
# @return [Sawyer::Resource] A deployment status
|
64
74
|
# @see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
|
65
75
|
def create_deployment_status(deployment_url, state, options = {})
|
66
|
-
deployment = get(deployment_url, :
|
76
|
+
deployment = get(deployment_url, accept: options[:accept])
|
67
77
|
options[:state] = state.to_s.downcase
|
68
78
|
post(deployment.rels[:statuses].href, options)
|
69
79
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Repo Downloads API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/downloads/
|
7
8
|
module Downloads
|
8
|
-
|
9
9
|
# List available downloads for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A Github Repository
|
@@ -14,10 +14,10 @@ module Octokit
|
|
14
14
|
# @see https://developer.github.com/v3/repos/downloads/#list-downloads-for-a-repository
|
15
15
|
# @example List all downloads for Github/Hubot
|
16
16
|
# Octokit.downloads("github/hubot")
|
17
|
-
def downloads(repo, options={})
|
17
|
+
def downloads(repo, options = {})
|
18
18
|
paginate "#{Repository.path repo}/downloads", options
|
19
19
|
end
|
20
|
-
alias
|
20
|
+
alias list_downloads downloads
|
21
21
|
|
22
22
|
# Get single download for a repository
|
23
23
|
#
|
@@ -28,7 +28,7 @@ module Octokit
|
|
28
28
|
# @see https://developer.github.com/v3/repos/downloads/#get-a-single-download
|
29
29
|
# @example Get the "Robawt" download from Github/Hubot
|
30
30
|
# Octokit.download("github/hubot")
|
31
|
-
def download(repo, id, options={})
|
31
|
+
def download(repo, id, options = {})
|
32
32
|
get "#{Repository.path repo}/downloads/#{id}", options
|
33
33
|
end
|
34
34
|
|
@@ -44,7 +44,6 @@ module Octokit
|
|
44
44
|
def delete_download(repo, id, options = {})
|
45
45
|
boolean_from_response :delete, "#{Repository.path repo}/downloads/#{id}", options
|
46
46
|
end
|
47
|
-
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Emojis API
|
5
6
|
module Emojis
|
6
|
-
|
7
7
|
# List all emojis used on GitHub
|
8
8
|
#
|
9
9
|
# @return [Sawyer::Resource] A list of all emojis on GitHub
|
@@ -11,7 +11,7 @@ module Octokit
|
|
11
11
|
# @example List all emojis
|
12
12
|
# Octokit.emojis
|
13
13
|
def emojis(options = {})
|
14
|
-
get
|
14
|
+
get 'emojis', options
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -1,12 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Method for the Events API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/activity/events/
|
7
8
|
# @see https://developer.github.com/v3/issues/events/
|
8
9
|
module Events
|
9
|
-
|
10
10
|
# List all public events for GitHub
|
11
11
|
#
|
12
12
|
# @return [Array<Sawyer::Resource>] A list of all public events from GitHub
|
@@ -14,7 +14,7 @@ module Octokit
|
|
14
14
|
# @example List all pubilc events
|
15
15
|
# Octokit.public_events
|
16
16
|
def public_events(options = {})
|
17
|
-
paginate
|
17
|
+
paginate 'events', options
|
18
18
|
end
|
19
19
|
|
20
20
|
# List all user events
|
@@ -119,7 +119,7 @@ module Octokit
|
|
119
119
|
def repository_issue_events(repo, options = {})
|
120
120
|
paginate "#{Repository.path repo}/issues/events", options
|
121
121
|
end
|
122
|
-
alias
|
122
|
+
alias repo_issue_events repository_issue_events
|
123
123
|
|
124
124
|
# List events for an Issue
|
125
125
|
#
|