octokit 4.22.0 → 7.0.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 +113 -75
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +10 -3
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +10 -9
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +23 -3
- data/lib/octokit/client/actions_workflows.rb +27 -2
- data/lib/octokit/client/apps.rb +26 -26
- data/lib/octokit/client/checks.rb +18 -9
- data/lib/octokit/client/code_scanning.rb +53 -0
- data/lib/octokit/client/codespaces_secrets.rb +59 -0
- data/lib/octokit/client/commit_branches.rb +2 -2
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +2 -2
- data/lib/octokit/client/commits.rb +25 -33
- data/lib/octokit/client/community_profile.rb +2 -3
- data/lib/octokit/client/contents.rb +20 -21
- data/lib/octokit/client/dependabot_secrets.rb +59 -0
- data/lib/octokit/client/deployments.rb +6 -6
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +55 -0
- data/lib/octokit/client/events.rb +4 -5
- 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 +0 -6
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +100 -56
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +44 -64
- data/lib/octokit/client/pub_sub_hubbub.rb +15 -15
- data/lib/octokit/client/pull_requests.rb +54 -42
- data/lib/octokit/client/rate_limit.rb +9 -11
- data/lib/octokit/client/reactions.rb +13 -16
- data/lib/octokit/client/refs.rb +14 -17
- data/lib/octokit/client/releases.rb +13 -13
- data/lib/octokit/client/repositories.rb +49 -69
- data/lib/octokit/client/repository_invitations.rb +3 -3
- data/lib/octokit/client/reviews.rb +8 -8
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +24 -10
- 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 +27 -33
- data/lib/octokit/client.rb +40 -16
- data/lib/octokit/configurable.rb +34 -30
- data/lib/octokit/connection.rb +28 -21
- data/lib/octokit/default.rb +48 -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 +45 -34
- data/lib/octokit/gist.rb +3 -4
- data/lib/octokit/middleware/follow_redirects.rb +12 -11
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +8 -6
- 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 -7
- data/lib/octokit/response/raise_error.rb +4 -4
- 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 -11
- metadata +20 -33
- data/lib/octokit/client/authorizations.rb +0 -182
- 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 Reacions API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/reactions/
|
7
8
|
module Reactions
|
8
|
-
|
9
9
|
# List reactions for a commit comment
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -17,7 +17,6 @@ module Octokit
|
|
17
17
|
#
|
18
18
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
19
19
|
def commit_comment_reactions(repo, id, options = {})
|
20
|
-
options = ensure_api_media_type(:reactions, options)
|
21
20
|
get "#{Repository.path repo}/comments/#{id}/reactions", options
|
22
21
|
end
|
23
22
|
|
@@ -34,7 +33,7 @@ module Octokit
|
|
34
33
|
#
|
35
34
|
# @return [<Sawyer::Resource>] Hash representing the reaction
|
36
35
|
def create_commit_comment_reaction(repo, id, reaction, options = {})
|
37
|
-
options =
|
36
|
+
options = options.merge(content: reaction)
|
38
37
|
post "#{Repository.path repo}/comments/#{id}/reactions", options
|
39
38
|
end
|
40
39
|
|
@@ -49,7 +48,6 @@ module Octokit
|
|
49
48
|
#
|
50
49
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
51
50
|
def issue_reactions(repo, number, options = {})
|
52
|
-
options = ensure_api_media_type(:reactions, options)
|
53
51
|
get "#{Repository.path repo}/issues/#{number}/reactions", options
|
54
52
|
end
|
55
53
|
|
@@ -67,7 +65,7 @@ module Octokit
|
|
67
65
|
#
|
68
66
|
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
69
67
|
def create_issue_reaction(repo, number, reaction, options = {})
|
70
|
-
options =
|
68
|
+
options = options.merge(content: reaction)
|
71
69
|
post "#{Repository.path repo}/issues/#{number}/reactions", options
|
72
70
|
end
|
73
71
|
|
@@ -83,7 +81,6 @@ module Octokit
|
|
83
81
|
#
|
84
82
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
85
83
|
def issue_comment_reactions(repo, id, options = {})
|
86
|
-
options = ensure_api_media_type(:reactions, options)
|
87
84
|
get "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
88
85
|
end
|
89
86
|
|
@@ -101,7 +98,7 @@ module Octokit
|
|
101
98
|
#
|
102
99
|
# @return [<Sawyer::Resource>] Hashes representing the reaction.
|
103
100
|
def create_issue_comment_reaction(repo, id, reaction, options = {})
|
104
|
-
options =
|
101
|
+
options = options.merge(content: reaction)
|
105
102
|
post "#{Repository.path repo}/issues/comments/#{id}/reactions", options
|
106
103
|
end
|
107
104
|
|
@@ -117,7 +114,6 @@ module Octokit
|
|
117
114
|
#
|
118
115
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
|
119
116
|
def pull_request_review_comment_reactions(repo, id, options = {})
|
120
|
-
options = ensure_api_media_type(:reactions, options)
|
121
117
|
get "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
122
118
|
end
|
123
119
|
|
@@ -135,23 +131,24 @@ module Octokit
|
|
135
131
|
#
|
136
132
|
# @return [<Sawyer::Resource>] Hash representing the reaction.
|
137
133
|
def create_pull_request_review_comment_reaction(repo, id, reaction, options = {})
|
138
|
-
options =
|
134
|
+
options = options.merge(content: reaction)
|
139
135
|
post "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
|
140
136
|
end
|
141
137
|
|
142
138
|
# Delete a reaction
|
143
139
|
#
|
144
|
-
# @param
|
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
|
145
143
|
#
|
146
|
-
# @see https://
|
144
|
+
# @see https://docs.github.com/en/rest/reactions/reactions#delete-an-issue-reaction
|
147
145
|
#
|
148
146
|
# @example
|
149
|
-
# @client.
|
147
|
+
# @client.delete_issue_reaction("octokit/octokit.rb", 1, 2)
|
150
148
|
#
|
151
149
|
# @return [Boolean] Return true if reaction was deleted, false otherwise.
|
152
|
-
def
|
153
|
-
|
154
|
-
boolean_from_response :delete, "reactions/#{id}", options
|
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
|
155
152
|
end
|
156
153
|
end
|
157
154
|
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,9 @@ 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
25
|
|
26
26
|
# Fetch matching refs
|
27
27
|
#
|
@@ -46,7 +46,7 @@ module Octokit
|
|
46
46
|
def ref(repo, ref, options = {})
|
47
47
|
get "#{Repository.path repo}/git/refs/#{ref}", options
|
48
48
|
end
|
49
|
-
alias
|
49
|
+
alias reference ref
|
50
50
|
|
51
51
|
# Create a reference
|
52
52
|
#
|
@@ -60,12 +60,12 @@ module Octokit
|
|
60
60
|
def create_ref(repo, ref, sha, options = {})
|
61
61
|
ref = "refs/#{ref}" unless ref =~ %r{\Arefs/}
|
62
62
|
parameters = {
|
63
|
-
:
|
64
|
-
:
|
63
|
+
ref: ref,
|
64
|
+
sha: sha
|
65
65
|
}
|
66
66
|
post "#{Repository.path repo}/git/refs", options.merge(parameters)
|
67
67
|
end
|
68
|
-
alias
|
68
|
+
alias create_reference create_ref
|
69
69
|
|
70
70
|
# Update a reference
|
71
71
|
#
|
@@ -77,16 +77,14 @@ module Octokit
|
|
77
77
|
# @see https://developer.github.com/v3/git/refs/#update-a-reference
|
78
78
|
# @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
|
79
79
|
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
|
80
|
-
|
81
|
-
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
|
82
|
-
def update_ref(repo, ref, sha, force = true, options = {})
|
80
|
+
def update_ref(repo, ref, sha, force = false, options = {})
|
83
81
|
parameters = {
|
84
|
-
:
|
85
|
-
:
|
82
|
+
sha: sha,
|
83
|
+
force: force
|
86
84
|
}
|
87
85
|
patch "#{Repository.path repo}/git/refs/#{ref}", options.merge(parameters)
|
88
86
|
end
|
89
|
-
alias
|
87
|
+
alias update_reference update_ref
|
90
88
|
|
91
89
|
# Update a branch
|
92
90
|
#
|
@@ -127,8 +125,7 @@ module Octokit
|
|
127
125
|
def delete_ref(repo, ref, options = {})
|
128
126
|
boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", options
|
129
127
|
end
|
130
|
-
alias
|
131
|
-
|
128
|
+
alias delete_reference delete_ref
|
132
129
|
end
|
133
130
|
end
|
134
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
|
|
@@ -55,7 +55,7 @@ module Octokit
|
|
55
55
|
def update_release(url, options = {})
|
56
56
|
patch url, options
|
57
57
|
end
|
58
|
-
alias
|
58
|
+
alias edit_release update_release
|
59
59
|
|
60
60
|
# Delete a release
|
61
61
|
#
|
@@ -84,17 +84,18 @@ module Octokit
|
|
84
84
|
# @return [Sawyer::Resource] The release asset
|
85
85
|
# @see https://developer.github.com/v3/repos/releases/#upload-a-release-asset
|
86
86
|
def upload_asset(release_url, path_or_file, options = {})
|
87
|
-
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')
|
88
88
|
options[:content_type] ||= content_type_from_file(file)
|
89
|
-
raise Octokit::MissingContentType
|
89
|
+
raise Octokit::MissingContentType if options[:content_type].nil?
|
90
|
+
|
90
91
|
unless name = options[:name]
|
91
92
|
name = File.basename(file.path)
|
92
93
|
end
|
93
|
-
upload_url = release(release_url).rels[:upload].href_template.expand(:
|
94
|
+
upload_url = release(release_url).rels[:upload].href_template.expand(name: name)
|
94
95
|
|
95
96
|
request :post, upload_url, file.read, parse_query_and_convenience_headers(options)
|
96
97
|
ensure
|
97
|
-
file
|
98
|
+
file&.close
|
98
99
|
end
|
99
100
|
|
100
101
|
# Get a single release asset
|
@@ -117,7 +118,7 @@ module Octokit
|
|
117
118
|
def update_release_asset(asset_url, options = {})
|
118
119
|
patch(asset_url, options)
|
119
120
|
end
|
120
|
-
alias
|
121
|
+
alias edit_release_asset update_release_asset
|
121
122
|
|
122
123
|
# Delete a release asset
|
123
124
|
#
|
@@ -155,10 +156,9 @@ module Octokit
|
|
155
156
|
mime_type.content_type
|
156
157
|
end
|
157
158
|
rescue LoadError
|
158
|
-
msg =
|
159
|
-
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
|
160
161
|
end
|
161
|
-
|
162
162
|
end
|
163
163
|
end
|
164
164
|
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 Repositories API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/
|
7
8
|
module Repositories
|
8
|
-
|
9
9
|
# Check if a repository exists
|
10
10
|
#
|
11
11
|
# @see https://developer.github.com/v3/repos/#get
|
@@ -13,9 +13,7 @@ module Octokit
|
|
13
13
|
# @return [Boolean]
|
14
14
|
def repository?(repo, options = {})
|
15
15
|
!!repository(repo, options)
|
16
|
-
rescue Octokit::InvalidRepository
|
17
|
-
false
|
18
|
-
rescue Octokit::NotFound
|
16
|
+
rescue Octokit::InvalidRepository, Octokit::NotFound
|
19
17
|
false
|
20
18
|
end
|
21
19
|
|
@@ -28,7 +26,7 @@ module Octokit
|
|
28
26
|
def repository(repo, options = {})
|
29
27
|
get Repository.path(repo), options
|
30
28
|
end
|
31
|
-
alias
|
29
|
+
alias repo repository
|
32
30
|
|
33
31
|
# Edit a repository
|
34
32
|
#
|
@@ -47,15 +45,12 @@ module Octokit
|
|
47
45
|
# @return [Sawyer::Resource] Repository information
|
48
46
|
def edit_repository(repo, options = {})
|
49
47
|
repo = Repository.new(repo)
|
50
|
-
if options.include? :is_template
|
51
|
-
options = ensure_api_media_type(:template_repositories, options)
|
52
|
-
end
|
53
48
|
options[:name] ||= repo.name
|
54
49
|
patch "repos/#{repo}", options
|
55
50
|
end
|
56
|
-
alias
|
57
|
-
alias
|
58
|
-
alias
|
51
|
+
alias edit edit_repository
|
52
|
+
alias update_repository edit_repository
|
53
|
+
alias update edit_repository
|
59
54
|
|
60
55
|
# List user repositories
|
61
56
|
#
|
@@ -71,12 +66,12 @@ module Octokit
|
|
71
66
|
# @param user [Integer, String] Optional GitHub user login or id for which
|
72
67
|
# to list repos.
|
73
68
|
# @return [Array<Sawyer::Resource>] List of repositories
|
74
|
-
def repositories(user=nil, options = {})
|
69
|
+
def repositories(user = nil, options = {})
|
75
70
|
paginate "#{User.path user}/repos", options
|
76
71
|
end
|
77
|
-
alias
|
78
|
-
alias
|
79
|
-
alias
|
72
|
+
alias list_repositories repositories
|
73
|
+
alias list_repos repositories
|
74
|
+
alias repos repositories
|
80
75
|
|
81
76
|
# List all repositories
|
82
77
|
#
|
@@ -159,10 +154,7 @@ module Octokit
|
|
159
154
|
def create_repository(name, options = {})
|
160
155
|
opts = options.dup
|
161
156
|
organization = opts.delete :organization
|
162
|
-
opts.merge! :
|
163
|
-
if opts.include? :is_template
|
164
|
-
opts = ensure_api_media_type(:template_repositories, opts)
|
165
|
-
end
|
157
|
+
opts.merge! name: name
|
166
158
|
|
167
159
|
if organization.nil?
|
168
160
|
post 'user/repos', opts
|
@@ -170,8 +162,8 @@ module Octokit
|
|
170
162
|
post "#{Organization.path organization}/repos", opts
|
171
163
|
end
|
172
164
|
end
|
173
|
-
alias
|
174
|
-
alias
|
165
|
+
alias create_repo create_repository
|
166
|
+
alias create create_repository
|
175
167
|
|
176
168
|
# Delete repository
|
177
169
|
#
|
@@ -183,7 +175,7 @@ module Octokit
|
|
183
175
|
def delete_repository(repo, options = {})
|
184
176
|
boolean_from_response :delete, Repository.path(repo), options
|
185
177
|
end
|
186
|
-
alias
|
178
|
+
alias delete_repo delete_repository
|
187
179
|
|
188
180
|
# Transfer repository
|
189
181
|
#
|
@@ -195,10 +187,9 @@ module Octokit
|
|
195
187
|
# @param options [Array<Integer>] :team_ids ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories.
|
196
188
|
# @return [Sawyer::Resource] Repository info for the transferred repository
|
197
189
|
def transfer_repository(repo, new_owner, options = {})
|
198
|
-
options = ensure_api_media_type(:transfer_repository, options)
|
199
190
|
post "#{Repository.path repo}/transfer", options.merge({ new_owner: new_owner })
|
200
191
|
end
|
201
|
-
alias
|
192
|
+
alias transfer_repo transfer_repository
|
202
193
|
|
203
194
|
# Create a repository for a user or organization generated from a template repository
|
204
195
|
#
|
@@ -210,11 +201,10 @@ module Octokit
|
|
210
201
|
# @option options [Boolean] :include_all_branches `true` copies all branches from the template repository, `false` (default) makes it only copy the master branch.
|
211
202
|
# @return [Sawyer::Resource] Repository info for the new repository
|
212
203
|
def create_repository_from_template(repo, name, options = {})
|
213
|
-
options.merge! :
|
214
|
-
options = ensure_api_media_type(:template_repositories, options)
|
204
|
+
options.merge! name: name
|
215
205
|
post "#{Repository.path repo}/generate", options
|
216
206
|
end
|
217
|
-
alias
|
207
|
+
alias create_repo_from_template create_repository_from_template
|
218
208
|
|
219
209
|
# Hide a public repository
|
220
210
|
#
|
@@ -222,7 +212,7 @@ module Octokit
|
|
222
212
|
# @return [Sawyer::Resource] Updated repository info
|
223
213
|
def set_private(repo, options = {})
|
224
214
|
# GitHub Api for setting private updated to use private attr, rather than public
|
225
|
-
update_repository repo, options.merge({ :
|
215
|
+
update_repository repo, options.merge({ private: true })
|
226
216
|
end
|
227
217
|
|
228
218
|
# Unhide a private repository
|
@@ -231,7 +221,7 @@ module Octokit
|
|
231
221
|
# @return [Sawyer::Resource] Updated repository info
|
232
222
|
def set_public(repo, options = {})
|
233
223
|
# GitHub Api for setting private updated to use private attr, rather than public
|
234
|
-
update_repository repo, options.merge({ :
|
224
|
+
update_repository repo, options.merge({ private: false })
|
235
225
|
end
|
236
226
|
|
237
227
|
# Get deploy keys on a repo
|
@@ -248,7 +238,7 @@ module Octokit
|
|
248
238
|
def deploy_keys(repo, options = {})
|
249
239
|
paginate "#{Repository.path repo}/keys", options
|
250
240
|
end
|
251
|
-
alias
|
241
|
+
alias list_deploy_keys deploy_keys
|
252
242
|
|
253
243
|
# Get a single deploy key for a repo
|
254
244
|
#
|
@@ -258,7 +248,7 @@ module Octokit
|
|
258
248
|
# @see https://developer.github.com/v3/repos/keys/#get-a-deploy-key
|
259
249
|
# @example
|
260
250
|
# @client.deploy_key('octokit/octokit.rb', 8675309)
|
261
|
-
def deploy_key(repo, id, options={})
|
251
|
+
def deploy_key(repo, id, options = {})
|
262
252
|
get "#{Repository.path repo}/keys/#{id}", options
|
263
253
|
end
|
264
254
|
|
@@ -274,7 +264,7 @@ module Octokit
|
|
274
264
|
# @example
|
275
265
|
# @client.add_deploy_key('octokit/octokit.rb', 'Staging server', 'ssh-rsa AAA...')
|
276
266
|
def add_deploy_key(repo, title, key, options = {})
|
277
|
-
post "#{Repository.path repo}/keys", options.merge(:
|
267
|
+
post "#{Repository.path repo}/keys", options.merge(title: title, key: key)
|
278
268
|
end
|
279
269
|
|
280
270
|
# Edit a deploy key
|
@@ -295,7 +285,7 @@ module Octokit
|
|
295
285
|
def edit_deploy_key(repo, id, options)
|
296
286
|
patch "#{Repository.path repo}/keys/#{id}", options
|
297
287
|
end
|
298
|
-
alias
|
288
|
+
alias update_deploy_key edit_deploy_key
|
299
289
|
|
300
290
|
# Remove deploy key from a repo
|
301
291
|
#
|
@@ -330,7 +320,7 @@ module Octokit
|
|
330
320
|
def collaborators(repo, options = {})
|
331
321
|
paginate "#{Repository.path repo}/collaborators", options
|
332
322
|
end
|
333
|
-
alias
|
323
|
+
alias collabs collaborators
|
334
324
|
|
335
325
|
# Add collaborator to repo
|
336
326
|
#
|
@@ -355,7 +345,7 @@ module Octokit
|
|
355
345
|
def add_collaborator(repo, collaborator, options = {})
|
356
346
|
boolean_from_response :put, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
357
347
|
end
|
358
|
-
alias
|
348
|
+
alias add_collab add_collaborator
|
359
349
|
|
360
350
|
# Remove collaborator from repo.
|
361
351
|
#
|
@@ -372,7 +362,7 @@ module Octokit
|
|
372
362
|
def remove_collaborator(repo, collaborator, options = {})
|
373
363
|
boolean_from_response :delete, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
374
364
|
end
|
375
|
-
alias
|
365
|
+
alias remove_collab remove_collaborator
|
376
366
|
|
377
367
|
# Checks if a user is a collaborator for a repo.
|
378
368
|
#
|
@@ -384,7 +374,7 @@ module Octokit
|
|
384
374
|
# @see https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator
|
385
375
|
# @example
|
386
376
|
# @client.collaborator?('octokit/octokit.rb', 'holman')
|
387
|
-
def collaborator?(repo, collaborator, options={})
|
377
|
+
def collaborator?(repo, collaborator, options = {})
|
388
378
|
boolean_from_response :get, "#{Repository.path repo}/collaborators/#{collaborator}", options
|
389
379
|
end
|
390
380
|
|
@@ -396,7 +386,7 @@ module Octokit
|
|
396
386
|
# @see https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
|
397
387
|
# @example
|
398
388
|
# @client.permission_level('octokit/octokit.rb', 'lizzhale')
|
399
|
-
def permission_level(repo, collaborator, options={})
|
389
|
+
def permission_level(repo, collaborator, options = {})
|
400
390
|
get "#{Repository.path repo}/collaborators/#{collaborator}/permission", options
|
401
391
|
end
|
402
392
|
|
@@ -416,8 +406,8 @@ module Octokit
|
|
416
406
|
def repository_teams(repo, options = {})
|
417
407
|
paginate "#{Repository.path repo}/teams", options
|
418
408
|
end
|
419
|
-
alias
|
420
|
-
alias
|
409
|
+
alias repo_teams repository_teams
|
410
|
+
alias teams repository_teams
|
421
411
|
|
422
412
|
# List all topics for a repository
|
423
413
|
#
|
@@ -431,8 +421,7 @@ module Octokit
|
|
431
421
|
# @example List topics for octokit/octokit.rb
|
432
422
|
# client.topics('octokit/octokit.rb')
|
433
423
|
def topics(repo, options = {})
|
434
|
-
|
435
|
-
paginate "#{Repository.path repo}/topics", opts
|
424
|
+
paginate "#{Repository.path repo}/topics", options
|
436
425
|
end
|
437
426
|
|
438
427
|
# Replace all topics for a repository
|
@@ -448,8 +437,7 @@ module Octokit
|
|
448
437
|
# @example Clear all topics for octokit/octokit.rb
|
449
438
|
# client.replace_all_topics('octokit/octokit.rb', [])
|
450
439
|
def replace_all_topics(repo, names, options = {})
|
451
|
-
|
452
|
-
put "#{Repository.path repo}/topics", opts.merge(:names => names)
|
440
|
+
put "#{Repository.path repo}/topics", options.merge(names: names)
|
453
441
|
end
|
454
442
|
|
455
443
|
# List contributors to a repo
|
@@ -470,7 +458,7 @@ module Octokit
|
|
470
458
|
options[:anon] = 1 if anon.to_s[/1|true/]
|
471
459
|
paginate "#{Repository.path repo}/contributors", options
|
472
460
|
end
|
473
|
-
alias
|
461
|
+
alias contribs contributors
|
474
462
|
|
475
463
|
# List stargazers of a repo
|
476
464
|
#
|
@@ -520,7 +508,7 @@ module Octokit
|
|
520
508
|
def forks(repo, options = {})
|
521
509
|
paginate "#{Repository.path repo}/forks", options
|
522
510
|
end
|
523
|
-
alias
|
511
|
+
alias network forks
|
524
512
|
|
525
513
|
# List languages of code in the repo.
|
526
514
|
#
|
@@ -576,9 +564,9 @@ module Octokit
|
|
576
564
|
# @example Get branch 'master` from octokit/octokit.rb
|
577
565
|
# Octokit.branch("octokit/octokit.rb", "master")
|
578
566
|
def branch(repo, branch, options = {})
|
579
|
-
get "#{Repository.path repo}/branches/#{branch}", options
|
567
|
+
get "#{Repository.path repo}/branches/#{CGI.escape(branch)}", options
|
580
568
|
end
|
581
|
-
alias
|
569
|
+
alias get_branch branch
|
582
570
|
|
583
571
|
# Lock a single branch from a repository
|
584
572
|
#
|
@@ -601,10 +589,9 @@ module Octokit
|
|
601
589
|
# @example
|
602
590
|
# @client.protect_branch('octokit/octokit.rb', 'master', foo)
|
603
591
|
def protect_branch(repo, branch, options = {})
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
put "#{Repository.path repo}/branches/#{branch}/protection", opts
|
592
|
+
options[:restrictions] ||= nil
|
593
|
+
options[:required_status_checks] ||= nil
|
594
|
+
put "#{Repository.path repo}/branches/#{branch}/protection", options
|
608
595
|
end
|
609
596
|
|
610
597
|
# Get branch protection summary
|
@@ -617,12 +604,9 @@ module Octokit
|
|
617
604
|
# @example
|
618
605
|
# @client.branch_protection('octokit/octokit.rb', 'master')
|
619
606
|
def branch_protection(repo, branch, options = {})
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
rescue Octokit::BranchNotProtected
|
624
|
-
nil
|
625
|
-
end
|
607
|
+
get "#{Repository.path repo}/branches/#{branch}/protection", options
|
608
|
+
rescue Octokit::BranchNotProtected
|
609
|
+
nil
|
626
610
|
end
|
627
611
|
|
628
612
|
# Unlock a single branch from a repository
|
@@ -636,8 +620,7 @@ module Octokit
|
|
636
620
|
# @example
|
637
621
|
# @client.unprotect_branch('octokit/octokit.rb', 'master')
|
638
622
|
def unprotect_branch(repo, branch, options = {})
|
639
|
-
|
640
|
-
boolean_from_response :delete, "#{Repository.path repo}/branches/#{branch}/protection", opts
|
623
|
+
boolean_from_response :delete, "#{Repository.path repo}/branches/#{branch}/protection", options
|
641
624
|
end
|
642
625
|
|
643
626
|
# Rename a single branch from a repository
|
@@ -653,7 +636,7 @@ module Octokit
|
|
653
636
|
# @client.rename_branch('octokit/octokit.rb', 'master', 'main')
|
654
637
|
def rename_branch(repo, branch, new_name, options = {})
|
655
638
|
params = {
|
656
|
-
new_name: new_name
|
639
|
+
new_name: new_name
|
657
640
|
}
|
658
641
|
post "#{Repository.path repo}/branches/#{branch}/rename", params.merge(options)
|
659
642
|
end
|
@@ -674,7 +657,7 @@ module Octokit
|
|
674
657
|
def repository_assignees(repo, options = {})
|
675
658
|
paginate "#{Repository.path repo}/assignees", options
|
676
659
|
end
|
677
|
-
alias
|
660
|
+
alias repo_assignees repository_assignees
|
678
661
|
|
679
662
|
# Check to see if a particular user is an assignee for a repository.
|
680
663
|
#
|
@@ -763,8 +746,7 @@ module Octokit
|
|
763
746
|
# @example
|
764
747
|
# @client.vulnerability_alerts_enabled?("octokit/octokit.rb")
|
765
748
|
def vulnerability_alerts_enabled?(repo, options = {})
|
766
|
-
|
767
|
-
boolean_from_response(:get, "#{Repository.path repo}/vulnerability-alerts", opts)
|
749
|
+
boolean_from_response(:get, "#{Repository.path repo}/vulnerability-alerts", options)
|
768
750
|
end
|
769
751
|
|
770
752
|
# Enable vulnerability alerts for a repository
|
@@ -777,8 +759,7 @@ module Octokit
|
|
777
759
|
# @example Enable vulnerability alerts for a repository
|
778
760
|
# @client.enable_vulnerability_alerts("octokit/octokit.rb")
|
779
761
|
def enable_vulnerability_alerts(repo, options = {})
|
780
|
-
|
781
|
-
boolean_from_response(:put, "#{Repository.path repo}/vulnerability-alerts", opts)
|
762
|
+
boolean_from_response(:put, "#{Repository.path repo}/vulnerability-alerts", options)
|
782
763
|
end
|
783
764
|
|
784
765
|
# Disable vulnerability alerts for a repository
|
@@ -791,8 +772,7 @@ module Octokit
|
|
791
772
|
# @example Disable vulnerability alerts for a repository
|
792
773
|
# @client.disable_vulnerability_alerts("octokit/octokit.rb")
|
793
774
|
def disable_vulnerability_alerts(repo, options = {})
|
794
|
-
|
795
|
-
boolean_from_response(:delete, "#{Repository.path repo}/vulnerability-alerts", opts)
|
775
|
+
boolean_from_response(:delete, "#{Repository.path repo}/vulnerability-alerts", options)
|
796
776
|
end
|
797
777
|
end
|
798
778
|
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 Repository Invitations API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/invitations/
|
7
8
|
module RepositoryInvitations
|
8
|
-
|
9
9
|
# Invite a user to a repository
|
10
10
|
#
|
11
11
|
# Requires authenticated client
|
@@ -64,7 +64,7 @@ module Octokit
|
|
64
64
|
# @return [Array<Sawyer::Resource>] The users repository invitations
|
65
65
|
# @see https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations
|
66
66
|
def user_repository_invitations(options = {})
|
67
|
-
paginate
|
67
|
+
paginate '/user/repository_invitations', options
|
68
68
|
end
|
69
69
|
alias user_repo_invitations user_repository_invitations
|
70
70
|
|