octokit 6.1.1 → 7.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68c11fbd1bb2d452acf5bbebf33974285207aa99513b22b4ff8d208e01f76e11
4
- data.tar.gz: 63c099454a0ffcdbc621990114adbec36d44535929dfbfacaf09bb3d1b34394f
3
+ metadata.gz: 27b858e49de1997cc637b78dd77f283f49164e16783d58b665e55da23a2fe957
4
+ data.tar.gz: f2447bb4e8e8a15e45eb43ebf771a4a04d2fbb9f1615ef9cd835347bb289f33f
5
5
  SHA512:
6
- metadata.gz: a7ed6fb3bdf0b189ed74e8d12705fd9c377407910a6f8f5a8bd6a16f47326b86126dbf973fbbd6045c3b7f31202fa8af9120fbf8acf99cab1f26765be8413bfc
7
- data.tar.gz: 52da944c212373baa9a68476e719dd5b2156bccbd09f0d6028edcf34ca90e15961499cfc88acda86ac7fa6625576005cf79d1c2c7eb8cd9f6f2c453317bbe054
6
+ metadata.gz: 6e616a14ccdeba68b690f0d3956a6e8eaf45963615231c9c2d95bbef41d3da5bba70401aff57676bdcefcd9d49095cf19932c1383cd8c5d8bb9f54d246f5a48d
7
+ data.tar.gz: afeaa8ff5a087af75af032b14ffb7428614bd76827fd987a35f36614601ed62d2592961ef09327357ec7b1378ca6b214ef251daa5be5afab5bee5e1c8656fd1f
data/Rakefile CHANGED
@@ -3,12 +3,18 @@
3
3
  require 'bundler'
4
4
  Bundler::GemHelper.install_tasks
5
5
 
6
- require 'rspec/core/rake_task'
7
- RSpec::Core::RakeTask.new(:spec)
8
-
9
6
  task test: :spec
10
7
  task default: :spec
11
8
 
9
+ desc 'Run RSpec'
10
+ task :spec do
11
+ if Process.respond_to?(:fork)
12
+ sh('rspec-queue')
13
+ else
14
+ sh('rspec')
15
+ end
16
+ end
17
+
12
18
  namespace :doc do
13
19
  require 'yard'
14
20
  YARD::Rake::YardocTask.new do |task|
@@ -11,7 +11,7 @@ module Octokit
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 get_public_key(repo)
14
+ def get_actions_public_key(repo)
15
15
  get "#{Repository.path repo}/actions/secrets/public-key"
16
16
  end
17
17
 
@@ -20,7 +20,7 @@ module Octokit
20
20
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
21
21
  # @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
22
22
  # @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
23
- def list_secrets(repo)
23
+ def list_actions_secrets(repo)
24
24
  paginate "#{Repository.path repo}/actions/secrets" do |data, last_response|
25
25
  data.secrets.concat last_response.data.secrets
26
26
  end
@@ -32,7 +32,7 @@ module Octokit
32
32
  # @param name [String] Name of secret
33
33
  # @return [Hash] name, created_at and updated_at
34
34
  # @see https://developer.github.com/v3/actions/secrets/#get-a-secret
35
- def get_secret(repo, name)
35
+ def get_actions_secret(repo, name)
36
36
  get "#{Repository.path repo}/actions/secrets/#{name}"
37
37
  end
38
38
 
@@ -42,7 +42,7 @@ module Octokit
42
42
  # @param name [String] Name of secret
43
43
  # @param options [Hash] encrypted_value and key_id
44
44
  # @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
45
- def create_or_update_secret(repo, name, options)
45
+ def create_or_update_actions_secret(repo, name, options)
46
46
  put "#{Repository.path repo}/actions/secrets/#{name}", options
47
47
  end
48
48
 
@@ -51,9 +51,62 @@ module Octokit
51
51
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
52
52
  # @param name [String] Name of secret
53
53
  # @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
54
- def delete_secret(repo, name)
54
+ def delete_actions_secret(repo, name)
55
55
  boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
56
56
  end
57
+
58
+ # Get environment public key for secrets encryption
59
+ #
60
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
61
+ # @param environment [String] Name of environment
62
+ # @return [Hash] key_id and key
63
+ # @see https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key
64
+ def get_actions_environment_public_key(repo, environment)
65
+ get "#{Repository.path repo}/environments/#{environment}/secrets/public-key"
66
+ end
67
+
68
+ # List environment secrets
69
+ #
70
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
71
+ # @param environment [String] Name of environment
72
+ # @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
73
+ # @see https://developer.github.com/v3/actions/secrets/#list-environment-secrets
74
+ def list_actions_environment_secrets(repo, environment)
75
+ paginate "#{Repository.path repo}/environments/#{environment}/secrets" do |data, last_response|
76
+ data.secrets.concat last_response.data.secrets
77
+ end
78
+ end
79
+
80
+ # Get an environment secret
81
+ #
82
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
83
+ # @param environment [String] Name of environment
84
+ # @param name [String] Name of secret
85
+ # @return [Hash] name, created_at and updated_at
86
+ # @see https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret
87
+ def get_actions_environment_secret(repo, environment, name)
88
+ get "#{Repository.path repo}/environments/#{environment}/secrets/#{name}"
89
+ end
90
+
91
+ # Create or update an environment secret
92
+ #
93
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
94
+ # @param environment [String] Name of environment
95
+ # @param name [String] Name of secret
96
+ # @param options [Hash] encrypted_value and key_id
97
+ # @see https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret
98
+ def create_or_update_actions_environment_secret(repo, environment, name, options)
99
+ put "#{Repository.path repo}/environments/#{environment}/secrets/#{name}", options
100
+ end
101
+
102
+ # Delete environment secret
103
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
104
+ # @param environment [String] Name of environment
105
+ # @param name [String] Name of secret
106
+ # @see https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret
107
+ def delete_actions_environment_secret(repo, environment, name)
108
+ boolean_from_response :delete, "#{Repository.path repo}/environments/#{environment}/secrets/#{name}"
109
+ end
57
110
  end
58
111
  end
59
112
  end
@@ -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
@@ -0,0 +1,59 @@
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
+ # 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/dependabot/repository-secrets?apiVersion=2022-11-28#list-repository-secrets
23
+ def list_dependabot_secrets(repo)
24
+ paginate "#{Repository.path repo}/dependabot/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/dependabot/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret
35
+ def get_dependabot_secret(repo, name)
36
+ get "#{Repository.path repo}/dependabot/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/dependabot/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret
45
+ def create_or_update_dependabot_secret(repo, name, options)
46
+ put "#{Repository.path repo}/dependabot/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/dependabot/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret
54
+ def delete_dependabot_secret(repo, name)
55
+ boolean_from_response :delete, "#{Repository.path repo}/dependabot/secrets/#{name}"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -71,7 +71,7 @@ module Octokit
71
71
  # Nonauthenticated calls to this method will return organizations that
72
72
  # the user is a public member.
73
73
  #
74
- # Use an authenicated client to get both public and private organizations
74
+ # Use an authenticated client to get both public and private organizations
75
75
  # for a user.
76
76
  #
77
77
  # Calling this method on a `@client` will return that users organizations.
@@ -199,11 +199,13 @@ module Octokit
199
199
  # @param path [String] Relative path of the file to comment on.
200
200
  # @param position [Integer] Line index in the diff to comment on.
201
201
  # @return [Sawyer::Resource] Hash representing the new comment
202
+ # @deprecated The position will be deprecated in the next major version. Please refer to the details below.
202
203
  # @see https://developer.github.com/v3/pulls/comments/#create-a-comment
203
204
  # @example
204
205
  # @client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
205
206
  # "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
206
207
  def create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {})
208
+ octokit_warn 'Deprecated: The position will be deprecated in the next major version.'
207
209
  options.merge!({
208
210
  body: body,
209
211
  commit_id: commit_id,
@@ -137,16 +137,18 @@ module Octokit
137
137
 
138
138
  # Delete a reaction
139
139
  #
140
- # @param id [Integer] Reaction id
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
141
143
  #
142
- # @see https://developer.github.com/v3/reactions/#delete-a-reaction
144
+ # @see https://docs.github.com/en/rest/reactions/reactions#delete-an-issue-reaction
143
145
  #
144
146
  # @example
145
- # @client.delete_reaction(1)
147
+ # @client.delete_issue_reaction("octokit/octokit.rb", 1, 2)
146
148
  #
147
149
  # @return [Boolean] Return true if reaction was deleted, false otherwise.
148
- def delete_reaction(id, options = {})
149
- 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
150
152
  end
151
153
  end
152
154
  end
@@ -151,7 +151,7 @@ module Octokit
151
151
  # @param number [Integer] Number ID of the pull request
152
152
  # @param reviewers [Hash] :reviewers [Array<String>] An array of user logins
153
153
  # @param options [Hash] :team_reviewers [Array<String>] An array of team slugs
154
- # @see https://developer.github.com/v3/pulls/review_requests/#create-a-review-request
154
+ # @see https://developer.github.com/v3/pulls/review_requests/#request-reviewers-for-a-pull-request
155
155
  #
156
156
  # @example
157
157
  # @client.request_pull_request_review('octokit/octokit.rb', 2, reviewers: ['soudy'])
@@ -18,6 +18,8 @@ require 'octokit/client/actions_workflow_jobs'
18
18
  require 'octokit/client/actions_workflow_runs'
19
19
  require 'octokit/client/apps'
20
20
  require 'octokit/client/checks'
21
+ require 'octokit/client/code_scanning'
22
+ require 'octokit/client/codespaces_secrets'
21
23
  require 'octokit/client/commits'
22
24
  require 'octokit/client/commit_comments'
23
25
  require 'octokit/client/commit_pulls'
@@ -25,6 +27,7 @@ require 'octokit/client/commit_branches'
25
27
  require 'octokit/client/community_profile'
26
28
  require 'octokit/client/contents'
27
29
  require 'octokit/client/downloads'
30
+ require 'octokit/client/dependabot_secrets'
28
31
  require 'octokit/client/deployments'
29
32
  require 'octokit/client/environments'
30
33
  require 'octokit/client/emojis'
@@ -79,12 +82,15 @@ module Octokit
79
82
  include Octokit::Client::ActionsArtifacts
80
83
  include Octokit::Client::ActionsSecrets
81
84
  include Octokit::Client::Checks
85
+ include Octokit::Client::CodeScanning
86
+ include Octokit::Client::CodespacesSecrets
82
87
  include Octokit::Client::Commits
83
88
  include Octokit::Client::CommitComments
84
89
  include Octokit::Client::CommitPulls
85
90
  include Octokit::Client::CommitBranches
86
91
  include Octokit::Client::CommunityProfile
87
92
  include Octokit::Client::Contents
93
+ include Octokit::Client::DependabotSecrets
88
94
  include Octokit::Client::Deployments
89
95
  include Octokit::Client::Downloads
90
96
  include Octokit::Client::Environments
@@ -48,7 +48,8 @@ module Octokit
48
48
  # @return [String] Repository API path
49
49
  def path
50
50
  return named_api_path if @owner && @name
51
- return id_api_path if @id
51
+
52
+ id_api_path if @id
52
53
  end
53
54
 
54
55
  # Get the api path for a repo
@@ -3,7 +3,7 @@
3
3
  module Octokit
4
4
  # Current major release.
5
5
  # @return [Integer]
6
- MAJOR = 6
6
+ MAJOR = 7
7
7
 
8
8
  # Current minor release.
9
9
  # @return [Integer]
@@ -11,7 +11,7 @@ module Octokit
11
11
 
12
12
  # Current patch level.
13
13
  # @return [Integer]
14
- PATCH = 1
14
+ PATCH = 0
15
15
 
16
16
  # Full release version.
17
17
  # @return [String]
data/octokit.gemspec CHANGED
@@ -5,7 +5,6 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'octokit/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.add_development_dependency 'bundler', '>= 1', '< 3'
9
8
  spec.add_dependency 'faraday', '>= 1', '< 3'
10
9
  spec.add_dependency 'sawyer', '~> 0.9'
11
10
  spec.authors = ['Wynn Netherland', 'Erik Michaels-Ober', 'Clint Shryock']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.1
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -10,28 +10,8 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-04-06 00:00:00.000000000 Z
13
+ date: 2023-08-24 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: bundler
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: '1'
22
- - - "<"
23
- - !ruby/object:Gem::Version
24
- version: '3'
25
- type: :development
26
- prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- version: '1'
32
- - - "<"
33
- - !ruby/object:Gem::Version
34
- version: '3'
35
15
  - !ruby/object:Gem::Dependency
36
16
  name: faraday
37
17
  requirement: !ruby/object:Gem::Requirement
@@ -92,12 +72,15 @@ files:
92
72
  - lib/octokit/client/actions_workflows.rb
93
73
  - lib/octokit/client/apps.rb
94
74
  - lib/octokit/client/checks.rb
75
+ - lib/octokit/client/code_scanning.rb
76
+ - lib/octokit/client/codespaces_secrets.rb
95
77
  - lib/octokit/client/commit_branches.rb
96
78
  - lib/octokit/client/commit_comments.rb
97
79
  - lib/octokit/client/commit_pulls.rb
98
80
  - lib/octokit/client/commits.rb
99
81
  - lib/octokit/client/community_profile.rb
100
82
  - lib/octokit/client/contents.rb
83
+ - lib/octokit/client/dependabot_secrets.rb
101
84
  - lib/octokit/client/deployments.rb
102
85
  - lib/octokit/client/downloads.rb
103
86
  - lib/octokit/client/emojis.rb
@@ -184,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
167
  - !ruby/object:Gem::Version
185
168
  version: 1.3.5
186
169
  requirements: []
187
- rubygems_version: 3.1.2
170
+ rubygems_version: 3.4.0.dev
188
171
  signing_key:
189
172
  specification_version: 4
190
173
  summary: Ruby toolkit for working with the GitHub API