octokit 4.22.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 +4 -4
- data/README.md +117 -95
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +10 -3
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +111 -8
- 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 +63 -26
- data/lib/octokit/client/checks.rb +18 -9
- 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 +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 +19 -22
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +8 -8
- 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 -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 +1 -7
- 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/pull_requests.rb +66 -45
- data/lib/octokit/client/rate_limit.rb +9 -11
- data/lib/octokit/client/reactions.rb +62 -16
- data/lib/octokit/client/refs.rb +14 -17
- data/lib/octokit/client/releases.rb +13 -13
- data/lib/octokit/client/repositories.rb +92 -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 +54 -33
- data/lib/octokit/client.rb +42 -18
- data/lib/octokit/configurable.rb +51 -31
- data/lib/octokit/connection.rb +30 -21
- data/lib/octokit/default.rb +66 -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 +51 -33
- data/lib/octokit/enterprise_management_console_client.rb +8 -2
- data/lib/octokit/error.rb +51 -34
- data/lib/octokit/gist.rb +3 -4
- 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 +13 -12
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +8 -6
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +32 -25
- 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 +30 -8
- data/octokit.gemspec +12 -11
- metadata +19 -31
- data/lib/octokit/client/authorizations.rb +0 -182
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -46
@@ -0,0 +1,190 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
require 'zlib'
|
5
|
+
|
6
|
+
module Octokit
|
7
|
+
class Client
|
8
|
+
# Methods for the code scanning alerts API
|
9
|
+
#
|
10
|
+
# @see https://docs.github.com/rest/code-scanning
|
11
|
+
module CodeScanning
|
12
|
+
# Updates a code scanning default setup configuration
|
13
|
+
#
|
14
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
15
|
+
# @param state [String] The desired state of code scanning default setup
|
16
|
+
# @param query_suite [String] CodeQL query suite to be used
|
17
|
+
# @param languages [Array] List of CodeQL languages to be analyzed
|
18
|
+
#
|
19
|
+
# @return [Sawyer::Resource] Action Run information
|
20
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#update-a-code-scanning-default-setup-configuration
|
21
|
+
def update_code_scanning_default_config(repo, state, query_suite = nil, languages = nil, options = {})
|
22
|
+
options[:state] = state
|
23
|
+
options[:query_suite] = query_suite if query_suite
|
24
|
+
options[:languages] = languages if languages
|
25
|
+
|
26
|
+
patch "#{Repository.path repo}/code-scanning/default-setup", options
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get Code Scanning Default Configuration
|
30
|
+
#
|
31
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
32
|
+
#
|
33
|
+
# @return [Sawyer::Resource] CodeQl Default Setup Configuration Information
|
34
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-default-setup-configuration
|
35
|
+
def get_code_scanning_default_config(repo, options = {})
|
36
|
+
get "#{Repository.path repo}/code-scanning/default-setup", options
|
37
|
+
end
|
38
|
+
|
39
|
+
# Gets a CodeQL database for a language in a repository
|
40
|
+
#
|
41
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
42
|
+
# @param language [String]
|
43
|
+
#
|
44
|
+
# @return [Sawyer::Resource] CodeQl Default Setup Configuration Information
|
45
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-codeql-database-for-a-repository
|
46
|
+
def get_codeql_database_for_repo(repo, language, options = {})
|
47
|
+
get "#{Repository.path repo}/code-scanning/codeql/databases/#{language}", options
|
48
|
+
end
|
49
|
+
|
50
|
+
# Lists the CodeQL databases that are available in a repository
|
51
|
+
#
|
52
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
53
|
+
#
|
54
|
+
# @return [Array] List of CodeQL Databases
|
55
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-codeql-databases-for-a-repository
|
56
|
+
def list_codeql_database_for_repo(repo, options = {})
|
57
|
+
get "#{Repository.path repo}/code-scanning/codeql/databases", options
|
58
|
+
end
|
59
|
+
|
60
|
+
# Delete a specified code scanning analysis from a repository
|
61
|
+
#
|
62
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
63
|
+
# @param analysis_id [Integer] ID of the code scanning analysis
|
64
|
+
#
|
65
|
+
# @return [Sawyer::Resource] Next Code Scanning Analysis Information
|
66
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#delete-a-code-scanning-analysis-from-a-repository
|
67
|
+
def delete_code_scanning_analysis(repo, analysis_id, options = {})
|
68
|
+
delete "#{Repository.path repo}/code-scanning/analyses/#{analysis_id}", options
|
69
|
+
end
|
70
|
+
|
71
|
+
# Get a code scanning analysis for a repository
|
72
|
+
#
|
73
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
74
|
+
# @param analysis_id [Integer] ID of the code scanning analysis
|
75
|
+
#
|
76
|
+
# @return [Sawyer::Resource] Code Scanning Analysis
|
77
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-analysis-for-a-repository
|
78
|
+
def get_code_scanning_analysis(repo, analysis_id, options = {})
|
79
|
+
get "#{Repository.path repo}/code-scanning/analyses/#{analysis_id}", options
|
80
|
+
end
|
81
|
+
|
82
|
+
# List code scanning analyses for a repository
|
83
|
+
#
|
84
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
85
|
+
#
|
86
|
+
# @return [Array] List of Code Scanning Analyses
|
87
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-analyses-for-a-repository
|
88
|
+
def list_code_scanning_analysis(repo, options = {})
|
89
|
+
paginate "#{Repository.path repo}/code-scanning/analyses", options
|
90
|
+
end
|
91
|
+
|
92
|
+
# List instances of a code scanning alert
|
93
|
+
#
|
94
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
95
|
+
# @param alert_number [Integer] The number that identifies an alert
|
96
|
+
#
|
97
|
+
# @return [Array] List of Code Scanning Alerts
|
98
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-instances-of-a-code-scanning-alert
|
99
|
+
def list_instances_of_code_scanning_alert(repo, alert_number, options = {})
|
100
|
+
paginate "#{Repository.path repo}/code-scanning/alerts/#{alert_number}/instances", options
|
101
|
+
end
|
102
|
+
|
103
|
+
# Update a code scanning alert
|
104
|
+
#
|
105
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
106
|
+
# @param alert_number [Integer] The number that identifies an alert
|
107
|
+
# @param state [String] The reason for dismissing or closing the alert. Required when the state is dismissed
|
108
|
+
#
|
109
|
+
# @return [Sawyer::Resource] Code Scanning Alert information
|
110
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#update-a-code-scanning-alert
|
111
|
+
def update_code_scanning_alert(repo, alert_number, state, reason, comment = nil, options = {})
|
112
|
+
options[:state] = state
|
113
|
+
options[:dismissed_reason] = reason
|
114
|
+
options[:dismissed_comment] = comment if comment
|
115
|
+
|
116
|
+
patch "#{Repository.path repo}/code-scanning/alerts/#{alert_number}", options
|
117
|
+
end
|
118
|
+
|
119
|
+
# Gets a single code scanning alert
|
120
|
+
#
|
121
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
122
|
+
# @param alert_number [Integer] The number that identifies an alert
|
123
|
+
#
|
124
|
+
# @return [Sawyer::Resource] Code Scanning Alert
|
125
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#get-a-code-scanning-alert
|
126
|
+
def get_code_scanning_alert(repo, alert_number, options = {})
|
127
|
+
get "#{Repository.path repo}/code-scanning/alerts/#{alert_number}", options
|
128
|
+
end
|
129
|
+
|
130
|
+
# List code scanning alerts for a repository
|
131
|
+
#
|
132
|
+
# @param org [String] A GitHub organization
|
133
|
+
#
|
134
|
+
# @return [Array] Code Scanning Alert information
|
135
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-a-repository
|
136
|
+
def list_code_scanning_alerts_for_repo(repo, options = {})
|
137
|
+
paginate "#{Repository.path repo}/code-scanning/alerts", options
|
138
|
+
end
|
139
|
+
|
140
|
+
# List code scanning alerts for an organization
|
141
|
+
#
|
142
|
+
# @param org [String] A GitHub organization
|
143
|
+
#
|
144
|
+
# @return [Array] Code Scanning Alert information
|
145
|
+
# @see https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-an-organization
|
146
|
+
def list_code_scanning_alerts_for_org(org, options = {})
|
147
|
+
paginate "orgs/#{org}/code-scanning/alerts", options
|
148
|
+
end
|
149
|
+
|
150
|
+
# Uploads SARIF data containing the results of a code scanning analysis
|
151
|
+
#
|
152
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
153
|
+
# @param file [String] Path to the SARIF file to upload
|
154
|
+
# @param sha [String] The SHA of the commit to which the analysis you are uploading relates
|
155
|
+
# @param ref [String] The full Git reference, formatted as `refs/heads/<branch name>`, `refs/pull/<number>/merge`, or `refs/pull/<number>/head`
|
156
|
+
#
|
157
|
+
# @return [Sawyer::Resource] SARIF upload information
|
158
|
+
# @see https://docs.github.com/rest/code-scanning#upload-an-analysis-as-sarif-data
|
159
|
+
def upload_sarif_data(repo, file, sha, ref, options = {})
|
160
|
+
options[:sarif] = compress_sarif_data(file)
|
161
|
+
options[:commit_sha] = sha
|
162
|
+
options[:ref] = ref
|
163
|
+
|
164
|
+
post "#{Repository.path repo}/code-scanning/sarifs", options
|
165
|
+
end
|
166
|
+
|
167
|
+
# Gets information about a SARIF upload
|
168
|
+
#
|
169
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
170
|
+
# @param sarif_id [String] The SARIF ID obtained after uploading
|
171
|
+
#
|
172
|
+
# @return [Sawyer::Resource] SARIF upload information
|
173
|
+
# @see https://docs.github.com/rest/code-scanning#get-information-about-a-sarif-upload
|
174
|
+
def get_sarif_upload_information(repo, sarif_id, options = {})
|
175
|
+
get "#{Repository.path repo}/code-scanning/sarifs/#{sarif_id}", options
|
176
|
+
end
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def compress_sarif_data(file)
|
181
|
+
Tempfile.create('sarif.gz') do |tempfile|
|
182
|
+
Zlib::GzipWriter.open(tempfile) do |gz_file|
|
183
|
+
gz_file.write File.binread(file)
|
184
|
+
end
|
185
|
+
[tempfile.read].pack('m0') # Base64.strict_encode64
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
@@ -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
|
@@ -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
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
|
3
5
|
module Octokit
|
4
6
|
class Client
|
5
|
-
|
6
7
|
# Methods for the Commits API
|
7
8
|
#
|
8
9
|
# @see https://developer.github.com/v3/repos/commits/
|
9
10
|
module Commits
|
10
|
-
|
11
11
|
# List commits
|
12
12
|
#
|
13
13
|
# @overload commits(repo, sha_or_branch, options = {})
|
@@ -23,12 +23,10 @@ module Octokit
|
|
23
23
|
def commits(*args)
|
24
24
|
arguments = Octokit::RepoArguments.new(args)
|
25
25
|
sha_or_branch = arguments.pop
|
26
|
-
if sha_or_branch
|
27
|
-
arguments.options[:sha] = sha_or_branch
|
28
|
-
end
|
26
|
+
arguments.options[:sha] = sha_or_branch if sha_or_branch
|
29
27
|
paginate "#{Repository.new(arguments.repo).path}/commits", arguments.options
|
30
28
|
end
|
31
|
-
alias
|
29
|
+
alias list_commits commits
|
32
30
|
|
33
31
|
# Get commits after a specified date
|
34
32
|
#
|
@@ -48,13 +46,11 @@ module Octokit
|
|
48
46
|
# Octokit.commits_since('octokit/octokit.rb', '2012-10-01')
|
49
47
|
def commits_since(*args)
|
50
48
|
arguments = Octokit::RepoArguments.new(args)
|
51
|
-
date
|
49
|
+
date = parse_date(arguments.shift)
|
52
50
|
params = arguments.options
|
53
|
-
params.merge!(:
|
51
|
+
params.merge!(since: iso8601(date))
|
54
52
|
sha_or_branch = arguments.pop
|
55
|
-
if sha_or_branch
|
56
|
-
params[:sha] = sha_or_branch
|
57
|
-
end
|
53
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
58
54
|
commits(arguments.repo, params)
|
59
55
|
end
|
60
56
|
|
@@ -74,13 +70,11 @@ module Octokit
|
|
74
70
|
# Octokit.commits_before('octokit/octokit.rb', '2012-10-01')
|
75
71
|
def commits_before(*args)
|
76
72
|
arguments = Octokit::RepoArguments.new(args)
|
77
|
-
date
|
73
|
+
date = parse_date(arguments.shift)
|
78
74
|
params = arguments.options
|
79
|
-
params.merge!(:
|
75
|
+
params.merge!(until: iso8601(date))
|
80
76
|
sha_or_branch = arguments.pop
|
81
|
-
if sha_or_branch
|
82
|
-
params[:sha] = sha_or_branch
|
83
|
-
end
|
77
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
84
78
|
commits(arguments.repo, params)
|
85
79
|
end
|
86
80
|
|
@@ -100,14 +94,12 @@ module Octokit
|
|
100
94
|
# Octokit.commits_on('octokit/octokit.rb', '2012-10-01')
|
101
95
|
def commits_on(*args)
|
102
96
|
arguments = Octokit::RepoArguments.new(args)
|
103
|
-
date
|
97
|
+
date = parse_date(arguments.shift)
|
104
98
|
params = arguments.options
|
105
99
|
end_date = date + 1
|
106
|
-
params.merge!(:
|
100
|
+
params.merge!(since: iso8601(date), until: iso8601(end_date))
|
107
101
|
sha_or_branch = arguments.pop
|
108
|
-
if sha_or_branch
|
109
|
-
params[:sha] = sha_or_branch
|
110
|
-
end
|
102
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
111
103
|
commits(arguments.repo, params)
|
112
104
|
end
|
113
105
|
|
@@ -129,16 +121,16 @@ module Octokit
|
|
129
121
|
# Octokit.commits_between('octokit/octokit.rb', '2012-10-01', '2012-11-01')
|
130
122
|
def commits_between(*args)
|
131
123
|
arguments = Octokit::RepoArguments.new(args)
|
132
|
-
date
|
133
|
-
end_date
|
134
|
-
|
124
|
+
date = parse_date(arguments.shift)
|
125
|
+
end_date = parse_date(arguments.shift)
|
126
|
+
if date > end_date
|
127
|
+
raise ArgumentError, "Start date #{date} does not precede #{end_date}"
|
128
|
+
end
|
135
129
|
|
136
130
|
params = arguments.options
|
137
|
-
params.merge!(:
|
131
|
+
params.merge!(since: iso8601(date), until: iso8601(end_date))
|
138
132
|
sha_or_branch = arguments.pop
|
139
|
-
if sha_or_branch
|
140
|
-
params[:sha] = sha_or_branch
|
141
|
-
end
|
133
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
142
134
|
commits(arguments.repo, params)
|
143
135
|
end
|
144
136
|
|
@@ -181,8 +173,8 @@ 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
|
@@ -213,8 +205,8 @@ module Octokit
|
|
213
205
|
# @see https://developer.github.com/v3/repos/merging/#perform-a-merge
|
214
206
|
def merge(repo, base, head, options = {})
|
215
207
|
params = {
|
216
|
-
:
|
217
|
-
:
|
208
|
+
base: base,
|
209
|
+
head: head
|
218
210
|
}.merge(options)
|
219
211
|
post "#{Repository.path repo}/merges", params
|
220
212
|
end
|
@@ -225,7 +217,7 @@ module Octokit
|
|
225
217
|
if date.respond_to?(:iso8601)
|
226
218
|
date.iso8601
|
227
219
|
else
|
228
|
-
date.strftime(
|
220
|
+
date.strftime('%Y-%m-%dT%H:%M:%S%Z')
|
229
221
|
end
|
230
222
|
end
|
231
223
|
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Community Profile API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/community/
|
7
8
|
module CommunityProfile
|
8
|
-
|
9
9
|
# Get community profile metrics for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -14,7 +14,6 @@ module Octokit
|
|
14
14
|
# @example Get community profile metrics for octokit/octokit.rb
|
15
15
|
# @client.community_profile('octokit/octokit.rb')
|
16
16
|
def community_profile(repo, options = {})
|
17
|
-
options = ensure_api_media_type(:community_profile, options)
|
18
17
|
get "#{Repository.path repo}/community/profile", options
|
19
18
|
end
|
20
19
|
end
|
@@ -1,13 +1,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
|
@@ -18,7 +16,7 @@ module Octokit
|
|
18
16
|
# Octokit.readme("octokit/octokit.rb")
|
19
17
|
# @example Get the readme file for a particular branch of the repo
|
20
18
|
# Octokit.readme("octokit/octokit.rb", :query => {:ref => 'some-other-branch'})
|
21
|
-
def readme(repo, options={})
|
19
|
+
def readme(repo, options = {})
|
22
20
|
get "#{Repository.path repo}/readme", options
|
23
21
|
end
|
24
22
|
|
@@ -33,13 +31,13 @@ module Octokit
|
|
33
31
|
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb')
|
34
32
|
# @example Lists the contents of lib /octokit.rb on a particular branch
|
35
33
|
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb', :query => {:ref => 'some-other-branch'})
|
36
|
-
def contents(repo, options={})
|
34
|
+
def contents(repo, options = {})
|
37
35
|
options = options.dup
|
38
36
|
repo_path = options.delete :path
|
39
37
|
url = "#{Repository.path repo}/contents/#{repo_path}"
|
40
38
|
get url, options
|
41
39
|
end
|
42
|
-
alias
|
40
|
+
alias content contents
|
43
41
|
|
44
42
|
# Add content to a repository
|
45
43
|
#
|
@@ -59,7 +57,7 @@ module Octokit
|
|
59
57
|
# "File content",
|
60
58
|
# :branch => "my-new-feature")
|
61
59
|
def create_contents(*args)
|
62
|
-
args = args.map { |item| item
|
60
|
+
args = args.map { |item| item&.dup }
|
63
61
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
64
62
|
repo = args.shift
|
65
63
|
path = args.shift
|
@@ -69,7 +67,7 @@ module Octokit
|
|
69
67
|
case file
|
70
68
|
when String
|
71
69
|
if File.exist?(file)
|
72
|
-
file = File.open(file,
|
70
|
+
file = File.open(file, 'r')
|
73
71
|
content = file.read
|
74
72
|
file.close
|
75
73
|
end
|
@@ -78,17 +76,16 @@ module Octokit
|
|
78
76
|
file.close
|
79
77
|
end
|
80
78
|
end
|
81
|
-
raise ArgumentError
|
82
|
-
|
83
|
-
|
84
|
-
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
|
85
82
|
options[:message] = message
|
86
83
|
url = "#{Repository.path repo}/contents/#{path}"
|
87
84
|
put url, options
|
88
85
|
end
|
89
|
-
alias
|
90
|
-
alias
|
91
|
-
alias
|
86
|
+
alias create_content create_contents
|
87
|
+
alias add_content create_contents
|
88
|
+
alias add_contents create_contents
|
92
89
|
|
93
90
|
# Update content in a repository
|
94
91
|
#
|
@@ -116,10 +113,10 @@ module Octokit
|
|
116
113
|
message = args.shift
|
117
114
|
sha = args.shift
|
118
115
|
content = args.shift
|
119
|
-
options.merge!(:
|
116
|
+
options.merge!(sha: sha)
|
120
117
|
create_contents(repo, path, message, content, options)
|
121
118
|
end
|
122
|
-
alias
|
119
|
+
alias update_content update_contents
|
123
120
|
|
124
121
|
# Delete content in a repository
|
125
122
|
#
|
@@ -142,9 +139,9 @@ module Octokit
|
|
142
139
|
url = "#{Repository.path repo}/contents/#{path}"
|
143
140
|
delete url, options
|
144
141
|
end
|
145
|
-
alias
|
146
|
-
alias
|
147
|
-
alias
|
142
|
+
alias delete_content delete_contents
|
143
|
+
alias remove_content delete_contents
|
144
|
+
alias remove_contents delete_contents
|
148
145
|
|
149
146
|
# This method will provide a URL to download a tarball or zipball archive for a repository.
|
150
147
|
#
|
@@ -155,8 +152,8 @@ module Octokit
|
|
155
152
|
# @see https://developer.github.com/v3/repos/contents/#get-archive-link
|
156
153
|
# @example Get archive link for octokit/octokit.rb
|
157
154
|
# Octokit.archive_link("octokit/octokit.rb")
|
158
|
-
def archive_link(repo, options={})
|
159
|
-
repo_ref = options.delete
|
155
|
+
def archive_link(repo, options = {})
|
156
|
+
repo_ref = ERB::Util.url_encode(options.delete(:ref))
|
160
157
|
format = (options.delete :format) || 'tarball'
|
161
158
|
url = "#{Repository.path repo}/#{format}/#{repo_ref}"
|
162
159
|
|