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 Reacions API
5
6
  #
6
7
  # @see https://developer.github.com/v3/reactions/
7
8
  module Reactions
8
-
9
9
  # List reactions for a commit comment
10
10
  #
11
11
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -17,7 +17,6 @@ module Octokit
17
17
  #
18
18
  # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
19
19
  def commit_comment_reactions(repo, id, options = {})
20
- options = ensure_api_media_type(:reactions, options)
21
20
  get "#{Repository.path repo}/comments/#{id}/reactions", options
22
21
  end
23
22
 
@@ -34,7 +33,7 @@ module Octokit
34
33
  #
35
34
  # @return [<Sawyer::Resource>] Hash representing the reaction
36
35
  def create_commit_comment_reaction(repo, id, reaction, options = {})
37
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
36
+ options = options.merge(content: reaction)
38
37
  post "#{Repository.path repo}/comments/#{id}/reactions", options
39
38
  end
40
39
 
@@ -49,7 +48,6 @@ module Octokit
49
48
  #
50
49
  # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
51
50
  def issue_reactions(repo, number, options = {})
52
- options = ensure_api_media_type(:reactions, options)
53
51
  get "#{Repository.path repo}/issues/#{number}/reactions", options
54
52
  end
55
53
 
@@ -67,7 +65,7 @@ module Octokit
67
65
  #
68
66
  # @return [<Sawyer::Resource>] Hash representing the reaction.
69
67
  def create_issue_reaction(repo, number, reaction, options = {})
70
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
68
+ options = options.merge(content: reaction)
71
69
  post "#{Repository.path repo}/issues/#{number}/reactions", options
72
70
  end
73
71
 
@@ -83,7 +81,6 @@ module Octokit
83
81
  #
84
82
  # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
85
83
  def issue_comment_reactions(repo, id, options = {})
86
- options = ensure_api_media_type(:reactions, options)
87
84
  get "#{Repository.path repo}/issues/comments/#{id}/reactions", options
88
85
  end
89
86
 
@@ -101,10 +98,26 @@ module Octokit
101
98
  #
102
99
  # @return [<Sawyer::Resource>] Hashes representing the reaction.
103
100
  def create_issue_comment_reaction(repo, id, reaction, options = {})
104
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
101
+ options = options.merge(content: reaction)
105
102
  post "#{Repository.path repo}/issues/comments/#{id}/reactions", options
106
103
  end
107
104
 
105
+ # Delete a reaction from an issue comment
106
+ #
107
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
108
+ # @param comment_id [Integer] The Issue comment id
109
+ # @param reaction_id [Integer] The Reaction id
110
+ #
111
+ # @see https://docs.github.com/en/rest/reactions/reactions#delete-an-issue-comment-reaction
112
+ #
113
+ # @example
114
+ # @client.delete_issue_comment_reaction("octokit/octokit.rb", 1, 2)
115
+ #
116
+ # @return [Boolean] Return true if reaction was deleted, false otherwise.
117
+ def delete_issue_comment_reaction(repo, comment_id, reaction_id, options = {})
118
+ boolean_from_response :delete, "#{Repository.path repo}/issues/comments/#{comment_id}/reactions/#{reaction_id}", options
119
+ end
120
+
108
121
  # List reactions for a pull request review comment
109
122
  #
110
123
  # @param repo [Integer, String, Hash, Repository] A GitHub repository
@@ -117,7 +130,6 @@ module Octokit
117
130
  #
118
131
  # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
119
132
  def pull_request_review_comment_reactions(repo, id, options = {})
120
- options = ensure_api_media_type(:reactions, options)
121
133
  get "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
122
134
  end
123
135
 
@@ -135,23 +147,73 @@ module Octokit
135
147
  #
136
148
  # @return [<Sawyer::Resource>] Hash representing the reaction.
137
149
  def create_pull_request_review_comment_reaction(repo, id, reaction, options = {})
138
- options = ensure_api_media_type(:reactions, options.merge(:content => reaction))
150
+ options = options.merge(content: reaction)
139
151
  post "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
140
152
  end
141
153
 
142
154
  # Delete a reaction
143
155
  #
144
- # @param id [Integer] Reaction id
156
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
157
+ # @param issue_id [Integer] The Issue comment id
158
+ # @param reaction_id [Integer] The Reaction id
159
+ #
160
+ # @see https://docs.github.com/en/rest/reactions/reactions#delete-an-issue-reaction
161
+ #
162
+ # @example
163
+ # @client.delete_issue_reaction("octokit/octokit.rb", 1, 2)
164
+ #
165
+ # @return [Boolean] Return true if reaction was deleted, false otherwise.
166
+ def delete_issue_reaction(repo, issue_id, reaction_id, options = {})
167
+ boolean_from_response :delete, "#{Repository.path repo}/issues/#{issue_id}/reactions/#{reaction_id}", options
168
+ end
169
+
170
+ # List reactions for a release
171
+ #
172
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
173
+ # @param id [Integer] The Release id
174
+ #
175
+ # @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-release
176
+ #
177
+ # @example
178
+ # @client.release_reactions("octokit/octokit.rb", 1)
179
+ #
180
+ # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
181
+ def release_reactions(repo, release_id, options = {})
182
+ get "#{Repository.path repo}/releases/#{release_id}/reactions", options
183
+ end
184
+
185
+ # Create reaction for a release
186
+ #
187
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
188
+ # @param id [Integer] The Release id
189
+ # @param reaction [String] The Reaction
190
+ #
191
+ # @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-release
192
+ # @see https://developer.github.com/v3/reactions/#reaction-types
193
+ #
194
+ # @example
195
+ # @client.create_release_reaction("octokit/octokit.rb", 1)
196
+ #
197
+ # @return [<Sawyer::Resource>] Hash representing the reaction.
198
+ def create_release_reaction(repo, release_id, reaction, options = {})
199
+ options = options.merge(content: reaction)
200
+ post "#{Repository.path repo}/releases/#{release_id}/reactions", options
201
+ end
202
+
203
+ # Delete a reaction for a release
204
+ #
205
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
206
+ # @param issue_id [Integer] The Release id
207
+ # @param reaction_id [Integer] The Reaction id
145
208
  #
146
- # @see https://developer.github.com/v3/reactions/#delete-a-reaction
209
+ # @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#delete-a-release-reaction
147
210
  #
148
211
  # @example
149
- # @client.delete_reaction(1)
212
+ # @client.delete_release_reaction("octokit/octokit.rb", 1, 2)
150
213
  #
151
214
  # @return [Boolean] Return true if reaction was deleted, false otherwise.
152
- def delete_reaction(id, options = {})
153
- options = ensure_api_media_type(:reactions, options)
154
- boolean_from_response :delete, "reactions/#{id}", options
215
+ def delete_release_reaction(repo, release_id, reaction_id, options = {})
216
+ boolean_from_response :delete, "#{Repository.path repo}/releases/#{release_id}/reactions/#{reaction_id}", options
155
217
  end
156
218
  end
157
219
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Octokit
2
4
  class Client
3
-
4
5
  # Methods for References for Git Data API
5
6
  #
6
7
  # @see https://developer.github.com/v3/git/refs/
7
8
  module Refs
8
-
9
9
  # List all refs for a given user and repo
10
10
  #
11
11
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -19,9 +19,9 @@ module Octokit
19
19
  path += "/#{namespace}" unless namespace.nil?
20
20
  paginate path, options
21
21
  end
22
- alias :list_refs :refs
23
- alias :references :refs
24
- alias :list_references :refs
22
+ alias list_refs refs
23
+ alias references refs
24
+ alias list_references refs
25
25
 
26
26
  # Fetch matching refs
27
27
  #
@@ -46,7 +46,7 @@ module Octokit
46
46
  def ref(repo, ref, options = {})
47
47
  get "#{Repository.path repo}/git/refs/#{ref}", options
48
48
  end
49
- alias :reference :ref
49
+ alias reference ref
50
50
 
51
51
  # Create a reference
52
52
  #
@@ -58,14 +58,14 @@ module Octokit
58
58
  # @example Create refs/heads/master for octocat/Hello-World with sha 827efc6d56897b048c772eb4087f854f46256132
59
59
  # Octokit.create_ref("octocat/Hello-World", "heads/master", "827efc6d56897b048c772eb4087f854f46256132")
60
60
  def create_ref(repo, ref, sha, options = {})
61
- ref = "refs/#{ref}" unless ref =~ %r{refs/}
61
+ ref = "refs/#{ref}" unless ref =~ %r{\Arefs/}
62
62
  parameters = {
63
- :ref => ref,
64
- :sha => sha
63
+ ref: ref,
64
+ sha: sha
65
65
  }
66
66
  post "#{Repository.path repo}/git/refs", options.merge(parameters)
67
67
  end
68
- alias :create_reference :create_ref
68
+ alias create_reference create_ref
69
69
 
70
70
  # Update a reference
71
71
  #
@@ -77,16 +77,14 @@ module Octokit
77
77
  # @see https://developer.github.com/v3/git/refs/#update-a-reference
78
78
  # @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
79
79
  # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
80
- # @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
81
- # Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
82
- def update_ref(repo, ref, sha, force = true, options = {})
80
+ def update_ref(repo, ref, sha, force = false, options = {})
83
81
  parameters = {
84
- :sha => sha,
85
- :force => force
82
+ sha: sha,
83
+ force: force
86
84
  }
87
85
  patch "#{Repository.path repo}/git/refs/#{ref}", options.merge(parameters)
88
86
  end
89
- alias :update_reference :update_ref
87
+ alias update_reference update_ref
90
88
 
91
89
  # Update a branch
92
90
  #
@@ -127,8 +125,7 @@ module Octokit
127
125
  def delete_ref(repo, ref, options = {})
128
126
  boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", options
129
127
  end
130
- alias :delete_reference :delete_ref
131
-
128
+ alias delete_reference delete_ref
132
129
  end
133
130
  end
134
131
  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 Releases API
5
6
  #
6
7
  # @see https://developer.github.com/v3/repos/releases/
7
8
  module Releases
8
-
9
9
  # List releases for a repository
10
10
  #
11
11
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
@@ -14,7 +14,7 @@ module Octokit
14
14
  def releases(repo, options = {})
15
15
  paginate "#{Repository.path repo}/releases", options
16
16
  end
17
- alias :list_releases :releases
17
+ alias list_releases releases
18
18
 
19
19
  # Create a release
20
20
  #
@@ -28,7 +28,7 @@ module Octokit
28
28
  # @return [Sawyer::Resource] The release
29
29
  # @see https://developer.github.com/v3/repos/releases/#create-a-release
30
30
  def create_release(repo, tag_name, options = {})
31
- opts = options.merge(:tag_name => tag_name)
31
+ opts = options.merge(tag_name: tag_name)
32
32
  post "#{Repository.path repo}/releases", opts
33
33
  end
34
34
 
@@ -55,7 +55,7 @@ module Octokit
55
55
  def update_release(url, options = {})
56
56
  patch url, options
57
57
  end
58
- alias :edit_release :update_release
58
+ alias edit_release update_release
59
59
 
60
60
  # Delete a release
61
61
  #
@@ -84,17 +84,18 @@ module Octokit
84
84
  # @return [Sawyer::Resource] The release asset
85
85
  # @see https://developer.github.com/v3/repos/releases/#upload-a-release-asset
86
86
  def upload_asset(release_url, path_or_file, options = {})
87
- file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, "rb")
87
+ file = path_or_file.respond_to?(:read) ? path_or_file : File.new(path_or_file, 'rb')
88
88
  options[:content_type] ||= content_type_from_file(file)
89
- raise Octokit::MissingContentType.new if options[:content_type].nil?
89
+ raise Octokit::MissingContentType if options[:content_type].nil?
90
+
90
91
  unless name = options[:name]
91
92
  name = File.basename(file.path)
92
93
  end
93
- upload_url = release(release_url).rels[:upload].href_template.expand(:name => name)
94
+ upload_url = release(release_url).rels[:upload].href_template.expand(name: name)
94
95
 
95
96
  request :post, upload_url, file.read, parse_query_and_convenience_headers(options)
96
97
  ensure
97
- file.close if file
98
+ file&.close
98
99
  end
99
100
 
100
101
  # Get a single release asset
@@ -117,7 +118,7 @@ module Octokit
117
118
  def update_release_asset(asset_url, options = {})
118
119
  patch(asset_url, options)
119
120
  end
120
- alias :edit_release_asset :update_release_asset
121
+ alias edit_release_asset update_release_asset
121
122
 
122
123
  # Delete a release asset
123
124
  #
@@ -155,10 +156,9 @@ module Octokit
155
156
  mime_type.content_type
156
157
  end
157
158
  rescue LoadError
158
- msg = "Please pass content_type or install mime-types gem to guess content type from file"
159
- raise Octokit::MissingContentType.new(msg)
159
+ msg = 'Please pass content_type or install mime-types gem to guess content type from file'
160
+ raise Octokit::MissingContentType, msg
160
161
  end
161
-
162
162
  end
163
163
  end
164
164
  end