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
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Codespaces Secrets API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/codespaces/
|
8
|
+
module CodespacesSecrets
|
9
|
+
# Get public key for secrets encryption
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Hash] key_id and key
|
13
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets#get-a-repository-public-key
|
14
|
+
def get_codespaces_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/codespaces/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get public key for secrets encryption
|
19
|
+
#
|
20
|
+
# @param org [String] A GitHub organization
|
21
|
+
# @return [Hash] key_id and key
|
22
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key
|
23
|
+
def get_org_codespaces_public_key(org)
|
24
|
+
get "#{Organization.path org}/codespaces/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
27
|
+
# List secrets
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
30
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
31
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#list-repository-secrets
|
32
|
+
def list_codespaces_secrets(repo)
|
33
|
+
paginate "#{Repository.path repo}/codespaces/secrets" do |data, last_response|
|
34
|
+
data.secrets.concat last_response.data.secrets
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# List org secrets
|
39
|
+
#
|
40
|
+
# @param org [String] A GitHub organization
|
41
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
42
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#list-organization-secrets
|
43
|
+
def list_org_codespaces_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/codespaces/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
54
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret
|
55
|
+
def get_codespaces_secret(repo, name)
|
56
|
+
get "#{Repository.path repo}/codespaces/secrets/#{name}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get an org secret
|
60
|
+
#
|
61
|
+
# @param org [String] A GitHub organization
|
62
|
+
# @param name [String] Name of secret
|
63
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
64
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret
|
65
|
+
def get_org_codespaces_secret(org, name)
|
66
|
+
get "#{Organization.path org}/codespaces/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create or update secrets
|
70
|
+
#
|
71
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
72
|
+
# @param name [String] Name of secret
|
73
|
+
# @param options [Hash] encrypted_value and key_id
|
74
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret
|
75
|
+
def create_or_update_codespaces_secret(repo, name, options)
|
76
|
+
put "#{Repository.path repo}/codespaces/secrets/#{name}", options
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create or update org secrets
|
80
|
+
#
|
81
|
+
# @param org [String] A GitHub organization
|
82
|
+
# @param name [String] Name of secret
|
83
|
+
# @param options [Hash] encrypted_value and key_id
|
84
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret
|
85
|
+
def create_or_update_org_codespaces_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/codespaces/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
89
|
+
# Delete a secret
|
90
|
+
#
|
91
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
92
|
+
# @param name [String] Name of secret
|
93
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret
|
94
|
+
def delete_codespaces_secret(repo, name)
|
95
|
+
boolean_from_response :delete, "#{Repository.path repo}/codespaces/secrets/#{name}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete an org secret
|
99
|
+
#
|
100
|
+
# @param org [String] A GitHub organization
|
101
|
+
# @param name [String] Name of secret
|
102
|
+
# @see https://docs.github.com/en/rest/codespaces/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret
|
103
|
+
def delete_org_codespaces_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/codespaces/secrets/#{name}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Commit Pulls API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/repos/comments/
|
8
|
+
module CommitPulls
|
9
|
+
# List pulls for a single commit
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @param sha [String] The SHA of the commit whose pulls will be fetched
|
13
|
+
# @return [Array] List of commit pulls
|
14
|
+
# @see https://developer.github.com/v3/repos/commits/#list-pull-requests-associated-with-commit
|
15
|
+
def commit_pulls(repo, sha, options = {})
|
16
|
+
paginate "#{Repository.path repo}/commits/#{sha}/pulls", options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -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
|
|
@@ -126,19 +118,19 @@ module Octokit
|
|
126
118
|
# @return [Array<Sawyer::Resource>] An array of hashes representing commits
|
127
119
|
# @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
|
128
120
|
# @example
|
129
|
-
# Octokit.
|
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
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Community Profile API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/repos/community/
|
8
|
+
module CommunityProfile
|
9
|
+
# Get community profile metrics for a repository
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Sawyer::Resource] Community profile metrics
|
13
|
+
# @see https://developer.github.com/v3/repos/community/#retrieve-community-profile-metrics
|
14
|
+
# @example Get community profile metrics for octokit/octokit.rb
|
15
|
+
# @client.community_profile('octokit/octokit.rb')
|
16
|
+
def community_profile(repo, options = {})
|
17
|
+
get "#{Repository.path repo}/community/profile", options
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,13 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Octokit
|
4
4
|
class Client
|
5
|
-
|
6
5
|
# Methods for the Repo Contents API
|
7
6
|
#
|
8
7
|
# @see https://developer.github.com/v3/repos/contents/
|
9
8
|
module Contents
|
10
|
-
|
11
9
|
# Receive the default Readme for a repository
|
12
10
|
#
|
13
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -16,7 +14,9 @@ module Octokit
|
|
16
14
|
# @see https://developer.github.com/v3/repos/contents/#get-the-readme
|
17
15
|
# @example Get the readme file for a repo
|
18
16
|
# Octokit.readme("octokit/octokit.rb")
|
19
|
-
|
17
|
+
# @example Get the readme file for a particular branch of the repo
|
18
|
+
# Octokit.readme("octokit/octokit.rb", :query => {:ref => 'some-other-branch'})
|
19
|
+
def readme(repo, options = {})
|
20
20
|
get "#{Repository.path repo}/readme", options
|
21
21
|
end
|
22
22
|
|
@@ -29,12 +29,15 @@ module Octokit
|
|
29
29
|
# @see https://developer.github.com/v3/repos/contents/#get-contents
|
30
30
|
# @example List the contents of lib/octokit.rb
|
31
31
|
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb')
|
32
|
-
|
32
|
+
# @example Lists the contents of lib /octokit.rb on a particular branch
|
33
|
+
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb', :query => {:ref => 'some-other-branch'})
|
34
|
+
def contents(repo, options = {})
|
35
|
+
options = options.dup
|
33
36
|
repo_path = options.delete :path
|
34
37
|
url = "#{Repository.path repo}/contents/#{repo_path}"
|
35
38
|
get url, options
|
36
39
|
end
|
37
|
-
alias
|
40
|
+
alias content contents
|
38
41
|
|
39
42
|
# Add content to a repository
|
40
43
|
#
|
@@ -54,6 +57,7 @@ module Octokit
|
|
54
57
|
# "File content",
|
55
58
|
# :branch => "my-new-feature")
|
56
59
|
def create_contents(*args)
|
60
|
+
args = args.map { |item| item&.dup }
|
57
61
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
58
62
|
repo = args.shift
|
59
63
|
path = args.shift
|
@@ -63,7 +67,7 @@ module Octokit
|
|
63
67
|
case file
|
64
68
|
when String
|
65
69
|
if File.exist?(file)
|
66
|
-
file = File.open(file,
|
70
|
+
file = File.open(file, 'r')
|
67
71
|
content = file.read
|
68
72
|
file.close
|
69
73
|
end
|
@@ -72,17 +76,16 @@ module Octokit
|
|
72
76
|
file.close
|
73
77
|
end
|
74
78
|
end
|
75
|
-
raise ArgumentError
|
76
|
-
|
77
|
-
|
78
|
-
Base64.encode64(content).delete("\n") # Ruby 1.9.2
|
79
|
+
raise ArgumentError, 'content or :file option required' if content.nil?
|
80
|
+
|
81
|
+
options[:content] = [content].pack('m0') # Base64.strict_encode64
|
79
82
|
options[:message] = message
|
80
83
|
url = "#{Repository.path repo}/contents/#{path}"
|
81
84
|
put url, options
|
82
85
|
end
|
83
|
-
alias
|
84
|
-
alias
|
85
|
-
alias
|
86
|
+
alias create_content create_contents
|
87
|
+
alias add_content create_contents
|
88
|
+
alias add_contents create_contents
|
86
89
|
|
87
90
|
# Update content in a repository
|
88
91
|
#
|
@@ -110,10 +113,10 @@ module Octokit
|
|
110
113
|
message = args.shift
|
111
114
|
sha = args.shift
|
112
115
|
content = args.shift
|
113
|
-
options.merge!(:
|
116
|
+
options.merge!(sha: sha)
|
114
117
|
create_contents(repo, path, message, content, options)
|
115
118
|
end
|
116
|
-
alias
|
119
|
+
alias update_content update_contents
|
117
120
|
|
118
121
|
# Delete content in a repository
|
119
122
|
#
|
@@ -136,9 +139,9 @@ module Octokit
|
|
136
139
|
url = "#{Repository.path repo}/contents/#{path}"
|
137
140
|
delete url, options
|
138
141
|
end
|
139
|
-
alias
|
140
|
-
alias
|
141
|
-
alias
|
142
|
+
alias delete_content delete_contents
|
143
|
+
alias remove_content delete_contents
|
144
|
+
alias remove_contents delete_contents
|
142
145
|
|
143
146
|
# This method will provide a URL to download a tarball or zipball archive for a repository.
|
144
147
|
#
|
@@ -149,8 +152,8 @@ module Octokit
|
|
149
152
|
# @see https://developer.github.com/v3/repos/contents/#get-archive-link
|
150
153
|
# @example Get archive link for octokit/octokit.rb
|
151
154
|
# Octokit.archive_link("octokit/octokit.rb")
|
152
|
-
def archive_link(repo, options={})
|
153
|
-
repo_ref = options.delete
|
155
|
+
def archive_link(repo, options = {})
|
156
|
+
repo_ref = ERB::Util.url_encode(options.delete(:ref))
|
154
157
|
format = (options.delete :format) || 'tarball'
|
155
158
|
url = "#{Repository.path repo}/#{format}/#{repo_ref}"
|
156
159
|
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the dependabot Secrets API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/dependabot/
|
8
|
+
module DependabotSecrets
|
9
|
+
# Get public key for secrets encryption
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Hash] key_id and key
|
13
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets#get-a-repository-public-key
|
14
|
+
def get_dependabot_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/dependabot/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get public key for secrets encryption
|
19
|
+
#
|
20
|
+
# @param org [String] A GitHub organization
|
21
|
+
# @return [Hash] key_id and key
|
22
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key
|
23
|
+
def get_org_dependabot_public_key(org)
|
24
|
+
get "#{Organization.path org}/dependabot/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
27
|
+
# List secrets
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
30
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
31
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#list-repository-secrets
|
32
|
+
def list_dependabot_secrets(repo)
|
33
|
+
paginate "#{Repository.path repo}/dependabot/secrets" do |data, last_response|
|
34
|
+
data.secrets.concat last_response.data.secrets
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# List org secrets
|
39
|
+
#
|
40
|
+
# @param org [String] A GitHub organization
|
41
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
42
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#list-organization-secrets
|
43
|
+
def list_org_dependabot_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/dependabot/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
54
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret
|
55
|
+
def get_dependabot_secret(repo, name)
|
56
|
+
get "#{Repository.path repo}/dependabot/secrets/#{name}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get an org secret
|
60
|
+
#
|
61
|
+
# @param org [String] A GitHub organization
|
62
|
+
# @param name [String] Name of secret
|
63
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
64
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret
|
65
|
+
def get_org_dependabot_secret(org, name)
|
66
|
+
get "#{Organization.path org}/dependabot/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create or update secrets
|
70
|
+
#
|
71
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
72
|
+
# @param name [String] Name of secret
|
73
|
+
# @param options [Hash] encrypted_value and key_id
|
74
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret
|
75
|
+
def create_or_update_dependabot_secret(repo, name, options)
|
76
|
+
put "#{Repository.path repo}/dependabot/secrets/#{name}", options
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create or update org secrets
|
80
|
+
#
|
81
|
+
# @param org [String] A GitHub organization
|
82
|
+
# @param name [String] Name of secret
|
83
|
+
# @param options [Hash] encrypted_value and key_id
|
84
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret
|
85
|
+
def create_or_update_org_dependabot_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/dependabot/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
89
|
+
# Delete a secret
|
90
|
+
#
|
91
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
92
|
+
# @param name [String] Name of secret
|
93
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret
|
94
|
+
def delete_dependabot_secret(repo, name)
|
95
|
+
boolean_from_response :delete, "#{Repository.path repo}/dependabot/secrets/#{name}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete an org secret
|
99
|
+
#
|
100
|
+
# @param org [String] A GitHub organization
|
101
|
+
# @param name [String] Name of secret
|
102
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret
|
103
|
+
def delete_org_dependabot_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/dependabot/secrets/#{name}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|