octokit 4.21.0 → 10.0.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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +120 -96
  3. data/Rakefile +20 -14
  4. data/lib/ext/sawyer/relation.rb +4 -2
  5. data/lib/octokit/arguments.rb +3 -3
  6. data/lib/octokit/authentication.rb +10 -3
  7. data/lib/octokit/client/actions_artifacts.rb +71 -0
  8. data/lib/octokit/client/actions_secrets.rb +111 -8
  9. data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
  10. data/lib/octokit/client/actions_workflow_runs.rb +23 -3
  11. data/lib/octokit/client/actions_workflows.rb +27 -2
  12. data/lib/octokit/client/apps.rb +63 -74
  13. data/lib/octokit/client/checks.rb +18 -9
  14. data/lib/octokit/client/code_scanning.rb +190 -0
  15. data/lib/octokit/client/codespaces_secrets.rb +108 -0
  16. data/lib/octokit/client/commit_branches.rb +2 -2
  17. data/lib/octokit/client/commit_comments.rb +8 -8
  18. data/lib/octokit/client/commit_pulls.rb +2 -2
  19. data/lib/octokit/client/commits.rb +31 -34
  20. data/lib/octokit/client/community_profile.rb +2 -3
  21. data/lib/octokit/client/contents.rb +19 -22
  22. data/lib/octokit/client/dependabot_secrets.rb +108 -0
  23. data/lib/octokit/client/deployments.rb +8 -8
  24. data/lib/octokit/client/downloads.rb +5 -6
  25. data/lib/octokit/client/emojis.rb +3 -3
  26. data/lib/octokit/client/environments.rb +58 -0
  27. data/lib/octokit/client/events.rb +4 -5
  28. data/lib/octokit/client/feeds.rb +4 -5
  29. data/lib/octokit/client/gists.rb +6 -6
  30. data/lib/octokit/client/gitignore.rb +3 -3
  31. data/lib/octokit/client/hooks.rb +9 -19
  32. data/lib/octokit/client/issues.rb +14 -15
  33. data/lib/octokit/client/labels.rb +10 -10
  34. data/lib/octokit/client/legacy_search.rb +3 -3
  35. data/lib/octokit/client/licenses.rb +3 -6
  36. data/lib/octokit/client/markdown.rb +3 -3
  37. data/lib/octokit/client/marketplace.rb +4 -4
  38. data/lib/octokit/client/meta.rb +4 -5
  39. data/lib/octokit/client/milestones.rb +5 -5
  40. data/lib/octokit/client/notifications.rb +6 -6
  41. data/lib/octokit/client/oauth_applications.rb +1 -7
  42. data/lib/octokit/client/objects.rb +14 -14
  43. data/lib/octokit/client/organizations.rb +106 -62
  44. data/lib/octokit/client/pages.rb +5 -7
  45. data/lib/octokit/client/projects.rb +44 -64
  46. data/lib/octokit/client/pull_requests.rb +66 -45
  47. data/lib/octokit/client/rate_limit.rb +9 -11
  48. data/lib/octokit/client/reactions.rb +78 -16
  49. data/lib/octokit/client/refs.rb +15 -18
  50. data/lib/octokit/client/releases.rb +13 -13
  51. data/lib/octokit/client/repositories.rb +92 -69
  52. data/lib/octokit/client/repository_invitations.rb +3 -3
  53. data/lib/octokit/client/reviews.rb +8 -8
  54. data/lib/octokit/client/say.rb +4 -5
  55. data/lib/octokit/client/search.rb +24 -10
  56. data/lib/octokit/client/service_status.rb +19 -9
  57. data/lib/octokit/client/source_import.rb +7 -12
  58. data/lib/octokit/client/stats.rb +10 -9
  59. data/lib/octokit/client/statuses.rb +5 -5
  60. data/lib/octokit/client/tokens.rb +31 -0
  61. data/lib/octokit/client/traffic.rb +6 -11
  62. data/lib/octokit/client/users.rb +54 -33
  63. data/lib/octokit/client.rb +44 -20
  64. data/lib/octokit/configurable.rb +51 -31
  65. data/lib/octokit/connection.rb +33 -24
  66. data/lib/octokit/default.rb +66 -35
  67. data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
  68. data/lib/octokit/enterprise_admin_client/license.rb +3 -4
  69. data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
  70. data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
  71. data/lib/octokit/enterprise_admin_client/users.rb +5 -4
  72. data/lib/octokit/enterprise_admin_client.rb +9 -3
  73. data/lib/octokit/enterprise_management_console_client/management_console.rb +51 -33
  74. data/lib/octokit/enterprise_management_console_client.rb +8 -2
  75. data/lib/octokit/error.rb +53 -34
  76. data/lib/octokit/gist.rb +3 -4
  77. data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
  78. data/lib/octokit/manage_ghes_client.rb +64 -0
  79. data/lib/octokit/middleware/follow_redirects.rb +16 -12
  80. data/lib/octokit/organization.rb +3 -1
  81. data/lib/octokit/rate_limit.rb +8 -6
  82. data/lib/octokit/repo_arguments.rb +3 -4
  83. data/lib/octokit/repository.rb +32 -25
  84. data/lib/octokit/response/base_middleware.rb +10 -0
  85. data/lib/octokit/response/feed_parser.rb +5 -7
  86. data/lib/octokit/response/raise_error.rb +4 -4
  87. data/lib/octokit/user.rb +4 -2
  88. data/lib/octokit/version.rb +4 -2
  89. data/lib/octokit/warnable.rb +4 -5
  90. data/lib/octokit.rb +30 -8
  91. data/octokit.gemspec +12 -11
  92. metadata +22 -34
  93. data/lib/octokit/client/authorizations.rb +0 -182
  94. data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
  95. data/lib/octokit/preview.rb +0 -46
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the 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
- :body => body,
59
- :path => path,
60
- :line => line,
61
- :position => position
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
- :body => body
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 :list_commits :commits
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 = parse_date(arguments.shift)
49
+ date = parse_date(arguments.shift)
52
50
  params = arguments.options
53
- params.merge!(:since => iso8601(date))
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 = parse_date(arguments.shift)
73
+ date = parse_date(arguments.shift)
78
74
  params = arguments.options
79
- params.merge!(:until => iso8601(date))
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 = parse_date(arguments.shift)
97
+ date = parse_date(arguments.shift)
104
98
  params = arguments.options
105
99
  end_date = date + 1
106
- params.merge!(:since => iso8601(date), :until => iso8601(end_date))
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 = parse_date(arguments.shift)
133
- end_date = parse_date(arguments.shift)
134
- raise ArgumentError, "Start date #{date} does not precede #{end_date}" if date > end_date
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!(:since => iso8601(date), :until => iso8601(end_date))
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 = { :message => message, :tree => tree }
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
- get "#{Repository.path repo}/compare/#{start}...#{endd}", options
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
- :base => base,
212
- :head => head
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("%Y-%m-%dT%H:%M:%S%Z")
220
+ date.strftime('%Y-%m-%dT%H:%M:%S%Z')
224
221
  end
225
222
  end
226
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
- require 'base64'
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 :content :contents
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 && item.dup }
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, "r")
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.new("content or :file option required") if content.nil?
82
- options[:content] = Base64.respond_to?(:strict_encode64) ?
83
- Base64.strict_encode64(content) :
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 :create_content :create_contents
90
- alias :add_content :create_contents
91
- alias :add_contents :create_contents
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!(:sha => sha)
116
+ options.merge!(sha: sha)
120
117
  create_contents(repo, path, message, content, options)
121
118
  end
122
- alias :update_content :update_contents
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 :delete_content :delete_contents
146
- alias :remove_content :delete_contents
147
- alias :remove_contents :delete_contents
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 :ref
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
 
@@ -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
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Deployments API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/commits/deployments/
7
8
  module Deployments
8
-
9
9
  # Fetch a single deployment for a repository
10
10
  #
11
11
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -22,9 +22,9 @@ module Octokit
22
22
  # @return [Array<Sawyer::Resource>] A list of deployments
23
23
  # @see https://developer.github.com/v3/repos/deployments/#list-deployments
24
24
  def deployments(repo, options = {})
25
- get("#{Repository.path repo}/deployments", options)
25
+ paginate("#{Repository.path repo}/deployments", options)
26
26
  end
27
- alias :list_deployments :deployments
27
+ alias list_deployments deployments
28
28
 
29
29
  # Create a deployment for a ref
30
30
  #
@@ -59,10 +59,10 @@ module Octokit
59
59
  # @return [Array<Sawyer::Resource>] A list of deployment statuses
60
60
  # @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
61
61
  def deployment_statuses(deployment_url, options = {})
62
- deployment = get(deployment_url, :accept => options[:accept])
63
- get(deployment.rels[:statuses].href, options)
62
+ deployment = get(deployment_url, accept: options[:accept])
63
+ paginate(deployment.rels[:statuses].href, options)
64
64
  end
65
- alias :list_deployment_statuses :deployment_statuses
65
+ alias list_deployment_statuses deployment_statuses
66
66
 
67
67
  # Create a deployment status for a Deployment
68
68
  #
@@ -73,7 +73,7 @@ module Octokit
73
73
  # @return [Sawyer::Resource] A deployment status
74
74
  # @see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
75
75
  def create_deployment_status(deployment_url, state, options = {})
76
- deployment = get(deployment_url, :accept => options[:accept])
76
+ deployment = get(deployment_url, accept: options[:accept])
77
77
  options[:state] = state.to_s.downcase
78
78
  post(deployment.rels[:statuses].href, options)
79
79
  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 Repo Downloads API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/downloads/
7
8
  module Downloads
8
-
9
9
  # List available downloads for a repository
10
10
  #
11
11
  # @param repo [Integer, String, Repository, Hash] A Github Repository
@@ -14,10 +14,10 @@ module Octokit
14
14
  # @see https://developer.github.com/v3/repos/downloads/#list-downloads-for-a-repository
15
15
  # @example List all downloads for Github/Hubot
16
16
  # Octokit.downloads("github/hubot")
17
- def downloads(repo, options={})
17
+ def downloads(repo, options = {})
18
18
  paginate "#{Repository.path repo}/downloads", options
19
19
  end
20
- alias :list_downloads :downloads
20
+ alias list_downloads downloads
21
21
 
22
22
  # Get single download for a repository
23
23
  #
@@ -28,7 +28,7 @@ module Octokit
28
28
  # @see https://developer.github.com/v3/repos/downloads/#get-a-single-download
29
29
  # @example Get the "Robawt" download from Github/Hubot
30
30
  # Octokit.download("github/hubot")
31
- def download(repo, id, options={})
31
+ def download(repo, id, options = {})
32
32
  get "#{Repository.path repo}/downloads/#{id}", options
33
33
  end
34
34
 
@@ -44,7 +44,6 @@ module Octokit
44
44
  def delete_download(repo, id, options = {})
45
45
  boolean_from_response :delete, "#{Repository.path repo}/downloads/#{id}", options
46
46
  end
47
-
48
47
  end
49
48
  end
50
49
  end
@@ -1,9 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for the Emojis API
5
6
  module Emojis
6
-
7
7
  # List all emojis used on GitHub
8
8
  #
9
9
  # @return [Sawyer::Resource] A list of all emojis on GitHub
@@ -11,7 +11,7 @@ module Octokit
11
11
  # @example List all emojis
12
12
  # Octokit.emojis
13
13
  def emojis(options = {})
14
- get "emojis", options
14
+ get 'emojis', options
15
15
  end
16
16
  end
17
17
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+ # Methods for the Environments API
6
+ #
7
+ # @see https://docs.github.com/en/rest/deployments/environments
8
+ module Environments
9
+ # Fetch a single environment for a repository
10
+ #
11
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
12
+ # @param environment_name [String] The name of the environment
13
+ # @return <Sawyer::Resource> A single environment
14
+ # @see https://docs.github.com/en/rest/deployments/environments#get-an-environment
15
+ def environment(repo, environment_name, options = {})
16
+ get("#{Repository.path repo}/environments/#{environment_name}", options)
17
+ end
18
+
19
+ # Lists the environments for a repository
20
+ #
21
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
22
+ # @option options [Integer] :per_page The number of results per page (max 100). Default: 30
23
+ # @option options [Integer] :page Page number of the results to fetch. Default: 1
24
+ # @return [Sawyer::Resource] Total count of environments and list of environments
25
+ # @see https://docs.github.com/en/rest/deployments/environments#list-environments
26
+ def environments(repo, options = {})
27
+ paginate("#{Repository.path repo}/environments", options) do |data, last_response|
28
+ data.environments.concat last_response.data.environments
29
+ data.total_count += last_response.data.total_count
30
+ end
31
+ end
32
+ alias list_environments environments
33
+
34
+ # Create or update an environment with protection rules, such as required reviewers
35
+ #
36
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
37
+ # @param environment_name [String] The name of the environment
38
+ # @option options [Integer] :wait_timer The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days).
39
+ # @option options [Array] :reviewers The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers.
40
+ # @option options [Object] :deployment_branch_policy The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.
41
+ # @return [Sawyer::Resource] An environment
42
+ # @see https://docs.github.com/en/rest/deployments/environments#create-or-update-an-environment
43
+ def create_or_update_environment(repo, environment_name, options = {})
44
+ put("#{Repository.path repo}/environments/#{environment_name}", options)
45
+ end
46
+
47
+ # Delete an Environment
48
+ #
49
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
50
+ # @param environment_name [String] The name of the environment
51
+ # @return [No Content]
52
+ # @see https://docs.github.com/en/rest/deployments/environments#delete-an-environment
53
+ def delete_environment(repo, environment_name, options = {})
54
+ delete("#{Repository.path repo}/environments/#{environment_name}", options)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Method for the Events API
5
6
  #
6
7
  # @see https://developer.github.com/v3/activity/events/
7
8
  # @see https://developer.github.com/v3/issues/events/
8
9
  module Events
9
-
10
10
  # List all public events for GitHub
11
11
  #
12
12
  # @return [Array<Sawyer::Resource>] A list of all public events from GitHub
@@ -14,7 +14,7 @@ module Octokit
14
14
  # @example List all pubilc events
15
15
  # Octokit.public_events
16
16
  def public_events(options = {})
17
- paginate "events", options
17
+ paginate 'events', options
18
18
  end
19
19
 
20
20
  # List all user events
@@ -119,7 +119,7 @@ module Octokit
119
119
  def repository_issue_events(repo, options = {})
120
120
  paginate "#{Repository.path repo}/issues/events", options
121
121
  end
122
- alias :repo_issue_events :repository_issue_events
122
+ alias repo_issue_events repository_issue_events
123
123
 
124
124
  # List events for an Issue
125
125
  #
@@ -131,7 +131,6 @@ module Octokit
131
131
  # @example List all issues events for issue #38 on octokit/octokit.rb
132
132
  # Octokit.issue_events("octokit/octokit.rb", 38)
133
133
  def issue_events(repo, number, options = {})
134
- options = ensure_api_media_type(:project_card_events, options)
135
134
  paginate "#{Repository.path repo}/issues/#{number}/events", options
136
135
  end
137
136