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,28 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Actions Secrets API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/actions/secrets/
|
7
8
|
module ActionsSecrets
|
8
|
-
|
9
9
|
# Get public key for secrets encryption
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
12
|
# @return [Hash] key_id and key
|
13
13
|
# @see https://developer.github.com/v3/actions/secrets/#get-your-public-key
|
14
|
-
def
|
14
|
+
def get_actions_public_key(repo)
|
15
15
|
get "#{Repository.path repo}/actions/secrets/public-key"
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
18
|
# List secrets
|
20
19
|
#
|
21
20
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
22
21
|
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
23
22
|
# @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
|
24
|
-
def
|
25
|
-
paginate "#{Repository.path repo}/actions/secrets"
|
23
|
+
def list_actions_secrets(repo)
|
24
|
+
paginate "#{Repository.path repo}/actions/secrets" do |data, last_response|
|
25
|
+
data.secrets.concat last_response.data.secrets
|
26
|
+
end
|
26
27
|
end
|
27
28
|
|
28
29
|
# Get a secret
|
@@ -31,7 +32,7 @@ module Octokit
|
|
31
32
|
# @param name [String] Name of secret
|
32
33
|
# @return [Hash] name, created_at and updated_at
|
33
34
|
# @see https://developer.github.com/v3/actions/secrets/#get-a-secret
|
34
|
-
def
|
35
|
+
def get_actions_secret(repo, name)
|
35
36
|
get "#{Repository.path repo}/actions/secrets/#{name}"
|
36
37
|
end
|
37
38
|
|
@@ -41,7 +42,7 @@ module Octokit
|
|
41
42
|
# @param name [String] Name of secret
|
42
43
|
# @param options [Hash] encrypted_value and key_id
|
43
44
|
# @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
|
44
|
-
def
|
45
|
+
def create_or_update_actions_secret(repo, name, options)
|
45
46
|
put "#{Repository.path repo}/actions/secrets/#{name}", options
|
46
47
|
end
|
47
48
|
|
@@ -50,7 +51,7 @@ module Octokit
|
|
50
51
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
51
52
|
# @param name [String] Name of secret
|
52
53
|
# @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
|
53
|
-
def
|
54
|
+
def delete_actions_secret(repo, name)
|
54
55
|
boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
|
55
56
|
end
|
56
57
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Actions Workflows jobs API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs
|
8
|
+
module ActionsWorkflowJobs
|
9
|
+
# Get a job for a workflow run
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
# @param job_id [Integer, String] Id of the job
|
13
|
+
#
|
14
|
+
# @return [Sawyer::Resource] Job information
|
15
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run
|
16
|
+
def workflow_run_job(repo, job_id, options = {})
|
17
|
+
get "#{Repository.path repo}/actions/jobs/#{job_id}", options
|
18
|
+
end
|
19
|
+
|
20
|
+
# Download job logs for a workflow run
|
21
|
+
#
|
22
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
23
|
+
# @param job_id [Integer, String] Id of the job
|
24
|
+
#
|
25
|
+
# @return [String] URL to the archived log files of the job
|
26
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run
|
27
|
+
def workflow_run_job_logs(repo, job_id, options = {})
|
28
|
+
url = "#{Repository.path repo}/actions/jobs/#{job_id}/logs"
|
29
|
+
|
30
|
+
response = client_without_redirects.head(url, options)
|
31
|
+
response.headers['Location']
|
32
|
+
end
|
33
|
+
|
34
|
+
# List jobs for a workflow run attempt
|
35
|
+
#
|
36
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
37
|
+
# @param run_id [Integer, String] Id of the workflow run
|
38
|
+
# @param attempt_number [Integer, String] Attempt number of the workflow run
|
39
|
+
#
|
40
|
+
# @return [Sawyer::Resource] Jobs information
|
41
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run-attempt
|
42
|
+
def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})
|
43
|
+
paginate "#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs", options do |data, last_response|
|
44
|
+
data.jobs.concat last_response.data.jobs
|
45
|
+
end
|
46
|
+
end
|
47
|
+
alias list_workflow_run_attempt_jobs workflow_run_attempt_jobs
|
48
|
+
|
49
|
+
# List jobs for a workflow run
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
52
|
+
# @param run_id [Integer, String] Id of the workflow run
|
53
|
+
# @option options [String] :filter Optional filtering by a `completed_at` timestamp
|
54
|
+
#
|
55
|
+
# @return [Sawyer::Resource] Jobs information
|
56
|
+
# @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
|
57
|
+
def workflow_run_jobs(repo, run_id, options = {})
|
58
|
+
paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options do |data, last_response|
|
59
|
+
data.jobs.concat last_response.data.jobs
|
60
|
+
end
|
61
|
+
end
|
62
|
+
alias list_workflow_run_jobs workflow_run_jobs
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,5 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
5
|
+
# Methods for the Actions Workflows runs API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/rest/actions/workflow-runs
|
3
8
|
module ActionsWorkflowRuns
|
4
9
|
# List all runs for a repository workflow
|
5
10
|
#
|
@@ -13,7 +18,9 @@ module Octokit
|
|
13
18
|
# @return [Sawyer::Resource] the total count and an array of workflows
|
14
19
|
# @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
|
15
20
|
def workflow_runs(repo, workflow, options = {})
|
16
|
-
paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options
|
21
|
+
paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options do |data, last_response|
|
22
|
+
data.workflow_runs.concat last_response.data.workflow_runs
|
23
|
+
end
|
17
24
|
end
|
18
25
|
alias list_workflow_runs workflow_runs
|
19
26
|
|
@@ -28,7 +35,9 @@ module Octokit
|
|
28
35
|
# @return [Sawyer::Resource] the total count and an array of workflows
|
29
36
|
# @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
|
30
37
|
def repository_workflow_runs(repo, options = {})
|
31
|
-
paginate "#{Repository.path repo}/actions/runs", options
|
38
|
+
paginate "#{Repository.path repo}/actions/runs", options do |data, last_response|
|
39
|
+
data.workflow_runs.concat last_response.data.workflow_runs
|
40
|
+
end
|
32
41
|
end
|
33
42
|
alias list_repository_workflow_runs repository_workflow_runs
|
34
43
|
|
@@ -90,7 +99,7 @@ module Octokit
|
|
90
99
|
response.headers['Location']
|
91
100
|
end
|
92
101
|
|
93
|
-
#
|
102
|
+
# Delete all log files of a workflow run
|
94
103
|
#
|
95
104
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
96
105
|
# @param id [Integer] Id of a workflow run
|
@@ -100,6 +109,17 @@ module Octokit
|
|
100
109
|
def delete_workflow_run_logs(repo, id, options = {})
|
101
110
|
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
|
102
111
|
end
|
112
|
+
|
113
|
+
# Get workflow run usage
|
114
|
+
#
|
115
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
116
|
+
# @param id [Integer] Id of a workflow run
|
117
|
+
#
|
118
|
+
# @return [Sawyer::Resource] Run usage
|
119
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
|
120
|
+
def workflow_run_usage(repo, id, options = {})
|
121
|
+
get "#{Repository.path repo}/actions/runs/#{id}/timing", options
|
122
|
+
end
|
103
123
|
end
|
104
124
|
end
|
105
125
|
end
|
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
5
|
# Methods for the Actions Workflows API
|
4
6
|
#
|
5
7
|
# @see https://developer.github.com/v3/actions/workflows
|
6
8
|
module ActionsWorkflows
|
7
|
-
|
8
9
|
# Get the workflows in a repository
|
9
10
|
#
|
10
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -12,7 +13,9 @@ module Octokit
|
|
12
13
|
# @return [Sawyer::Resource] the total count and an array of workflows
|
13
14
|
# @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows
|
14
15
|
def workflows(repo, options = {})
|
15
|
-
paginate "#{Repository.path repo}/actions/workflows", options
|
16
|
+
paginate "#{Repository.path repo}/actions/workflows", options do |data, last_response|
|
17
|
+
data.workflows.concat last_response.data.workflows
|
18
|
+
end
|
16
19
|
end
|
17
20
|
alias list_workflows workflows
|
18
21
|
|
@@ -38,6 +41,28 @@ module Octokit
|
|
38
41
|
def workflow_dispatch(repo, id, ref, options = {})
|
39
42
|
boolean_from_response :post, "#{Repository.path repo}/actions/workflows/#{id}/dispatches", options.merge({ ref: ref })
|
40
43
|
end
|
44
|
+
|
45
|
+
# Enable a workflow
|
46
|
+
#
|
47
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
48
|
+
# @param id [Integer, String] Id or file name of the workflow
|
49
|
+
#
|
50
|
+
# @return [Boolean] True if workflow was enabled, false otherwise
|
51
|
+
# @see https://docs.github.com/en/rest/actions/workflows#enable-a-workflow
|
52
|
+
def workflow_enable(repo, id, options = {})
|
53
|
+
boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/enable", options
|
54
|
+
end
|
55
|
+
|
56
|
+
# Disable a workflow
|
57
|
+
#
|
58
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
59
|
+
# @param id [Integer, String] Id or file name of the workflow
|
60
|
+
#
|
61
|
+
# @return [Boolean] True if workflow was disabled, false otherwise
|
62
|
+
# @see https://docs.github.com/en/rest/actions/workflows#disable-a-workflow
|
63
|
+
def workflow_disable(repo, id, options = {})
|
64
|
+
boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/disable", options
|
65
|
+
end
|
41
66
|
end
|
42
67
|
end
|
43
68
|
end
|
data/lib/octokit/client/apps.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Apps API
|
5
6
|
module Apps
|
6
|
-
|
7
7
|
# Get the authenticated App
|
8
8
|
#
|
9
9
|
# @param options [Hash] A customizable set of options
|
@@ -12,7 +12,7 @@ module Octokit
|
|
12
12
|
#
|
13
13
|
# @return [Sawyer::Resource] App information
|
14
14
|
def app(options = {})
|
15
|
-
get
|
15
|
+
get 'app', options
|
16
16
|
end
|
17
17
|
|
18
18
|
# Find all installations that belong to an App
|
@@ -23,16 +23,16 @@ module Octokit
|
|
23
23
|
#
|
24
24
|
# @return [Array<Sawyer::Resource>] the total_count and an array of installations
|
25
25
|
def find_app_installations(options = {})
|
26
|
-
paginate
|
26
|
+
paginate 'app/installations', options
|
27
27
|
end
|
28
28
|
alias find_installations find_app_installations
|
29
29
|
|
30
30
|
def find_integration_installations(options = {})
|
31
31
|
octokit_warn(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
'Deprecated: Octokit::Client::Apps#find_integration_installations ' \
|
33
|
+
'method is deprecated. Please update your call to use ' \
|
34
|
+
'Octokit::Client::Apps#find_app_installations before the next major ' \
|
35
|
+
'Octokit version update.'
|
36
36
|
)
|
37
37
|
find_app_installations(options)
|
38
38
|
end
|
@@ -45,7 +45,7 @@ module Octokit
|
|
45
45
|
#
|
46
46
|
# @return [Sawyer::Resource] the total_count and an array of installations
|
47
47
|
def find_user_installations(options = {})
|
48
|
-
paginate(
|
48
|
+
paginate('user/installations', options) do |data, last_response|
|
49
49
|
data.installations.concat last_response.data.installations
|
50
50
|
end
|
51
51
|
end
|
@@ -76,10 +76,10 @@ module Octokit
|
|
76
76
|
|
77
77
|
def create_integration_installation_access_token(installation, options = {})
|
78
78
|
octokit_warn(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
'Deprecated: Octokit::Client::Apps#create_integration_installation_access_token ' \
|
80
|
+
'method is deprecated. Please update your call to use ' \
|
81
|
+
'Octokit::Client::Apps#create_app_installation_access_token before the next major ' \
|
82
|
+
'Octokit version update.'
|
83
83
|
)
|
84
84
|
create_app_installation_access_token(installation, options)
|
85
85
|
end
|
@@ -128,7 +128,7 @@ module Octokit
|
|
128
128
|
#
|
129
129
|
# @return [Sawyer::Resource] the total_count and an array of repositories
|
130
130
|
def list_app_installation_repositories(options = {})
|
131
|
-
paginate(
|
131
|
+
paginate('installation/repositories', options) do |data, last_response|
|
132
132
|
data.repositories.concat last_response.data.repositories
|
133
133
|
end
|
134
134
|
end
|
@@ -136,10 +136,10 @@ module Octokit
|
|
136
136
|
|
137
137
|
def list_integration_installation_repositories(options = {})
|
138
138
|
octokit_warn(
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
'Deprecated: Octokit::Client::Apps#list_integration_installation_repositories ' \
|
140
|
+
'method is deprecated. Please update your call to use ' \
|
141
|
+
'Octokit::Client::Apps#list_app_installation_repositories before the next major ' \
|
142
|
+
'Octokit version update.'
|
143
143
|
)
|
144
144
|
list_app_installation_repositories(options)
|
145
145
|
end
|
@@ -160,10 +160,10 @@ module Octokit
|
|
160
160
|
|
161
161
|
def add_repository_to_integration_installation(installation, repo, options = {})
|
162
162
|
octokit_warn(
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
163
|
+
'Deprecated: Octokit::Client::Apps#add_repository_to_integration_installation ' \
|
164
|
+
'method is deprecated. Please update your call to use ' \
|
165
|
+
'Octokit::Client::Apps#add_repository_to_app_installation before the next major ' \
|
166
|
+
'Octokit version update.'
|
167
167
|
)
|
168
168
|
add_repository_to_app_installation(installation, repo, options)
|
169
169
|
end
|
@@ -184,10 +184,10 @@ module Octokit
|
|
184
184
|
|
185
185
|
def remove_repository_from_integration_installation(installation, repo, options = {})
|
186
186
|
octokit_warn(
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
187
|
+
'Deprecated: Octokit::Client::Apps#remove_repository_from_integration_installation ' \
|
188
|
+
'method is deprecated. Please update your call to use ' \
|
189
|
+
'Octokit::Client::Apps#remove_repository_from_app_installation before the next major ' \
|
190
|
+
'Octokit version update.'
|
191
191
|
)
|
192
192
|
remove_repository_from_app_installation(installation, repo, options)
|
193
193
|
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 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/
|
@@ -60,9 +60,12 @@ module Octokit
|
|
60
60
|
# result.check_runs[0].id # => 51295429
|
61
61
|
# result.check_runs[0].status # => "in_progress"
|
62
62
|
def check_runs_for_ref(repo, ref, options = {})
|
63
|
-
|
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
|
64
67
|
end
|
65
|
-
alias
|
68
|
+
alias list_check_runs_for_ref check_runs_for_ref
|
66
69
|
|
67
70
|
# List check runs in a check suite
|
68
71
|
#
|
@@ -81,9 +84,12 @@ module Octokit
|
|
81
84
|
# result.check_runs[0].check_suite.id # => 50440400
|
82
85
|
# result.check_runs[0].status # => "in_progress"
|
83
86
|
def check_runs_for_check_suite(repo, id, options = {})
|
84
|
-
|
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
|
85
91
|
end
|
86
|
-
alias
|
92
|
+
alias list_check_runs_for_check_suite check_runs_for_check_suite
|
87
93
|
|
88
94
|
# Get a single check run
|
89
95
|
#
|
@@ -107,7 +113,7 @@ module Octokit
|
|
107
113
|
# annotations[0].path # => "README.md"
|
108
114
|
# annotations[0].message # => "Looks good!"
|
109
115
|
def check_run_annotations(repo, id, options = {})
|
110
|
-
|
116
|
+
paginate "#{Repository.path repo}/check-runs/#{id}/annotations", options
|
111
117
|
end
|
112
118
|
|
113
119
|
# Methods for Check Suites
|
@@ -140,9 +146,12 @@ module Octokit
|
|
140
146
|
# result.check_suites[0].id # => 50440400
|
141
147
|
# result.check_suites[0].app.id # => 76765
|
142
148
|
def check_suites_for_ref(repo, ref, options = {})
|
143
|
-
|
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
|
144
153
|
end
|
145
|
-
alias
|
154
|
+
alias list_check_suites_for_ref check_suites_for_ref
|
146
155
|
|
147
156
|
# Set preferences for check suites on a repository
|
148
157
|
#
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'zlib'
|
6
|
+
|
7
|
+
module Octokit
|
8
|
+
class Client
|
9
|
+
# Methods for the code scanning alerts API
|
10
|
+
#
|
11
|
+
# @see https://docs.github.com/rest/code-scanning
|
12
|
+
module CodeScanning
|
13
|
+
# Uploads SARIF data containing the results of a code scanning analysis
|
14
|
+
#
|
15
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
16
|
+
# @param file [String] Path to the SARIF file to upload
|
17
|
+
# @param sha [String] The SHA of the commit to which the analysis you are uploading relates
|
18
|
+
# @param ref [String] The full Git reference, formatted as `refs/heads/<branch name>`, `refs/pull/<number>/merge`, or `refs/pull/<number>/head`
|
19
|
+
#
|
20
|
+
# @return [Sawyer::Resource] SARIF upload information
|
21
|
+
# @see https://docs.github.com/rest/code-scanning#upload-an-analysis-as-sarif-data
|
22
|
+
def upload_sarif_data(repo, file, sha, ref, options = {})
|
23
|
+
options[:sarif] = compress_sarif_data(file)
|
24
|
+
options[:commit_sha] = sha
|
25
|
+
options[:ref] = ref
|
26
|
+
|
27
|
+
post "#{Repository.path repo}/code-scanning/sarifs", options
|
28
|
+
end
|
29
|
+
|
30
|
+
# Gets information about a SARIF upload
|
31
|
+
#
|
32
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
33
|
+
# @param sarif_id [String] The SARIF ID obtained after uploading
|
34
|
+
#
|
35
|
+
# @return [Sawyer::Resource] SARIF upload information
|
36
|
+
# @see https://docs.github.com/rest/code-scanning#get-information-about-a-sarif-upload
|
37
|
+
def get_sarif_upload_information(repo, sarif_id, options = {})
|
38
|
+
get "#{Repository.path repo}/code-scanning/sarifs/#{sarif_id}", options
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def compress_sarif_data(file)
|
44
|
+
Tempfile.create('sarif.gz') do |tempfile|
|
45
|
+
Zlib::GzipWriter.open(tempfile) do |gz_file|
|
46
|
+
gz_file.write File.binread(file)
|
47
|
+
end
|
48
|
+
Base64.strict_encode64(tempfile.read)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,59 @@
|
|
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
|
+
# List secrets
|
19
|
+
#
|
20
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
21
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
22
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#list-repository-secrets
|
23
|
+
def list_codespaces_secrets(repo)
|
24
|
+
paginate "#{Repository.path repo}/codespaces/secrets" do |data, last_response|
|
25
|
+
data.secrets.concat last_response.data.secrets
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get a secret
|
30
|
+
#
|
31
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
32
|
+
# @param name [String] Name of secret
|
33
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
34
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret
|
35
|
+
def get_codespaces_secret(repo, name)
|
36
|
+
get "#{Repository.path repo}/codespaces/secrets/#{name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create or update secrets
|
40
|
+
#
|
41
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
42
|
+
# @param name [String] Name of secret
|
43
|
+
# @param options [Hash] encrypted_value and key_id
|
44
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret
|
45
|
+
def create_or_update_codespaces_secret(repo, name, options)
|
46
|
+
put "#{Repository.path repo}/codespaces/secrets/#{name}", options
|
47
|
+
end
|
48
|
+
|
49
|
+
# Delete a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @see https://docs.github.com/en/rest/codespaces/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret
|
54
|
+
def delete_codespaces_secret(repo, name)
|
55
|
+
boolean_from_response :delete, "#{Repository.path repo}/codespaces/secrets/#{name}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
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 Branches for HEAD API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/commits/
|
7
8
|
module CommitBranches
|
8
|
-
|
9
9
|
# List branches for a single HEAD commit
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -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
|