octokit 4.14.0 → 4.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da3e4a3c93344024b60cb7d3c5e13bc90742576c6e43dc3e438f3e16819cdc9f
4
- data.tar.gz: 9a47ad957027e32a4f74ca93250476ae46627d961b6bd349cf62a632da04477f
3
+ metadata.gz: 9801b25dfdd07e517b87bdc1404ffa64fd12496b66af8bb8bc4af57f6f33483f
4
+ data.tar.gz: b082dcc32f514846b53da5aaafe7666020c9de8d590dafb6e93743767a70573b
5
5
  SHA512:
6
- metadata.gz: 22921fbc5478cbdcbe17f033b7a63666dc69ff63b1b2fda1f47f37eb2967cd055539c1935a5a767d46e24ed427c2d64457c6057141f77caa3bfdf2ebcd6bd179
7
- data.tar.gz: 1bc0add3fdff8b42dc752c3886f95ba51e8ffd234ff3f0091b7dc7a22dbfd8286b0df2d043646a859cdc0bb2837663b6259339c82a0602296dc9cb305b68ab4a
6
+ metadata.gz: 16595560313f6346448710adf2a0d641fe62521089ff017aff1c2f1dc6dd1d5dc06d8397e552a098cf1a6ada91edfa111863d9c4491df86d3d38d3143531a7b5
7
+ data.tar.gz: 7dc816349c9050b31e0c0d09a7e1e25b6d455d59f6ae817db2f46b16900104bcdff15d3f280352e7bcb0ca195060824094ebe09ea022c3e46b52c8f559c0cc5b
data/CONTRIBUTING.md CHANGED
@@ -1,21 +1,22 @@
1
1
  ## Submitting a Pull Request
2
2
 
3
- 0. Check out Hacking on Octokit in the README guide for
4
- bootstrapping the project for local development.
5
- 1. [Fork the repository.][fork]
6
- 2. [Create a topic branch.][branch]
7
- 3. Add specs for your unimplemented feature or bug fix.
8
- 4. Run `script/test`. If your specs pass, return to step 3.
9
- 5. Implement your feature or bug fix.
10
- 6. Run `script/test`. If your specs fail, return to step 5.
11
- 7. Run `open coverage/index.html`. If your changes are not completely covered
3
+ 0. Read our [Code of Conduct](CODE_OF_CONDUCT.md).
4
+ 1. Check out [Hacking on Octokit](README.md#hacking-on-octokitrb) in the
5
+ README for bootstrapping the project for local development.
6
+ 2. [Fork the repository.][fork]
7
+ 3. [Create a topic branch.][branch]
8
+ 4. Add specs for your unimplemented feature or bug fix.
9
+ 5. Run `script/test`. If your specs pass, return to step 3.
10
+ 6. Implement your feature or bug fix.
11
+ 7. Run `script/test`. If your specs fail, return to step 5.
12
+ 8. Run `open coverage/index.html`. If your changes are not completely covered
12
13
  by your tests, return to step 4.
13
- 8. Add documentation for your feature or bug fix.
14
- 9. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go
14
+ 9. Add documentation for your feature or bug fix.
15
+ 10. Run `bundle exec rake doc:yard`. If your changes are not 100% documented, go
15
16
  back to step 8.
16
- 10. Add, commit, and push your changes. For documentation-only fixes, please
17
+ 11. Add, commit, and push your changes. For documentation-only fixes, please
17
18
  add "[ci skip]" to your commit message to avoid needless CI builds.
18
- 11. [Submit a pull request.][pr]
19
+ 12. [Submit a pull request.][pr]
19
20
 
20
21
  [fork]: https://help.github.com/articles/fork-a-repo
21
22
  [branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
data/README.md CHANGED
@@ -41,7 +41,8 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
41
41
  1. [Debugging](#debugging)
42
42
  2. [Caching](#caching)
43
43
  14. [Hacking on Octokit.rb](#hacking-on-octokitrb)
44
- 1. [Running and writing new tests](#running-and-writing-new-tests)
44
+ 1. [Code of Conduction](#code_of_conduct)
45
+ 2. [Running and writing new tests](#running-and-writing-new-tests)
45
46
  15. [Supported Ruby Versions](#supported-ruby-versions)
46
47
  16. [Versioning](#versioning)
47
48
  17. [Making Repeating Requests](#making-repeating-requests)
@@ -63,7 +64,7 @@ client.readme 'al3x/sovereign', :accept => 'application/vnd.github.html'
63
64
  ```
64
65
 
65
66
  [wrappers]: http://wynnnetherland.com/journal/what-makes-a-good-api-wrapper
66
- [github-api]: http://developer.github.com
67
+ [github-api]: https://developer.github.com/v3/
67
68
 
68
69
  ## Quick start
69
70
 
@@ -289,7 +290,7 @@ link relations](#hypermedia-agent).
289
290
 
290
291
  ```ruby
291
292
  issues = client.issues 'rails/rails'
292
- issues.concat client.last_response.rels[:next].get.data
293
+ issues.concat client.get(client.last_response.rels[:next].href)
293
294
  ```
294
295
 
295
296
  ### Auto pagination
@@ -650,9 +651,15 @@ to run a Ruby console to poke on Octokit, you can crank one up with:
650
651
 
651
652
  script/console
652
653
 
653
- Using the scripts in `./scripts` instead of `bundle exec rspec`, `bundle
654
+ Using the scripts in `./script` instead of `bundle exec rspec`, `bundle
654
655
  console`, etc. ensures your dependencies are up-to-date.
655
656
 
657
+ ### Code of Conduct
658
+
659
+ We want both the Octokit.rb and larger Octokit communities to be an open
660
+ and welcoming environments. Please read and follow both in spirit and
661
+ letter [Code of Conduct](CODE_OF_CONDUCT.md).
662
+
656
663
  ### Running and writing new tests
657
664
 
658
665
  Octokit uses [VCR][] for recording and playing back API fixtures during test
@@ -706,16 +713,12 @@ when writing new specs.
706
713
 
707
714
  ## Supported Ruby Versions
708
715
 
709
- This library aims to support and is [tested against][travis] the following Ruby
716
+ This library aims to support and is [tested against][actions] the following Ruby
710
717
  implementations:
711
718
 
712
- * Ruby 2.0
713
- * Ruby 2.1
714
- * Ruby 2.2
715
- * Ruby 2.3
716
- * Ruby 2.4
717
719
  * Ruby 2.5
718
720
  * Ruby 2.6
721
+ * Ruby 2.7
719
722
 
720
723
  If something doesn't work on one of these Ruby versions, it's a bug.
721
724
 
@@ -730,7 +733,7 @@ implementation, you will be responsible for providing patches in a timely
730
733
  fashion. If critical issues for a particular implementation exist at the time
731
734
  of a major release, support for that Ruby version may be dropped.
732
735
 
733
- [travis]: https://travis-ci.org/octokit/octokit.rb
736
+ [actions]: https://github.com/octokit/octokit.rb/actions
734
737
 
735
738
  ## Versioning
736
739
 
@@ -752,7 +755,7 @@ The changes made between versions can be seen on the [project releases page][rel
752
755
  [releases]: https://github.com/octokit/octokit.rb/releases
753
756
 
754
757
  ## Making Repeating Requests
755
- In most cases it would be best to use a [webhooks](https://developer.github.com/webhooks/), but sometimes webhooks don't provide all of the information needed. In those cases where one might need to poll for progress or retry a request on failure, we designed [Octopoller](https://github.com/octokit/octopoller.rb). Octopoller is a micro gem perfect for making repeating requests.
758
+ In most cases it would be best to use a [webhooks](https://developer.github.com/webhooks/), but sometimes webhooks don't provide all of the information needed. In those cases where one might need to poll for progress or retry a request on failure, we designed [Octopoller](https://github.com/octokit/octopoller.rb). Octopoller is a micro gem perfect for making repeating requests.
756
759
 
757
760
  ```ruby
758
761
  Octopoller.poll(timeout: 15.seconds) do
@@ -43,22 +43,13 @@ module Octokit
43
43
  # requests at a higher rate limit
44
44
  #
45
45
  # @see https://developer.github.com/v3/#unauthenticated-rate-limited-requests
46
- # @return Boolean
46
+ # @return [Boolean]
47
47
  def application_authenticated?
48
- !!application_authentication
48
+ !!(@client_id && @client_secret)
49
49
  end
50
50
 
51
51
  private
52
52
 
53
- def application_authentication
54
- if @client_id && @client_secret
55
- {
56
- :client_id => @client_id,
57
- :client_secret => @client_secret
58
- }
59
- end
60
- end
61
-
62
53
  def login_from_netrc
63
54
  return unless netrc?
64
55
 
@@ -0,0 +1,58 @@
1
+ module Octokit
2
+ class Client
3
+
4
+ # Methods for the Actions Secrets API
5
+ #
6
+ # @see https://developer.github.com/v3/actions/secrets/
7
+ module ActionsSecrets
8
+
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://developer.github.com/v3/actions/secrets/#get-your-public-key
14
+ def get_public_key(repo)
15
+ get "#{Repository.path repo}/actions/secrets/public-key"
16
+ end
17
+
18
+
19
+ # List secrets
20
+ #
21
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
22
+ # @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
23
+ # @see https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository
24
+ def list_secrets(repo)
25
+ paginate "#{Repository.path repo}/actions/secrets"
26
+ end
27
+
28
+ # Get a secret
29
+ #
30
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
31
+ # @param name [String] Name of secret
32
+ # @return [Hash] name, created_at and updated_at
33
+ # @see https://developer.github.com/v3/actions/secrets/#get-a-secret
34
+ def get_secret(repo, name)
35
+ get "#{Repository.path repo}/actions/secrets/#{name}"
36
+ end
37
+
38
+ # Create or update secrets
39
+ #
40
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
41
+ # @param name [String] Name of secret
42
+ # @param options [Hash] encrypted_value and key_id
43
+ # @see https://developer.github.com/v3/actions/secrets/#create-or-update-a-secret-for-a-repository
44
+ def create_or_update_secret(repo, name, options)
45
+ put "#{Repository.path repo}/actions/secrets/#{name}", options
46
+ end
47
+
48
+ # Delete a secret
49
+ #
50
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
51
+ # @param name [String] Name of secret
52
+ # @see https://developer.github.com/v3/actions/secrets/#delete-a-secret-from-a-repository
53
+ def delete_secret(repo, name)
54
+ boolean_from_response :delete, "#{Repository.path repo}/actions/secrets/#{name}"
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,94 @@
1
+ module Octokit
2
+ class Client
3
+ module ActionsWorkflowRuns
4
+ # List all runs for a repository workflow
5
+ #
6
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
7
+ # @param workflow [Integer, String] Id or file name of the workflow
8
+ # @option options [String] :actor Optional filtering by a user
9
+ # @option options [String] :branch Optional filtering by a branch
10
+ # @option options [String] :event Optional filtering by the event type
11
+ # @option options [String] :status Optional filtering by a status or conclusion
12
+ #
13
+ # @return [Sawyer::Resource] the total count and an array of workflows
14
+ # @see https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
15
+ def workflow_runs(repo, workflow, options = {})
16
+ paginate "#{Repository.path repo}/actions/workflows/#{workflow}/runs", options
17
+ end
18
+ alias list_workflow_runs workflow_runs
19
+
20
+ # List all workflow runs for a repository
21
+ #
22
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
23
+ # @option options [String] :actor Optional filtering by the login of a user
24
+ # @option options [String] :branch Optional filtering by a branch
25
+ # @option options [String] :event Optional filtering by the event type (e.g. push, pull_request, issue)
26
+ # @option options [String] :status Optional filtering by a status or conclusion (e.g. success, completed...)
27
+ #
28
+ # @return [Sawyer::Resource] the total count and an array of workflows
29
+ # @see https://developer.github.com/v3/actions/workflow-runs/#list-repository-workflow-runs
30
+ def repository_workflow_runs(repo, options = {})
31
+ paginate "#{Repository.path repo}/actions/runs", options
32
+ end
33
+ alias list_repository_workflow_runs repository_workflow_runs
34
+
35
+ # Get a workflow run
36
+ #
37
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
38
+ # @param id [Integer] Id of a workflow run
39
+ #
40
+ # @return [Sawyer::Resource] Run information
41
+ # @see https://developer.github.com/v3/actions/workflow-runs/#get-a-workflow-run
42
+ def workflow_run(repo, id, options = {})
43
+ get "#{Repository.path repo}/actions/runs/#{id}", options
44
+ end
45
+
46
+ # Re-runs a workflow run
47
+ #
48
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
49
+ # @param id [Integer] Id of a workflow run
50
+ #
51
+ # @return [Boolean] Returns true if the re-run request was accepted
52
+ # @see https://developer.github.com/v3/actions/workflow-runs/#re-run-a-workflow
53
+ def rerun_workflow_run(repo, id, options = {})
54
+ boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/rerun", options
55
+ end
56
+
57
+ # Cancels a workflow run
58
+ #
59
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
60
+ # @param id [Integer] Id of a workflow run
61
+ #
62
+ # @return [Boolean] Returns true if the cancellation was accepted
63
+ # @see https://developer.github.com/v3/actions/workflow-runs/#cancel-a-workflow-run
64
+ def cancel_workflow_run(repo, id, options = {})
65
+ boolean_from_response :post, "#{Repository.path repo}/actions/runs/#{id}/cancel", options
66
+ end
67
+
68
+ # Get a download url for archived log files of a workflow run
69
+ #
70
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
71
+ # @param id [Integer] Id of a workflow run
72
+ #
73
+ # @return [String] URL to the archived log files of the run
74
+ # @see https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
75
+ def workflow_run_logs(repo, id, options = {})
76
+ url = "#{Repository.path repo}/actions/runs/#{id}/logs"
77
+
78
+ response = client_without_redirects.head(url, options)
79
+ response.headers['Location']
80
+ end
81
+
82
+ # Delets all log files of a workflow run
83
+ #
84
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
85
+ # @param id [Integer] Id of a workflow run
86
+ #
87
+ # @return [Boolean] Returns true if the logs are deleted
88
+ # @see https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
89
+ def delete_workflow_run_logs(repo, id, options = {})
90
+ boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,43 @@
1
+ module Octokit
2
+ class Client
3
+ # Methods for the Actions Workflows API
4
+ #
5
+ # @see https://developer.github.com/v3/actions/workflows
6
+ module ActionsWorkflows
7
+
8
+ # Get the workflows in a repository
9
+ #
10
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
11
+ #
12
+ # @return [Sawyer::Resource] the total count and an array of workflows
13
+ # @see https://developer.github.com/v3/actions/workflows/#list-repository-workflows
14
+ def workflows(repo, options = {})
15
+ paginate "#{Repository.path repo}/actions/workflows", options
16
+ end
17
+ alias list_workflows workflows
18
+
19
+ # Get single workflow in a repository
20
+ #
21
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
22
+ # @param id [Integer, String] Id or file name of the workflow
23
+ #
24
+ # @return [Sawyer::Resource] A single workflow
25
+ # @see https://developer.github.com/v3/actions/workflows/#get-a-workflow
26
+ def workflow(repo, id, options = {})
27
+ get "#{Repository.path repo}/actions/workflows/#{id}", options
28
+ end
29
+
30
+ # Create a workflow dispatch event
31
+ #
32
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
33
+ # @param id [Integer, String] Id or file name of the workflow
34
+ # @param ref [String] A SHA, branch name, or tag name
35
+ #
36
+ # @return [Boolean] True if event was dispatched, false otherwise
37
+ # @see https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
38
+ def workflow_dispatch(repo, id, ref, options = {})
39
+ boolean_from_response :post, "#{Repository.path repo}/actions/workflows/#{id}/dispatches", options.merge({ ref: ref })
40
+ end
41
+ end
42
+ end
43
+ end
@@ -4,11 +4,23 @@ module Octokit
4
4
  # Methods for the Apps API
5
5
  module Apps
6
6
 
7
+ # Get the authenticated App
8
+ #
9
+ # @param options [Hash] A customizable set of options
10
+ #
11
+ # @see https://developer.github.com/v3/apps/#get-the-authenticated-app
12
+ #
13
+ # @return [Sawyer::Resource] App information
14
+ def app(options = {})
15
+ opts = ensure_api_media_type(:integrations, options)
16
+ get "app", opts
17
+ end
18
+
7
19
  # Find all installations that belong to an App
8
20
  #
9
21
  # @param options [Hash] A customizable set of options
10
22
  #
11
- # @see https://developer.github.com/v3/apps/#find-installations
23
+ # @see https://developer.github.com/v3/apps/#list-installations
12
24
  #
13
25
  # @return [Array<Sawyer::Resource>] the total_count and an array of installations
14
26
  def find_app_installations(options = {})
@@ -31,7 +43,7 @@ module Octokit
31
43
  #
32
44
  # @param options [Hash] A customizable set of options
33
45
  #
34
- # @see https://developer.github.com/v3/apps/#list-installations-for-user
46
+ # @see https://developer.github.com/v3/apps/installations/#list-installations-for-a-user
35
47
  #
36
48
  # @return [Sawyer::Resource] the total_count and an array of installations
37
49
  def find_user_installations(options = {})
@@ -45,7 +57,7 @@ module Octokit
45
57
  #
46
58
  # @param id [Integer] Installation id
47
59
  #
48
- # @see https://developer.github.com/v3/apps/#get-a-single-installation
60
+ # @see https://developer.github.com/v3/apps/#get-an-installation
49
61
  #
50
62
  # @return [Sawyer::Resource] Installation information
51
63
  def installation(id, options = {})
@@ -58,7 +70,7 @@ module Octokit
58
70
  # @param installation [Integer] The id of a GitHub App Installation
59
71
  # @param options [Hash] A customizable set of options
60
72
  #
61
- # @see https://developer.github.com/v3/apps/#find-installations
73
+ # @see https://developer.github.com/v3/apps/#create-a-new-installation-token
62
74
  #
63
75
  # @return [<Sawyer::Resource>] An installation token
64
76
  def create_app_installation_access_token(installation, options = {})
@@ -82,7 +94,7 @@ module Octokit
82
94
  # @param organization [String] Organization GitHub login
83
95
  # @param options [Hash] A customizable set of options
84
96
  #
85
- # @see https://developer.github.com/v3/apps/#find-organization-installation
97
+ # @see https://developer.github.com/v3/apps/#get-an-organization-installation
86
98
  #
87
99
  # @return [Sawyer::Resource] Installation information
88
100
  def find_organization_installation(organization, options = {})
@@ -95,7 +107,7 @@ module Octokit
95
107
  # @param repo [String] A GitHub repository
96
108
  # @param options [Hash] A customizable set of options
97
109
  #
98
- # @see https://developer.github.com/v3/apps/#find-repository-installation
110
+ # @see https://developer.github.com/v3/apps/#get-a-repository-installation
99
111
  #
100
112
  # @return [Sawyer::Resource] Installation information
101
113
  def find_repository_installation(repo, options = {})
@@ -108,7 +120,7 @@ module Octokit
108
120
  # @param user [String] GitHub user login
109
121
  # @param options [Hash] A customizable set of options
110
122
  #
111
- # @see https://developer.github.com/v3/apps/#find-user-installation
123
+ # @see https://developer.github.com/v3/apps/#get-a-user-installation
112
124
  #
113
125
  # @return [Sawyer::Resource] Installation information
114
126
  def find_user_installation(user, options = {})
@@ -119,6 +131,7 @@ module Octokit
119
131
  # List repositories that are accessible to the authenticated installation
120
132
  #
121
133
  # @param options [Hash] A customizable set of options
134
+ #
122
135
  # @see https://developer.github.com/v3/apps/installations/#list-repositories
123
136
  #
124
137
  # @return [Sawyer::Resource] the total_count and an array of repositories
@@ -195,7 +208,7 @@ module Octokit
195
208
  # @param installation [Integer] The id of a GitHub App Installation
196
209
  # @param options [Hash] A customizable set of options
197
210
  #
198
- # @see https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/identifying-users-for-github-apps/
211
+ # @see https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation
199
212
  #
200
213
  # @return [Sawyer::Resource] the total_count and an array of repositories
201
214
  def find_installation_repositories_for_user(installation, options = {})
@@ -204,6 +217,19 @@ module Octokit
204
217
  data.repositories.concat last_response.data.repositories
205
218
  end
206
219
  end
220
+
221
+ # Delete an installation and uninstall a GitHub App
222
+ #
223
+ # @param installation [Integer] The id of a GitHub App Installation
224
+ # @param options [Hash] A customizable set of options
225
+ #
226
+ # @see https://developer.github.com/v3/apps/#delete-an-installation
227
+ #
228
+ # @return [Boolean] Success
229
+ def delete_installation(installation, options = {})
230
+ opts = ensure_api_media_type(:uninstall_github_app, options)
231
+ boolean_from_response :delete, "app/installations/#{installation}", opts
232
+ end
207
233
  end
208
234
  end
209
235
  end
@@ -59,7 +59,7 @@ module Octokit
59
59
  # client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
60
60
  # client.create_authorization({:idempotent => true, :client_id => 'xxxx', :client_secret => 'yyyy', :scopes => ["user"]})
61
61
  def create_authorization(options = {})
62
- # Techincally we can omit scopes as GitHub has a default, however the
62
+ # Technically we can omit scopes as GitHub has a default, however the
63
63
  # API will reject us if we send a POST request with an empty body.
64
64
  options = options.dup
65
65
  if options.delete :idempotent
@@ -140,74 +140,6 @@ module Octokit
140
140
  sort
141
141
  end
142
142
 
143
- # Check if a token is valid.
144
- #
145
- # Applications can check if a token is valid without rate limits.
146
- #
147
- # @param token [String] 40 character GitHub OAuth access token
148
- #
149
- # @return [Sawyer::Resource] A single authorization for the authenticated user
150
- # @see https://developer.github.com/v3/oauth_authorizations/#check-an-authorization
151
- # @example
152
- # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
153
- # client.check_application_authorization('deadbeef1234567890deadbeef987654321')
154
- def check_application_authorization(token, options = {})
155
- opts = options.dup
156
- key = opts.delete(:client_id) || client_id
157
- secret = opts.delete(:client_secret) || client_secret
158
-
159
- as_app(key, secret) do |app_client|
160
- app_client.get "applications/#{client_id}/tokens/#{token}", opts
161
- end
162
- end
163
-
164
- # Reset a token
165
- #
166
- # Applications can reset a token without requiring a user to re-authorize.
167
- #
168
- # @param token [String] 40 character GitHub OAuth access token
169
- #
170
- # @return [Sawyer::Resource] A single authorization for the authenticated user
171
- # @see https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization
172
- # @example
173
- # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
174
- # client.reset_application_authorization('deadbeef1234567890deadbeef987654321')
175
- def reset_application_authorization(token, options = {})
176
- opts = options.dup
177
- key = opts.delete(:client_id) || client_id
178
- secret = opts.delete(:client_secret) || client_secret
179
-
180
- as_app(key, secret) do |app_client|
181
- app_client.post "applications/#{client_id}/tokens/#{token}", opts
182
- end
183
- end
184
-
185
- # Revoke a token
186
- #
187
- # Applications can revoke (delete) a token
188
- #
189
- # @param token [String] 40 character GitHub OAuth access token
190
- #
191
- # @return [Boolean] Result
192
- # @see https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application
193
- # @example
194
- # client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
195
- # client.revoke_application_authorization('deadbeef1234567890deadbeef987654321')
196
- def revoke_application_authorization(token, options = {})
197
- opts = options.dup
198
- key = opts.delete(:client_id) || client_id
199
- secret = opts.delete(:client_secret) || client_secret
200
-
201
- as_app(key, secret) do |app_client|
202
- app_client.delete "applications/#{client_id}/tokens/#{token}", opts
203
-
204
- app_client.last_response.status == 204
205
- end
206
- rescue Octokit::NotFound
207
- false
208
- end
209
- alias :delete_application_authorization :revoke_application_authorization
210
-
211
143
  # Revoke all tokens for an app
212
144
  #
213
145
  # Applications can revoke all of their tokens in a single request
@@ -233,7 +165,7 @@ module Octokit
233
165
  def authorize_url(app_id = client_id, options = {})
234
166
  opts = options.dup
235
167
  if app_id.to_s.empty?
236
- raise Octokit::ApplicationCredentialsRequired.new "client_id required"
168
+ raise Octokit::ApplicationCredentialsRequired, "client_id required"
237
169
  end
238
170
  authorize_url = opts.delete(:endpoint) || Octokit.web_endpoint
239
171
  authorize_url << "login/oauth/authorize?client_id=#{app_id}"
@@ -0,0 +1,20 @@
1
+ module Octokit
2
+ class Client
3
+
4
+ # Methods for the Branches for HEAD API
5
+ #
6
+ # @see https://developer.github.com/v3/repos/commits/
7
+ module CommitBranches
8
+
9
+ # List branches for a single HEAD commit
10
+ #
11
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
12
+ # @param sha [String] The SHA of the commit whose branches will be fetched
13
+ # @return [Array] List of branches
14
+ # @see https://developer.github.com/v3/repos/commits/#list-branches-for-head-commit
15
+ def commit_branches(repo, sha, options = {})
16
+ paginate "#{Repository.path repo}/commits/#{sha}/branches-where-head", options
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Octokit
2
+ class Client
3
+
4
+ # Methods for the Commit Pulls API
5
+ #
6
+ # @see https://developer.github.com/v3/repos/comments/
7
+ module CommitPulls
8
+
9
+ # List pulls for a single commit
10
+ #
11
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
12
+ # @param sha [String] The SHA of the commit whose pulls will be fetched
13
+ # @return [Array] List of commit pulls
14
+ # @see https://developer.github.com/v3/repos/commits/#list-pull-requests-associated-with-commit
15
+ def commit_pulls(repo, sha, options = {})
16
+ paginate "#{Repository.path repo}/commits/#{sha}/pulls", options
17
+ end
18
+ end
19
+ end
20
+ end
@@ -131,6 +131,7 @@ 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)
134
135
  paginate "#{Repository.path repo}/issues/#{number}/events", options
135
136
  end
136
137