octokit 4.2.0 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +275 -127
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +12 -0
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +161 -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 +259 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- 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 +20 -0
- data/lib/octokit/client/commits.rb +32 -35
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +29 -7
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +36 -8
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +34 -30
- data/lib/octokit/client/issues.rb +97 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +5 -8
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +14 -14
- data/lib/octokit/client/notifications.rb +7 -11
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +256 -73
- data/lib/octokit/client/pages.rb +26 -3
- data/lib/octokit/client/projects.rb +294 -0
- data/lib/octokit/client/pull_requests.rb +74 -51
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +204 -0
- data/lib/octokit/client/refs.rb +34 -20
- data/lib/octokit/client/releases.rb +16 -13
- data/lib/octokit/client/repositories.rb +276 -60
- data/lib/octokit/client/repository_invitations.rb +96 -0
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +46 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +156 -0
- data/lib/octokit/client/stats.rb +39 -17
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +64 -0
- data/lib/octokit/client/users.rb +133 -25
- data/lib/octokit/client.rb +85 -19
- data/lib/octokit/configurable.rb +60 -32
- data/lib/octokit/connection.rb +45 -21
- data/lib/octokit/default.rb +82 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +7 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +19 -18
- data/lib/octokit/enterprise_admin_client.rb +11 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +144 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +18 -14
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +35 -23
- 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 +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -10
- metadata +47 -24
- data/lib/octokit/client/authorizations.rb +0 -256
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -28
@@ -1,17 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for API rate limiting info
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/#rate-limiting
|
7
8
|
module RateLimit
|
8
|
-
|
9
9
|
# Get rate limit info from last response if available
|
10
10
|
# or make a new request to fetch rate limit
|
11
11
|
#
|
12
12
|
# @see https://developer.github.com/v3/rate_limit/#rate-limit
|
13
13
|
# @return [Octokit::RateLimit] Rate limit info
|
14
|
-
def rate_limit(
|
14
|
+
def rate_limit(_options = {})
|
15
15
|
return rate_limit! if last_response.nil?
|
16
16
|
|
17
17
|
Octokit::RateLimit.from_response(last_response)
|
@@ -21,9 +21,9 @@ module Octokit
|
|
21
21
|
# Get number of rate limted requests remaining
|
22
22
|
#
|
23
23
|
# @see https://developer.github.com/v3/rate_limit/#rate-limit
|
24
|
-
# @return [
|
25
|
-
def rate_limit_remaining(
|
26
|
-
octokit_warn
|
24
|
+
# @return [Integer] Number of requests remaining in this period
|
25
|
+
def rate_limit_remaining(_options = {})
|
26
|
+
octokit_warn 'Deprecated: Please use .rate_limit.remaining'
|
27
27
|
rate_limit.remaining
|
28
28
|
end
|
29
29
|
alias ratelimit_remaining rate_limit_remaining
|
@@ -32,8 +32,8 @@ module Octokit
|
|
32
32
|
#
|
33
33
|
# @see https://developer.github.com/v3/rate_limit/#rate-limit
|
34
34
|
# @return [Octokit::RateLimit] Rate limit info
|
35
|
-
def rate_limit!(
|
36
|
-
get
|
35
|
+
def rate_limit!(_options = {})
|
36
|
+
get 'rate_limit'
|
37
37
|
Octokit::RateLimit.from_response(last_response)
|
38
38
|
end
|
39
39
|
alias ratelimit! rate_limit!
|
@@ -41,14 +41,12 @@ module Octokit
|
|
41
41
|
# Refresh rate limit info and get number of rate limted requests remaining
|
42
42
|
#
|
43
43
|
# @see https://developer.github.com/v3/rate_limit/#rate-limit
|
44
|
-
# @return [
|
45
|
-
def rate_limit_remaining!(
|
46
|
-
octokit_warn
|
44
|
+
# @return [Integer] Number of requests remaining in this period
|
45
|
+
def rate_limit_remaining!(_options = {})
|
46
|
+
octokit_warn 'Deprecated: Please use .rate_limit!.remaining'
|
47
47
|
rate_limit!.remaining
|
48
48
|
end
|
49
49
|
alias ratelimit_remaining! rate_limit_remaining!
|
50
|
-
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
54
|
-
|
@@ -0,0 +1,204 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Reacions API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/reactions/
|
8
|
+
module Reactions
|
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
|
+
get "#{Repository.path repo}/comments/#{id}/reactions", options
|
21
|
+
end
|
22
|
+
|
23
|
+
# Create a reaction for a commit comment
|
24
|
+
#
|
25
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
26
|
+
# @param id [Integer] The id of the commit comment
|
27
|
+
# @param reaction [String] The Reaction
|
28
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment
|
29
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# @client.create_commit_comment_reactions("octokit/octokit.rb", 1)
|
33
|
+
#
|
34
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction
|
35
|
+
def create_commit_comment_reaction(repo, id, reaction, options = {})
|
36
|
+
options = options.merge(content: reaction)
|
37
|
+
post "#{Repository.path repo}/comments/#{id}/reactions", options
|
38
|
+
end
|
39
|
+
|
40
|
+
# List reactions for an issue
|
41
|
+
#
|
42
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
43
|
+
# @param number [Integer] The Issue number
|
44
|
+
# @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# @client.issue_reactions("octokit/octokit.rb", 1)
|
48
|
+
#
|
49
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
50
|
+
def issue_reactions(repo, number, options = {})
|
51
|
+
get "#{Repository.path repo}/issues/#{number}/reactions", options
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create reaction for an issue
|
55
|
+
#
|
56
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
57
|
+
# @param number [Integer] The Issue number
|
58
|
+
# @param reaction [String] The Reaction
|
59
|
+
#
|
60
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue
|
61
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# @client.create_issue_reaction("octokit/octokit.rb", 1)
|
65
|
+
#
|
66
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
67
|
+
def create_issue_reaction(repo, number, reaction, options = {})
|
68
|
+
options = options.merge(content: reaction)
|
69
|
+
post "#{Repository.path repo}/issues/#{number}/reactions", options
|
70
|
+
end
|
71
|
+
|
72
|
+
# List reactions for an issue comment
|
73
|
+
#
|
74
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
75
|
+
# @param id [Integer] The Issue comment id
|
76
|
+
#
|
77
|
+
# @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# @client.issue_comment_reactions("octokit/octokit.rb", 1)
|
81
|
+
#
|
82
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
83
|
+
def issue_comment_reactions(repo, id, options = {})
|
84
|
+
get "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
85
|
+
end
|
86
|
+
|
87
|
+
# Create reaction for an issue comment
|
88
|
+
#
|
89
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
90
|
+
# @param id [Integer] The Issue comment id
|
91
|
+
# @param reaction [String] The Reaction
|
92
|
+
#
|
93
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment
|
94
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# @client.create_issue_comment_reaction("octokit/octokit.rb", 1)
|
98
|
+
#
|
99
|
+
# @return [<Sawyer::Resource>] Hashes representing the reaction.
|
100
|
+
def create_issue_comment_reaction(repo, id, reaction, options = {})
|
101
|
+
options = options.merge(content: reaction)
|
102
|
+
post "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
103
|
+
end
|
104
|
+
|
105
|
+
# List reactions for a pull request review comment
|
106
|
+
#
|
107
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
108
|
+
# @param id [Integer] The Issue comment id
|
109
|
+
#
|
110
|
+
# @see https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# @client.pull_request_review_comment_reactions("octokit/octokit.rb", 1)
|
114
|
+
#
|
115
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
116
|
+
def pull_request_review_comment_reactions(repo, id, options = {})
|
117
|
+
get "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
118
|
+
end
|
119
|
+
|
120
|
+
# Create reaction for a pull request review comment
|
121
|
+
#
|
122
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
123
|
+
# @param id [Integer] The Issue comment id
|
124
|
+
# @param reaction [String] The Reaction
|
125
|
+
#
|
126
|
+
# @see https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment
|
127
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
128
|
+
#
|
129
|
+
# @example
|
130
|
+
# @client.create_pull_request_reiew_comment_reaction("octokit/octokit.rb", 1)
|
131
|
+
#
|
132
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
133
|
+
def create_pull_request_review_comment_reaction(repo, id, reaction, options = {})
|
134
|
+
options = options.merge(content: reaction)
|
135
|
+
post "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
136
|
+
end
|
137
|
+
|
138
|
+
# Delete a reaction
|
139
|
+
#
|
140
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
141
|
+
# @param issue_id [Integer] The Issue comment id
|
142
|
+
# @param reaction_id [Integer] The Reaction id
|
143
|
+
#
|
144
|
+
# @see https://docs.github.com/en/rest/reactions/reactions#delete-an-issue-reaction
|
145
|
+
#
|
146
|
+
# @example
|
147
|
+
# @client.delete_issue_reaction("octokit/octokit.rb", 1, 2)
|
148
|
+
#
|
149
|
+
# @return [Boolean] Return true if reaction was deleted, false otherwise.
|
150
|
+
def delete_issue_reaction(repo, issue_id, reaction_id, options = {})
|
151
|
+
boolean_from_response :delete, "#{Repository.path repo}/issues/#{issue_id}/reactions/#{reaction_id}", options
|
152
|
+
end
|
153
|
+
|
154
|
+
# List reactions for a release
|
155
|
+
#
|
156
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
157
|
+
# @param id [Integer] The Release id
|
158
|
+
#
|
159
|
+
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-release
|
160
|
+
#
|
161
|
+
# @example
|
162
|
+
# @client.release_reactions("octokit/octokit.rb", 1)
|
163
|
+
#
|
164
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
165
|
+
def release_reactions(repo, release_id, options = {})
|
166
|
+
get "#{Repository.path repo}/releases/#{release_id}/reactions", options
|
167
|
+
end
|
168
|
+
|
169
|
+
# Create reaction for a release
|
170
|
+
#
|
171
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
172
|
+
# @param id [Integer] The Release id
|
173
|
+
# @param reaction [String] The Reaction
|
174
|
+
#
|
175
|
+
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-release
|
176
|
+
# @see https://developer.github.com/v3/reactions/#reaction-types
|
177
|
+
#
|
178
|
+
# @example
|
179
|
+
# @client.create_release_reaction("octokit/octokit.rb", 1)
|
180
|
+
#
|
181
|
+
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
182
|
+
def create_release_reaction(repo, release_id, reaction, options = {})
|
183
|
+
options = options.merge(content: reaction)
|
184
|
+
post "#{Repository.path repo}/releases/#{release_id}/reactions", options
|
185
|
+
end
|
186
|
+
|
187
|
+
# Delete a reaction for a release
|
188
|
+
#
|
189
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
190
|
+
# @param issue_id [Integer] The Release id
|
191
|
+
# @param reaction_id [Integer] The Reaction id
|
192
|
+
#
|
193
|
+
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#delete-a-release-reaction
|
194
|
+
#
|
195
|
+
# @example
|
196
|
+
# @client.delete_release_reaction("octokit/octokit.rb", 1, 2)
|
197
|
+
#
|
198
|
+
# @return [Boolean] Return true if reaction was deleted, false otherwise.
|
199
|
+
def delete_release_reaction(repo, release_id, reaction_id, options = {})
|
200
|
+
boolean_from_response :delete, "#{Repository.path repo}/releases/#{release_id}/reactions/#{reaction_id}", options
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
data/lib/octokit/client/refs.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for References for Git Data API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/git/refs/
|
7
8
|
module Refs
|
8
|
-
|
9
9
|
# List all refs for a given user and repo
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -19,9 +19,21 @@ module Octokit
|
|
19
19
|
path += "/#{namespace}" unless namespace.nil?
|
20
20
|
paginate path, options
|
21
21
|
end
|
22
|
-
alias
|
23
|
-
alias
|
24
|
-
alias
|
22
|
+
alias list_refs refs
|
23
|
+
alias references refs
|
24
|
+
alias list_references refs
|
25
|
+
|
26
|
+
# Fetch matching refs
|
27
|
+
#
|
28
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
29
|
+
# @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt> or <tt>heads/rails-3</tt>
|
30
|
+
# @return [Array<Sawyer::Resource>] The reference matching the given repo and the ref id
|
31
|
+
# @see https://developer.github.com/v3/git/refs/#list-matching-references
|
32
|
+
# @example Fetch refs matching tags/v2 for sferik/rails_admin
|
33
|
+
# Octokit.ref("sferik/rails_admin","tags/v2")
|
34
|
+
def matching_refs(repo, ref, options = {})
|
35
|
+
paginate "#{Repository.path repo}/git/matching-refs/#{ref}", options
|
36
|
+
end
|
25
37
|
|
26
38
|
# Fetch a given reference
|
27
39
|
#
|
@@ -34,7 +46,7 @@ module Octokit
|
|
34
46
|
def ref(repo, ref, options = {})
|
35
47
|
get "#{Repository.path repo}/git/refs/#{ref}", options
|
36
48
|
end
|
37
|
-
alias
|
49
|
+
alias reference ref
|
38
50
|
|
39
51
|
# Create a reference
|
40
52
|
#
|
@@ -44,45 +56,48 @@ module Octokit
|
|
44
56
|
# @return [Array<Sawyer::Resource>] The list of references, already containing the new one
|
45
57
|
# @see https://developer.github.com/v3/git/refs/#create-a-reference
|
46
58
|
# @example Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132
|
47
|
-
# Octokit.create_ref("octocat/Hello-World","heads/master", "827efc6d56897b048c772eb4087f854f46256132")
|
59
|
+
# Octokit.create_ref("octocat/Hello-World", "heads/master", "827efc6d56897b048c772eb4087f854f46256132")
|
48
60
|
def create_ref(repo, ref, sha, options = {})
|
61
|
+
ref = "refs/#{ref}" unless ref =~ %r{\Arefs/}
|
49
62
|
parameters = {
|
50
|
-
:
|
51
|
-
:
|
63
|
+
ref: ref,
|
64
|
+
sha: sha
|
52
65
|
}
|
53
66
|
post "#{Repository.path repo}/git/refs", options.merge(parameters)
|
54
67
|
end
|
55
|
-
alias
|
68
|
+
alias create_reference create_ref
|
56
69
|
|
57
70
|
# Update a reference
|
58
71
|
#
|
59
72
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
60
73
|
# @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
|
61
74
|
# @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
|
62
|
-
# @param force [Boolean] A flag indicating
|
75
|
+
# @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
|
63
76
|
# @return [Array<Sawyer::Resource>] The list of references updated
|
64
77
|
# @see https://developer.github.com/v3/git/refs/#update-a-reference
|
65
78
|
# @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
|
-
def update_ref(repo, ref, sha, force =
|
79
|
+
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
|
80
|
+
def update_ref(repo, ref, sha, force = false, options = {})
|
68
81
|
parameters = {
|
69
|
-
:
|
70
|
-
:
|
82
|
+
sha: sha,
|
83
|
+
force: force
|
71
84
|
}
|
72
85
|
patch "#{Repository.path repo}/git/refs/#{ref}", options.merge(parameters)
|
73
86
|
end
|
74
|
-
alias
|
87
|
+
alias update_reference update_ref
|
75
88
|
|
76
89
|
# Update a branch
|
77
90
|
#
|
78
91
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
79
92
|
# @param branch [String] The ref, e.g. <tt>feature/new-shiny</tt>
|
80
93
|
# @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
|
81
|
-
# @param force [Boolean] A flag indicating
|
94
|
+
# @param force [Boolean] A flag indicating whether to force the update or to make sure the update is a fast-forward update.
|
82
95
|
# @return [Array<Sawyer::Resource>] The list of references updated
|
83
96
|
# @see https://developer.github.com/v3/git/refs/#update-a-reference
|
84
97
|
# @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
85
|
-
# Octokit.
|
98
|
+
# Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
|
99
|
+
# @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
100
|
+
# Octokit.update_branch("octocat/Hello-World", "sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
|
86
101
|
def update_branch(repo, branch, sha, force = true, options = {})
|
87
102
|
update_ref repo, "heads/#{branch}", sha, force, options
|
88
103
|
end
|
@@ -110,8 +125,7 @@ module Octokit
|
|
110
125
|
def delete_ref(repo, ref, options = {})
|
111
126
|
boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", options
|
112
127
|
end
|
113
|
-
alias
|
114
|
-
|
128
|
+
alias delete_reference delete_ref
|
115
129
|
end
|
116
130
|
end
|
117
131
|
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 Releases API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/releases/
|
7
8
|
module Releases
|
8
|
-
|
9
9
|
# List releases for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -14,7 +14,7 @@ module Octokit
|
|
14
14
|
def releases(repo, options = {})
|
15
15
|
paginate "#{Repository.path repo}/releases", options
|
16
16
|
end
|
17
|
-
alias
|
17
|
+
alias list_releases releases
|
18
18
|
|
19
19
|
# Create a release
|
20
20
|
#
|
@@ -28,7 +28,7 @@ module Octokit
|
|
28
28
|
# @return [Sawyer::Resource] The release
|
29
29
|
# @see https://developer.github.com/v3/repos/releases/#create-a-release
|
30
30
|
def create_release(repo, tag_name, options = {})
|
31
|
-
opts = options.merge(:
|
31
|
+
opts = options.merge(tag_name: tag_name)
|
32
32
|
post "#{Repository.path repo}/releases", opts
|
33
33
|
end
|
34
34
|
|
@@ -44,6 +44,7 @@ module Octokit
|
|
44
44
|
# Update a release
|
45
45
|
#
|
46
46
|
# @param url [String] URL for the release as returned from .releases
|
47
|
+
# @option options [String] :tag_name Git tag from which to create release
|
47
48
|
# @option options [String] :target_commitish Specifies the commitish value that determines where the Git tag is created from.
|
48
49
|
# @option options [String] :name Name for the release
|
49
50
|
# @option options [String] :body Content for release notes
|
@@ -54,7 +55,7 @@ module Octokit
|
|
54
55
|
def update_release(url, options = {})
|
55
56
|
patch url, options
|
56
57
|
end
|
57
|
-
alias
|
58
|
+
alias edit_release update_release
|
58
59
|
|
59
60
|
# Delete a release
|
60
61
|
#
|
@@ -83,17 +84,18 @@ module Octokit
|
|
83
84
|
# @return [Sawyer::Resource] The release asset
|
84
85
|
# @see https://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
85
86
|
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,
|
87
|
+
file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, 'rb')
|
87
88
|
options[:content_type] ||= content_type_from_file(file)
|
88
|
-
raise Octokit::MissingContentType
|
89
|
+
raise Octokit::MissingContentType if options[:content_type].nil?
|
90
|
+
|
89
91
|
unless name = options[:name]
|
90
92
|
name = File.basename(file.path)
|
91
93
|
end
|
92
|
-
upload_url = release(release_url).rels[:upload].href_template.expand(:
|
94
|
+
upload_url = release(release_url).rels[:upload].href_template.expand(name: name)
|
93
95
|
|
94
96
|
request :post, upload_url, file.read, parse_query_and_convenience_headers(options)
|
95
97
|
ensure
|
96
|
-
file
|
98
|
+
file&.close
|
97
99
|
end
|
98
100
|
|
99
101
|
# Get a single release asset
|
@@ -116,7 +118,7 @@ module Octokit
|
|
116
118
|
def update_release_asset(asset_url, options = {})
|
117
119
|
patch(asset_url, options)
|
118
120
|
end
|
119
|
-
alias
|
121
|
+
alias edit_release_asset update_release_asset
|
120
122
|
|
121
123
|
# Delete a release asset
|
122
124
|
#
|
@@ -132,6 +134,7 @@ module Octokit
|
|
132
134
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
133
135
|
# @param tag_name [String] the name for a tag
|
134
136
|
# @return [Sawyer::Resource] The release
|
137
|
+
# @see https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name
|
135
138
|
def release_for_tag(repo, tag_name, options = {})
|
136
139
|
get "#{Repository.path repo}/releases/tags/#{tag_name}", options
|
137
140
|
end
|
@@ -140,6 +143,7 @@ module Octokit
|
|
140
143
|
#
|
141
144
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
142
145
|
# @return [Sawyer::Resource] The release
|
146
|
+
# @see https://developer.github.com/v3/repos/releases/#get-the-latest-release
|
143
147
|
def latest_release(repo, options = {})
|
144
148
|
get "#{Repository.path repo}/releases/latest", options
|
145
149
|
end
|
@@ -152,10 +156,9 @@ module Octokit
|
|
152
156
|
mime_type.content_type
|
153
157
|
end
|
154
158
|
rescue LoadError
|
155
|
-
msg =
|
156
|
-
raise Octokit::MissingContentType
|
159
|
+
msg = 'Please pass content_type or install mime-types gem to guess content type from file'
|
160
|
+
raise Octokit::MissingContentType, msg
|
157
161
|
end
|
158
|
-
|
159
162
|
end
|
160
163
|
end
|
161
164
|
end
|