octokit 5.6.1 → 6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbf0b3ef2f8550628d4bde2fa55f7bcb97261364e94aac9f5a149ce6e86fa019
4
- data.tar.gz: d336c02e28efb73618c1c24827b2b7703dc5341ce95087467089cf36f11d96fb
3
+ metadata.gz: c3018cabf6ab75fe3a4340d20a4844ab92fa7059a4bbbdd96b9b671537aef5b5
4
+ data.tar.gz: 6308252f312bb301eadfe573daf9d5e17ce0698480dbdc938f72b62831e73632
5
5
  SHA512:
6
- metadata.gz: 960aacdc0e1a37794e6bed1a0c5f2686c1dca5160c0802cb449590f92ecab4cf243a0201b65e419fe3ffa38c194f106eceed0d46c90f63ceeb8a4aa14b22d716
7
- data.tar.gz: 22a81c032d49f11c2f3875bfbc1c577449787d0899f20d0108dc7de868a2b5f1c86163ccebf46eb4a4b2567277c46fd83aca619c071a238746229664894008bf
6
+ metadata.gz: 7477cd6b438fedbec3fe952a8aebeefa224b991a65c8950c26c938db69962614d1ae066c3afd4b40a37ab935637af2dbc08ae126f8e5d199c16df1e646b2878b
7
+ data.tar.gz: 6d891d836aa8118c9cce64d265ee26d8e97f7dc05425d491d0d7123f1b9fab12eb3aa62ccc85a1b69640ed29819dba7b19d34161f2fa5b159a0b36701c0c758a
@@ -13,7 +13,9 @@ module Octokit
13
13
  # @return [Sawyer::Resource] the total count and an array of artifacts
14
14
  # @see https://developer.github.com/v3/actions/artifacts#list-artifacts-for-a-repository
15
15
  def repository_artifacts(repo, options = {})
16
- paginate "#{Repository.path repo}/actions/artifacts", options
16
+ paginate "#{Repository.path repo}/actions/artifacts", options do |data, last_response|
17
+ data.artifacts.concat last_response.data.artifacts
18
+ end
17
19
  end
18
20
 
19
21
  # List all artifacts for a workflow run
@@ -24,7 +26,9 @@ module Octokit
24
26
  # @return [Sawyer::Resource] the total count and an array of artifacts
25
27
  # @see https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts
26
28
  def workflow_run_artifacts(repo, workflow_run_id, options = {})
27
- paginate "#{Repository.path repo}/actions/runs/#{workflow_run_id}/artifacts", options
29
+ paginate "#{Repository.path repo}/actions/runs/#{workflow_run_id}/artifacts", options do |data, last_response|
30
+ data.artifacts.concat last_response.data.artifacts
31
+ end
28
32
  end
29
33
 
30
34
  # Get an artifact
@@ -21,7 +21,9 @@ module Octokit
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
23
  def list_secrets(repo)
24
- paginate "#{Repository.path repo}/actions/secrets"
24
+ paginate "#{Repository.path repo}/actions/secrets" do |data, last_response|
25
+ data.secrets.concat last_response.data.secrets
26
+ end
25
27
  end
26
28
 
27
29
  # Get a secret
@@ -40,7 +40,9 @@ module Octokit
40
40
  # @return [Sawyer::Resource] Jobs information
41
41
  # @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run-attempt
42
42
  def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})
43
- paginate "#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs", options
43
+ paginate "#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs", options do |data, last_response|
44
+ data.jobs.concat last_response.data.jobs
45
+ end
44
46
  end
45
47
  alias list_workflow_run_attempt_jobs workflow_run_attempt_jobs
46
48
 
@@ -53,7 +55,9 @@ module Octokit
53
55
  # @return [Sawyer::Resource] Jobs information
54
56
  # @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
55
57
  def workflow_run_jobs(repo, run_id, options = {})
56
- paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options
58
+ paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options do |data, last_response|
59
+ data.jobs.concat last_response.data.jobs
60
+ end
57
61
  end
58
62
  alias list_workflow_run_jobs workflow_run_jobs
59
63
  end
@@ -18,7 +18,9 @@ module Octokit
18
18
  # @return [Sawyer::Resource] the total count and an array of workflows
19
19
  # @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
20
20
  def workflow_runs(repo, workflow, options = {})
21
- paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options
21
+ paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options do |data, last_response|
22
+ data.workflow_runs.concat last_response.data.workflow_runs
23
+ end
22
24
  end
23
25
  alias list_workflow_runs workflow_runs
24
26
 
@@ -33,7 +35,9 @@ module Octokit
33
35
  # @return [Sawyer::Resource] the total count and an array of workflows
34
36
  # @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
35
37
  def repository_workflow_runs(repo, options = {})
36
- paginate "#{Repository.path repo}/actions/runs", options
38
+ paginate "#{Repository.path repo}/actions/runs", options do |data, last_response|
39
+ data.workflow_runs.concat last_response.data.workflow_runs
40
+ end
37
41
  end
38
42
  alias list_repository_workflow_runs repository_workflow_runs
39
43
 
@@ -13,7 +13,9 @@ module Octokit
13
13
  # @return [Sawyer::Resource] the total count and an array of workflows
14
14
  # @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows
15
15
  def workflows(repo, options = {})
16
- paginate "#{Repository.path repo}/actions/workflows", options
16
+ paginate "#{Repository.path repo}/actions/workflows", options do |data, last_response|
17
+ data.workflows.concat last_response.data.workflows
18
+ end
17
19
  end
18
20
  alias list_workflows workflows
19
21
 
@@ -4,16 +4,6 @@ module Octokit
4
4
  class Client
5
5
  # Methods for the Hooks API
6
6
  module Hooks
7
- # List all Service Hooks supported by GitHub
8
- #
9
- # @return [Sawyer::Resource] A list of all hooks on GitHub
10
- # @see https://developer.github.com/v3/repos/hooks/#services
11
- # @example List all hooks
12
- # Octokit.available_hooks
13
- def available_hooks(options = {})
14
- get 'hooks', options
15
- end
16
-
17
7
  # List repo hooks
18
8
  #
19
9
  # Requires authenticated client.
@@ -77,9 +77,7 @@ 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
82
  sha: sha,
85
83
  force: force
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+ # Method to check scopes
6
+ #
7
+ # @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
8
+ module Tokens
9
+ # Check scopes for a token
10
+ #
11
+ # @param token [String] GitHub OAuth token
12
+ # @param options [Hash] Header params for request
13
+ # @return [Array<String>] OAuth scopes
14
+ # @see https://developer.github.com/v3/oauth/#scopes
15
+ def scopes(token = @access_token, options = {})
16
+ options = options.dup
17
+ raise ArgumentError, 'Access token required' if token.nil?
18
+
19
+ auth = { 'Authorization' => "token #{token}" }
20
+ headers = (options.delete(:headers) || {}).merge(auth)
21
+
22
+ agent.call(:get, 'user', headers: headers)
23
+ .headers['X-OAuth-Scopes']
24
+ .to_s
25
+ .split(',')
26
+ .map(&:strip)
27
+ .sort
28
+ end
29
+ end
30
+ end
31
+ end
@@ -17,7 +17,6 @@ require 'octokit/client/actions_workflows'
17
17
  require 'octokit/client/actions_workflow_jobs'
18
18
  require 'octokit/client/actions_workflow_runs'
19
19
  require 'octokit/client/apps'
20
- require 'octokit/client/authorizations'
21
20
  require 'octokit/client/checks'
22
21
  require 'octokit/client/commits'
23
22
  require 'octokit/client/commit_comments'
@@ -62,6 +61,7 @@ require 'octokit/client/service_status'
62
61
  require 'octokit/client/source_import'
63
62
  require 'octokit/client/stats'
64
63
  require 'octokit/client/statuses'
64
+ require 'octokit/client/tokens'
65
65
  require 'octokit/client/traffic'
66
66
  require 'octokit/client/users'
67
67
  require 'ext/sawyer/relation'
@@ -77,7 +77,6 @@ module Octokit
77
77
  include Octokit::Warnable
78
78
  include Octokit::Client::ActionsArtifacts
79
79
  include Octokit::Client::ActionsSecrets
80
- include Octokit::Client::Authorizations
81
80
  include Octokit::Client::Checks
82
81
  include Octokit::Client::Commits
83
82
  include Octokit::Client::CommitComments
@@ -126,6 +125,7 @@ module Octokit
126
125
  include Octokit::Client::SourceImport
127
126
  include Octokit::Client::Stats
128
127
  include Octokit::Client::Statuses
128
+ include Octokit::Client::Tokens
129
129
  include Octokit::Client::Traffic
130
130
  include Octokit::Client::Users
131
131
 
@@ -3,15 +3,15 @@
3
3
  module Octokit
4
4
  # Current major release.
5
5
  # @return [Integer]
6
- MAJOR = 5
6
+ MAJOR = 6
7
7
 
8
8
  # Current minor release.
9
9
  # @return [Integer]
10
- MINOR = 6
10
+ MINOR = 0
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]
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octokit
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.1
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
8
8
  - Erik Michaels-Ober
9
9
  - Clint Shryock
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-09-14 00:00:00.000000000 Z
13
+ date: 2022-10-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -91,7 +91,6 @@ files:
91
91
  - lib/octokit/client/actions_workflow_runs.rb
92
92
  - lib/octokit/client/actions_workflows.rb
93
93
  - lib/octokit/client/apps.rb
94
- - lib/octokit/client/authorizations.rb
95
94
  - lib/octokit/client/checks.rb
96
95
  - lib/octokit/client/commit_branches.rb
97
96
  - lib/octokit/client/commit_comments.rb
@@ -136,6 +135,7 @@ files:
136
135
  - lib/octokit/client/source_import.rb
137
136
  - lib/octokit/client/stats.rb
138
137
  - lib/octokit/client/statuses.rb
138
+ - lib/octokit/client/tokens.rb
139
139
  - lib/octokit/client/traffic.rb
140
140
  - lib/octokit/client/users.rb
141
141
  - lib/octokit/configurable.rb
@@ -168,7 +168,7 @@ licenses:
168
168
  - MIT
169
169
  metadata:
170
170
  rubygems_mfa_required: 'true'
171
- post_install_message:
171
+ post_install_message:
172
172
  rdoc_options: []
173
173
  require_paths:
174
174
  - lib
@@ -183,8 +183,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  - !ruby/object:Gem::Version
184
184
  version: 1.3.5
185
185
  requirements: []
186
- rubygems_version: 3.3.7
187
- signing_key:
186
+ rubygems_version: 3.1.6
187
+ signing_key:
188
188
  specification_version: 4
189
189
  summary: Ruby toolkit for working with the GitHub API
190
190
  test_files: []
@@ -1,185 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Octokit
4
- class Client
5
- # Methods for the Authorizations API
6
- #
7
- # @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
8
- module Authorizations
9
- # List the authenticated user's authorizations
10
- #
11
- # API for users to manage their own tokens.
12
- # You can only access your own tokens, and only through
13
- # Basic Authentication.
14
- #
15
- # @return [Array<Sawyer::Resource>] A list of authorizations for the authenticated user
16
- # @see https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
17
- # @example List authorizations for user ctshryock
18
- # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
19
- # client.authorizations
20
- def authorizations(options = {})
21
- paginate 'authorizations', options
22
- end
23
-
24
- # Get a single authorization for the authenticated user.
25
- #
26
- # You can only access your own tokens, and only through
27
- # Basic Authentication.
28
- #
29
- # @return [Sawyer::Resource] A single authorization for the authenticated user
30
- # @see https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
31
- # @example Show authorization for user ctshryock's Travis auth
32
- # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
33
- # client.authorization(999999)
34
- def authorization(number, options = {})
35
- get "authorizations/#{number}", options
36
- end
37
-
38
- # Create an authorization for the authenticated user.
39
- #
40
- # You can create your own tokens, and only through
41
- # Basic Authentication.
42
- #
43
- # @param options [Hash] A customizable set of options.
44
- # @option options [Array] :scopes A list of scopes that this authorization is in.
45
- # @option options [String] :note A note to remind you what the OAuth token is for.
46
- # @option options [String] :note_url A URL to remind you what app the OAuth token is for.
47
- # @option options [Boolean] :idempotent If true, will return an existing authorization if one has already been created.
48
- # @option options [String] :client_id Client Id we received when our application was registered with GitHub.
49
- # @option options [String] :client_secret Client Secret we received when our application was registered with GitHub.
50
- #
51
- # @return [Sawyer::Resource] A single authorization for the authenticated user
52
- # @see https://developer.github.com/v3/oauth/#scopes Available scopes
53
- # @see https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
54
- # @see https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app
55
- # @example Create a new authorization for user ctshryock's project Zoidberg
56
- # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
57
- # client.create_authorization({:scopes => ["public_repo", "gist"], :note => "Why not Zoidberg?", :note_url=> "https://en.wikipedia.org/wiki/Zoidberg"})
58
- # @example Create a new OR return an existing authorization to be used by a specific client for user ctshryock's project Zoidberg
59
- # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
60
- # client.create_authorization({:idempotent => true, :client_id => 'xxxx', :client_secret => 'yyyy', :scopes => ["user"]})
61
- def create_authorization(options = {})
62
- # Technically we can omit scopes as GitHub has a default, however the
63
- # API will reject us if we send a POST request with an empty body.
64
- options = options.dup
65
- if options.delete :idempotent
66
- client_id, client_secret = fetch_client_id_and_secret(options)
67
- unless client_id && client_secret
68
- raise ArgumentError, 'Client ID and Secret required for idempotent authorizations'
69
- end
70
-
71
- # Remove the client_id from the body otherwise
72
- # this will result in a 422.
73
- options.delete(:client_id)
74
-
75
- if (fingerprint = options.delete(:fingerprint))
76
- put "authorizations/clients/#{client_id}/#{fingerprint}", options.merge(client_secret: client_secret)
77
- else
78
- put "authorizations/clients/#{client_id}", options.merge(client_secret: client_secret)
79
- end
80
-
81
- else
82
- post 'authorizations', options
83
- end
84
- end
85
-
86
- # Update an authorization for the authenticated user.
87
- #
88
- # You can update your own tokens, but only through
89
- # Basic Authentication.
90
- #
91
- # @param options [Hash] A customizable set of options.
92
- # @option options [Array] :scopes Replace the authorization scopes with these.
93
- # @option options [Array] :add_scopes A list of scopes to add to this authorization.
94
- # @option options [Array] :remove_scopes A list of scopes to remove from this authorization.
95
- # @option options [String] :note A note to remind you what the OAuth token is for.
96
- # @option options [String] :note_url A URL to remind you what app the OAuth token is for.
97
- #
98
- # @return [Sawyer::Resource] A single (updated) authorization for the authenticated user
99
- # @see https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
100
- # @see https://developer.github.com/v3/oauth/#scopes for available scopes
101
- # @example Update the authorization for user ctshryock's project Zoidberg
102
- # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
103
- # client.update_authorization(999999, {:add_scopes => ["gist", "repo"], :note => "Why not Zoidberg possibly?"})
104
- def update_authorization(number, options = {})
105
- patch "authorizations/#{number}", options
106
- end
107
-
108
- # Delete an authorization for the authenticated user.
109
- #
110
- # You can delete your own tokens, and only through
111
- # Basic Authentication.
112
- #
113
- # @param number [Number] An existing Authorization ID
114
- #
115
- # @return [Boolean] Success
116
- # @see https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization
117
- # @example Delete an authorization
118
- # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
119
- # client.delete_authorization(999999)
120
- def delete_authorization(number, options = {})
121
- boolean_from_response :delete, "authorizations/#{number}", options
122
- end
123
-
124
- # Check scopes for a token
125
- #
126
- # @param token [String] GitHub OAuth token
127
- # @param options [Hash] Header params for request
128
- # @return [Array<String>] OAuth scopes
129
- # @see https://developer.github.com/v3/oauth/#scopes
130
- def scopes(token = @access_token, options = {})
131
- options = options.dup
132
- raise ArgumentError, 'Access token required' if token.nil?
133
-
134
- auth = { 'Authorization' => "token #{token}" }
135
- headers = (options.delete(:headers) || {}).merge(auth)
136
-
137
- agent.call(:get, 'user', headers: headers)
138
- .headers['X-OAuth-Scopes']
139
- .to_s
140
- .split(',')
141
- .map(&:strip)
142
- .sort
143
- end
144
-
145
- # Revoke all tokens for an app
146
- #
147
- # Applications can revoke all of their tokens in a single request
148
- #
149
- # @deprecated As of January 25th, 2016: https://developer.github.com/changes/2014-04-08-reset-api-tokens/
150
- # @return [Boolean] false
151
- def revoke_all_application_authorizations(_options = {})
152
- octokit_warn('Deprecated: If you need to revoke all tokens for your application, you can do so via the settings page for your application.')
153
- false
154
- end
155
-
156
- # Get the URL to authorize a user for an application via the web flow
157
- #
158
- # @param app_id [String] Client Id we received when our application was registered with GitHub.
159
- # @option options [String] :redirect_uri The url to redirect to after authorizing.
160
- # @option options [String] :scope The scopes to request from the user.
161
- # @option options [String] :state A random string to protect against CSRF.
162
- # @return [String] The url to redirect the user to authorize.
163
- # @see Octokit::Client
164
- # @see https://developer.github.com/v3/oauth/#web-application-flow
165
- # @example
166
- # @client.authorize_url('xxxx')
167
- def authorize_url(app_id = client_id, options = {})
168
- opts = options.dup
169
- if app_id.to_s.empty?
170
- raise Octokit::ApplicationCredentialsRequired, 'client_id required'
171
- end
172
-
173
- authorize_url = opts.delete(:endpoint) || Octokit.web_endpoint
174
- authorize_url << "login/oauth/authorize?client_id=#{app_id}"
175
-
176
- require 'cgi'
177
- opts.each do |key, value|
178
- authorize_url << "&#{key}=#{CGI.escape value}"
179
- end
180
-
181
- authorize_url
182
- end
183
- end
184
- end
185
- end