octokit 4.18.0 → 4.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +2 -4
- data/README.md +10 -14
- data/lib/octokit/authentication.rb +1 -1
- data/lib/octokit/client.rb +6 -0
- data/lib/octokit/client/actions_secrets.rb +58 -0
- data/lib/octokit/client/actions_workflow_runs.rb +105 -0
- data/lib/octokit/client/actions_workflows.rb +43 -0
- data/lib/octokit/client/apps.rb +23 -24
- data/lib/octokit/client/authorizations.rb +1 -1
- data/lib/octokit/client/checks.rb +0 -20
- data/lib/octokit/client/contents.rb +4 -0
- data/lib/octokit/client/deployments.rb +10 -0
- data/lib/octokit/client/oauth_applications.rb +2 -2
- data/lib/octokit/client/organizations.rb +25 -11
- data/lib/octokit/client/refs.rb +12 -0
- data/lib/octokit/client/repositories.rb +82 -8
- data/lib/octokit/client/users.rb +86 -0
- data/lib/octokit/connection.rb +10 -7
- data/lib/octokit/error.rb +36 -2
- data/lib/octokit/preview.rb +1 -4
- data/lib/octokit/rate_limit.rb +1 -1
- data/lib/octokit/response/feed_parser.rb +0 -2
- data/lib/octokit/response/raise_error.rb +0 -2
- data/lib/octokit/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be4c54d083639a915bef0eb235748b93351f17f2a98e204b7b9f2899c156f2f6
|
4
|
+
data.tar.gz: 21998779cea8f95e63b1814dc264102c1ac69c9d66fef6694ef6442554419bbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14221c5912859f6fa1a9f3dce7d7ee1cb6b5730bc1a95c997e84ff2972f23a3e8eaad723acbabd57982afadc1f4bb1538af510bd10583e21e0f208c7712ce1e6
|
7
|
+
data.tar.gz: 23300ee9b4e73fc660a391018efbc969742dbdc9740faa57ed7609853830689cc1edcca8d445df2d939f2d7353056f828b53ad44b33269573ed06a8e93b8dbd4
|
data/CONTRIBUTING.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
## Submitting a Pull Request
|
2
2
|
|
3
3
|
0. Read our [Code of Conduct](CODE_OF_CONDUCT.md).
|
4
|
-
1. Check out Hacking on Octokit in the
|
5
|
-
bootstrapping the project for local development.
|
4
|
+
1. Check out [Hacking on Octokit](README.md#hacking-on-octokitrb) in the
|
5
|
+
README for bootstrapping the project for local development.
|
6
6
|
2. [Fork the repository.][fork]
|
7
7
|
3. [Create a topic branch.][branch]
|
8
8
|
4. Add specs for your unimplemented feature or bug fix.
|
@@ -18,8 +18,6 @@
|
|
18
18
|
add "[ci skip]" to your commit message to avoid needless CI builds.
|
19
19
|
12. [Submit a pull request.][pr]
|
20
20
|
|
21
|
-
Please abide by
|
22
|
-
|
23
21
|
[fork]: https://help.github.com/articles/fork-a-repo
|
24
22
|
[branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/
|
25
23
|
[pr]: https://help.github.com/articles/using-pull-requests
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby toolkit for the GitHub API.
|
4
4
|
|
5
|
-
![logo](
|
5
|
+
![logo](https://docs.github.com/assets/images/gundamcat.png)
|
6
6
|
|
7
7
|
Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
8
8
|
[major version][semver].
|
@@ -41,7 +41,7 @@ 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. [Code of
|
44
|
+
1. [Code of Conduct](#code-of-conduct)
|
45
45
|
2. [Running and writing new tests](#running-and-writing-new-tests)
|
46
46
|
15. [Supported Ruby Versions](#supported-ruby-versions)
|
47
47
|
16. [Versioning](#versioning)
|
@@ -86,10 +86,10 @@ Access the library in Ruby:
|
|
86
86
|
|
87
87
|
```ruby
|
88
88
|
# Provide authentication credentials
|
89
|
-
client = Octokit::Client.new(:
|
89
|
+
client = Octokit::Client.new(:access_token => 'personal_access_token')
|
90
90
|
|
91
|
-
#
|
92
|
-
# client = Octokit::Client.new(:
|
91
|
+
# You can still use the username/password syntax by replacing the password value with your PAT.
|
92
|
+
# client = Octokit::Client.new(:login => 'defunkt', :password => 'personal_access_token')
|
93
93
|
|
94
94
|
# Fetch the current user
|
95
95
|
client.user
|
@@ -323,7 +323,7 @@ custom pattern for traversing large lists.
|
|
323
323
|
|
324
324
|
## Working with GitHub Enterprise
|
325
325
|
|
326
|
-
With a bit of setup, you can also use Octokit with your
|
326
|
+
With a bit of setup, you can also use Octokit with your GitHub Enterprise instance.
|
327
327
|
|
328
328
|
### Interacting with the GitHub.com APIs in GitHub Enterprise
|
329
329
|
|
@@ -651,7 +651,7 @@ to run a Ruby console to poke on Octokit, you can crank one up with:
|
|
651
651
|
|
652
652
|
script/console
|
653
653
|
|
654
|
-
Using the scripts in `./
|
654
|
+
Using the scripts in `./script` instead of `bundle exec rspec`, `bundle
|
655
655
|
console`, etc. ensures your dependencies are up-to-date.
|
656
656
|
|
657
657
|
### Code of Conduct
|
@@ -713,16 +713,12 @@ when writing new specs.
|
|
713
713
|
|
714
714
|
## Supported Ruby Versions
|
715
715
|
|
716
|
-
This library aims to support and is [tested against][
|
716
|
+
This library aims to support and is [tested against][actions] the following Ruby
|
717
717
|
implementations:
|
718
718
|
|
719
|
-
* Ruby 2.0
|
720
|
-
* Ruby 2.1
|
721
|
-
* Ruby 2.2
|
722
|
-
* Ruby 2.3
|
723
|
-
* Ruby 2.4
|
724
719
|
* Ruby 2.5
|
725
720
|
* Ruby 2.6
|
721
|
+
* Ruby 2.7
|
726
722
|
|
727
723
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
728
724
|
|
@@ -737,7 +733,7 @@ implementation, you will be responsible for providing patches in a timely
|
|
737
733
|
fashion. If critical issues for a particular implementation exist at the time
|
738
734
|
of a major release, support for that Ruby version may be dropped.
|
739
735
|
|
740
|
-
[
|
736
|
+
[actions]: https://github.com/octokit/octokit.rb/actions
|
741
737
|
|
742
738
|
## Versioning
|
743
739
|
|
data/lib/octokit/client.rb
CHANGED
@@ -10,6 +10,9 @@ require 'octokit/repository'
|
|
10
10
|
require 'octokit/user'
|
11
11
|
require 'octokit/organization'
|
12
12
|
require 'octokit/preview'
|
13
|
+
require 'octokit/client/actions_secrets'
|
14
|
+
require 'octokit/client/actions_workflows'
|
15
|
+
require 'octokit/client/actions_workflow_runs'
|
13
16
|
require 'octokit/client/apps'
|
14
17
|
require 'octokit/client/authorizations'
|
15
18
|
require 'octokit/client/checks'
|
@@ -72,6 +75,7 @@ module Octokit
|
|
72
75
|
include Octokit::Connection
|
73
76
|
include Octokit::Preview
|
74
77
|
include Octokit::Warnable
|
78
|
+
include Octokit::Client::ActionsSecrets
|
75
79
|
include Octokit::Client::Authorizations
|
76
80
|
include Octokit::Client::Checks
|
77
81
|
include Octokit::Client::Commits
|
@@ -88,6 +92,8 @@ module Octokit
|
|
88
92
|
include Octokit::Client::Gists
|
89
93
|
include Octokit::Client::Gitignore
|
90
94
|
include Octokit::Client::Hooks
|
95
|
+
include Octokit::Client::ActionsWorkflows
|
96
|
+
include Octokit::Client::ActionsWorkflowRuns
|
91
97
|
include Octokit::Client::Apps
|
92
98
|
include Octokit::Client::Issues
|
93
99
|
include Octokit::Client::Labels
|
@@ -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,105 @@
|
|
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
|
+
# Deletes 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 [Boolean] Returns true if the run is deleted
|
74
|
+
# @see https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run
|
75
|
+
def delete_workflow_run(repo, id, options = {})
|
76
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}", options
|
77
|
+
end
|
78
|
+
|
79
|
+
# Get a download url for archived log files of a workflow run
|
80
|
+
#
|
81
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
82
|
+
# @param id [Integer] Id of a workflow run
|
83
|
+
#
|
84
|
+
# @return [String] URL to the archived log files of the run
|
85
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#download-workflow-run-logs
|
86
|
+
def workflow_run_logs(repo, id, options = {})
|
87
|
+
url = "#{Repository.path repo}/actions/runs/#{id}/logs"
|
88
|
+
|
89
|
+
response = client_without_redirects.head(url, options)
|
90
|
+
response.headers['Location']
|
91
|
+
end
|
92
|
+
|
93
|
+
# Delets all log files of a workflow run
|
94
|
+
#
|
95
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
96
|
+
# @param id [Integer] Id of a workflow run
|
97
|
+
#
|
98
|
+
# @return [Boolean] Returns true if the logs are deleted
|
99
|
+
# @see https://developer.github.com/v3/actions/workflow-runs/#delete-workflow-run-logs
|
100
|
+
def delete_workflow_run_logs(repo, id, options = {})
|
101
|
+
boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
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
|
data/lib/octokit/client/apps.rb
CHANGED
@@ -4,6 +4,17 @@ 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
|
+
get "app", options
|
16
|
+
end
|
17
|
+
|
7
18
|
# Find all installations that belong to an App
|
8
19
|
#
|
9
20
|
# @param options [Hash] A customizable set of options
|
@@ -12,8 +23,7 @@ module Octokit
|
|
12
23
|
#
|
13
24
|
# @return [Array<Sawyer::Resource>] the total_count and an array of installations
|
14
25
|
def find_app_installations(options = {})
|
15
|
-
|
16
|
-
paginate "app/installations", opts
|
26
|
+
paginate "app/installations", options
|
17
27
|
end
|
18
28
|
alias find_installations find_app_installations
|
19
29
|
|
@@ -35,8 +45,7 @@ module Octokit
|
|
35
45
|
#
|
36
46
|
# @return [Sawyer::Resource] the total_count and an array of installations
|
37
47
|
def find_user_installations(options = {})
|
38
|
-
|
39
|
-
paginate("user/installations", opts) do |data, last_response|
|
48
|
+
paginate("user/installations", options) do |data, last_response|
|
40
49
|
data.installations.concat last_response.data.installations
|
41
50
|
end
|
42
51
|
end
|
@@ -49,8 +58,7 @@ module Octokit
|
|
49
58
|
#
|
50
59
|
# @return [Sawyer::Resource] Installation information
|
51
60
|
def installation(id, options = {})
|
52
|
-
|
53
|
-
get "app/installations/#{id}", opts
|
61
|
+
get "app/installations/#{id}", options
|
54
62
|
end
|
55
63
|
|
56
64
|
# Create a new installation token
|
@@ -62,8 +70,7 @@ module Octokit
|
|
62
70
|
#
|
63
71
|
# @return [<Sawyer::Resource>] An installation token
|
64
72
|
def create_app_installation_access_token(installation, options = {})
|
65
|
-
|
66
|
-
post "app/installations/#{installation}/access_tokens", opts
|
73
|
+
post "app/installations/#{installation}/access_tokens", options
|
67
74
|
end
|
68
75
|
alias create_installation_access_token create_app_installation_access_token
|
69
76
|
|
@@ -86,8 +93,7 @@ module Octokit
|
|
86
93
|
#
|
87
94
|
# @return [Sawyer::Resource] Installation information
|
88
95
|
def find_organization_installation(organization, options = {})
|
89
|
-
|
90
|
-
get "#{Organization.path(organization)}/installation", opts
|
96
|
+
get "#{Organization.path(organization)}/installation", options
|
91
97
|
end
|
92
98
|
|
93
99
|
# Enables an app to find the repository's installation information.
|
@@ -99,8 +105,7 @@ module Octokit
|
|
99
105
|
#
|
100
106
|
# @return [Sawyer::Resource] Installation information
|
101
107
|
def find_repository_installation(repo, options = {})
|
102
|
-
|
103
|
-
get "#{Repository.path(repo)}/installation", opts
|
108
|
+
get "#{Repository.path(repo)}/installation", options
|
104
109
|
end
|
105
110
|
|
106
111
|
# Enables an app to find the user's installation information.
|
@@ -112,8 +117,7 @@ module Octokit
|
|
112
117
|
#
|
113
118
|
# @return [Sawyer::Resource] Installation information
|
114
119
|
def find_user_installation(user, options = {})
|
115
|
-
|
116
|
-
get "#{User.path(user)}/installation", opts
|
120
|
+
get "#{User.path(user)}/installation", options
|
117
121
|
end
|
118
122
|
|
119
123
|
# List repositories that are accessible to the authenticated installation
|
@@ -124,8 +128,7 @@ module Octokit
|
|
124
128
|
#
|
125
129
|
# @return [Sawyer::Resource] the total_count and an array of repositories
|
126
130
|
def list_app_installation_repositories(options = {})
|
127
|
-
|
128
|
-
paginate("installation/repositories", opts) do |data, last_response|
|
131
|
+
paginate("installation/repositories", options) do |data, last_response|
|
129
132
|
data.repositories.concat last_response.data.repositories
|
130
133
|
end
|
131
134
|
end
|
@@ -151,8 +154,7 @@ module Octokit
|
|
151
154
|
#
|
152
155
|
# @return [Boolean] Success
|
153
156
|
def add_repository_to_app_installation(installation, repo, options = {})
|
154
|
-
|
155
|
-
boolean_from_response :put, "user/installations/#{installation}/repositories/#{repo}", opts
|
157
|
+
boolean_from_response :put, "user/installations/#{installation}/repositories/#{repo}", options
|
156
158
|
end
|
157
159
|
alias add_repo_to_installation add_repository_to_app_installation
|
158
160
|
|
@@ -176,8 +178,7 @@ module Octokit
|
|
176
178
|
#
|
177
179
|
# @return [Boolean] Success
|
178
180
|
def remove_repository_from_app_installation(installation, repo, options = {})
|
179
|
-
|
180
|
-
boolean_from_response :delete, "user/installations/#{installation}/repositories/#{repo}", opts
|
181
|
+
boolean_from_response :delete, "user/installations/#{installation}/repositories/#{repo}", options
|
181
182
|
end
|
182
183
|
alias remove_repo_from_installation remove_repository_from_app_installation
|
183
184
|
|
@@ -200,8 +201,7 @@ module Octokit
|
|
200
201
|
#
|
201
202
|
# @return [Sawyer::Resource] the total_count and an array of repositories
|
202
203
|
def find_installation_repositories_for_user(installation, options = {})
|
203
|
-
|
204
|
-
paginate("user/installations/#{installation}/repositories", opts) do |data, last_response|
|
204
|
+
paginate("user/installations/#{installation}/repositories", options) do |data, last_response|
|
205
205
|
data.repositories.concat last_response.data.repositories
|
206
206
|
end
|
207
207
|
end
|
@@ -215,8 +215,7 @@ module Octokit
|
|
215
215
|
#
|
216
216
|
# @return [Boolean] Success
|
217
217
|
def delete_installation(installation, options = {})
|
218
|
-
|
219
|
-
boolean_from_response :delete, "app/installations/#{installation}", opts
|
218
|
+
boolean_from_response :delete, "app/installations/#{installation}", options
|
220
219
|
end
|
221
220
|
end
|
222
221
|
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
|
-
#
|
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
|
@@ -23,7 +23,6 @@ module Octokit
|
|
23
23
|
# check_run.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
|
24
24
|
# check_run.status # => "queued"
|
25
25
|
def create_check_run(repo, name, head_sha, options = {})
|
26
|
-
ensure_api_media_type(:checks, options)
|
27
26
|
options[:name] = name
|
28
27
|
options[:head_sha] = head_sha
|
29
28
|
|
@@ -41,8 +40,6 @@ module Octokit
|
|
41
40
|
# check_run.id # => 51295429
|
42
41
|
# check_run.status # => "in_progress"
|
43
42
|
def update_check_run(repo, id, options = {})
|
44
|
-
ensure_api_media_type(:checks, options)
|
45
|
-
|
46
43
|
patch "#{Repository.path repo}/check-runs/#{id}", options
|
47
44
|
end
|
48
45
|
|
@@ -63,8 +60,6 @@ module Octokit
|
|
63
60
|
# result.check_runs[0].id # => 51295429
|
64
61
|
# result.check_runs[0].status # => "in_progress"
|
65
62
|
def check_runs_for_ref(repo, ref, options = {})
|
66
|
-
ensure_api_media_type(:checks, options)
|
67
|
-
|
68
63
|
get "#{Repository.path repo}/commits/#{ref}/check-runs", options
|
69
64
|
end
|
70
65
|
alias :list_check_runs_for_ref :check_runs_for_ref
|
@@ -86,8 +81,6 @@ module Octokit
|
|
86
81
|
# result.check_runs[0].check_suite.id # => 50440400
|
87
82
|
# result.check_runs[0].status # => "in_progress"
|
88
83
|
def check_runs_for_check_suite(repo, id, options = {})
|
89
|
-
ensure_api_media_type(:checks, options)
|
90
|
-
|
91
84
|
get "#{Repository.path repo}/check-suites/#{id}/check-runs", options
|
92
85
|
end
|
93
86
|
alias :list_check_runs_for_check_suite :check_runs_for_check_suite
|
@@ -99,8 +92,6 @@ module Octokit
|
|
99
92
|
# @return [Sawyer::Resource] A hash representing the check run
|
100
93
|
# @see https://developer.github.com/v3/checks/runs/#get-a-single-check-run
|
101
94
|
def check_run(repo, id, options = {})
|
102
|
-
ensure_api_media_type(:checks, options)
|
103
|
-
|
104
95
|
get "#{Repository.path repo}/check-runs/#{id}", options
|
105
96
|
end
|
106
97
|
|
@@ -116,8 +107,6 @@ module Octokit
|
|
116
107
|
# annotations[0].path # => "README.md"
|
117
108
|
# annotations[0].message # => "Looks good!"
|
118
109
|
def check_run_annotations(repo, id, options = {})
|
119
|
-
ensure_api_media_type(:checks, options)
|
120
|
-
|
121
110
|
get "#{Repository.path repo}/check-runs/#{id}/annotations", options
|
122
111
|
end
|
123
112
|
|
@@ -132,8 +121,6 @@ module Octokit
|
|
132
121
|
# @return [Sawyer::Resource] A hash representing the check suite
|
133
122
|
# @see https://developer.github.com/v3/checks/suites/#get-a-single-check-suite
|
134
123
|
def check_suite(repo, id, options = {})
|
135
|
-
ensure_api_media_type(:checks, options)
|
136
|
-
|
137
124
|
get "#{Repository.path repo}/check-suites/#{id}", options
|
138
125
|
end
|
139
126
|
|
@@ -153,8 +140,6 @@ module Octokit
|
|
153
140
|
# result.check_suites[0].id # => 50440400
|
154
141
|
# result.check_suites[0].app.id # => 76765
|
155
142
|
def check_suites_for_ref(repo, ref, options = {})
|
156
|
-
ensure_api_media_type(:checks, options)
|
157
|
-
|
158
143
|
get "#{Repository.path repo}/commits/#{ref}/check-suites", options
|
159
144
|
end
|
160
145
|
alias :list_check_suites_for_ref :check_suites_for_ref
|
@@ -172,8 +157,6 @@ module Octokit
|
|
172
157
|
# result.preferences.auto_trigger_checks[0].setting # => false
|
173
158
|
# result.repository.full_name # => "octocat/Hello-World"
|
174
159
|
def set_check_suite_preferences(repo, options = {})
|
175
|
-
ensure_api_media_type(:checks, options)
|
176
|
-
|
177
160
|
patch "#{Repository.path repo}/check-suites/preferences", options
|
178
161
|
end
|
179
162
|
|
@@ -188,7 +171,6 @@ module Octokit
|
|
188
171
|
# check_suite.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
|
189
172
|
# check_suite.status # => "queued"
|
190
173
|
def create_check_suite(repo, head_sha, options = {})
|
191
|
-
ensure_api_media_type(:checks, options)
|
192
174
|
options[:head_sha] = head_sha
|
193
175
|
|
194
176
|
post "#{Repository.path repo}/check-suites", options
|
@@ -201,8 +183,6 @@ module Octokit
|
|
201
183
|
# @return [Boolean] True if successful, raises an error otherwise
|
202
184
|
# @see https://developer.github.com/v3/checks/suites/#rerequest-check-suite
|
203
185
|
def rerequest_check_suite(repo, id, options = {})
|
204
|
-
ensure_api_media_type(:checks, options)
|
205
|
-
|
206
186
|
post "#{Repository.path repo}/check-suites/#{id}/rerequest", options
|
207
187
|
true
|
208
188
|
end
|
@@ -16,6 +16,8 @@ module Octokit
|
|
16
16
|
# @see https://developer.github.com/v3/repos/contents/#get-the-readme
|
17
17
|
# @example Get the readme file for a repo
|
18
18
|
# Octokit.readme("octokit/octokit.rb")
|
19
|
+
# @example Get the readme file for a particular branch of the repo
|
20
|
+
# Octokit.readme("octokit/octokit.rb", :query => {:ref => 'some-other-branch'})
|
19
21
|
def readme(repo, options={})
|
20
22
|
get "#{Repository.path repo}/readme", options
|
21
23
|
end
|
@@ -29,6 +31,8 @@ module Octokit
|
|
29
31
|
# @see https://developer.github.com/v3/repos/contents/#get-contents
|
30
32
|
# @example List the contents of lib/octokit.rb
|
31
33
|
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb')
|
34
|
+
# @example Lists the contents of lib /octokit.rb on a particular branch
|
35
|
+
# Octokit.contents("octokit/octokit.rb", :path => 'lib/octokit.rb', :query => {:ref => 'some-other-branch'})
|
32
36
|
def contents(repo, options={})
|
33
37
|
options = options.dup
|
34
38
|
repo_path = options.delete :path
|
@@ -43,6 +43,16 @@ module Octokit
|
|
43
43
|
post("#{Repository.path repo}/deployments", options)
|
44
44
|
end
|
45
45
|
|
46
|
+
# Delete a Deployment
|
47
|
+
#
|
48
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
49
|
+
# @param deployment_id [Integer, String, Repository, Hash] A GitHub repository
|
50
|
+
# @return [No Content]
|
51
|
+
# @see https://developer.github.com/v3/repos/deployments/#delete-a-deployment
|
52
|
+
def delete_deployment(repo, deployment_id, options = {})
|
53
|
+
delete("#{Repository.path repo}/deployments/#{deployment_id}", options)
|
54
|
+
end
|
55
|
+
|
46
56
|
# List all statuses for a Deployment
|
47
57
|
#
|
48
58
|
# @param deployment_url [String] A URL for a deployment resource
|
@@ -62,7 +62,7 @@ module Octokit
|
|
62
62
|
#
|
63
63
|
# Applications can revoke (delete) a token
|
64
64
|
#
|
65
|
-
# @param
|
65
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
66
66
|
#
|
67
67
|
# @return [Boolean] Result
|
68
68
|
# @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
|
@@ -93,7 +93,7 @@ module Octokit
|
|
93
93
|
#
|
94
94
|
# OAuth application owners can revoke a grant for their OAuth application and a specific user.
|
95
95
|
#
|
96
|
-
# @param
|
96
|
+
# @param access_token [String] 40 character GitHub OAuth access token
|
97
97
|
#
|
98
98
|
# @return [Boolean] Result
|
99
99
|
# @see https://developer.github.com/v3/apps/oauth_applications/#delete-an-app-token
|
@@ -236,7 +236,7 @@ module Octokit
|
|
236
236
|
# @example
|
237
237
|
# @client.outside_collaborators('github')
|
238
238
|
def outside_collaborators(org, options={})
|
239
|
-
|
239
|
+
paginate "#{Organization.path org}/outside_collaborators", options
|
240
240
|
end
|
241
241
|
|
242
242
|
# Remove outside collaborator from an organization
|
@@ -690,7 +690,7 @@ module Octokit
|
|
690
690
|
|
691
691
|
# Edit an organization membership
|
692
692
|
#
|
693
|
-
# @param org [String] Organization GitHub login.
|
693
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
694
694
|
# @option options [String] :role The role of the user in the organization.
|
695
695
|
# @option options [String] :state The state that the membership should be in.
|
696
696
|
# @option options [String] :user The login of the user, otherwise authenticated user.
|
@@ -701,7 +701,7 @@ module Octokit
|
|
701
701
|
options = options.dup
|
702
702
|
if user = options.delete(:user)
|
703
703
|
options.delete(:state)
|
704
|
-
put "
|
704
|
+
put "#{Organization.path(org)}/memberships/#{user}", options
|
705
705
|
else
|
706
706
|
options.delete(:role)
|
707
707
|
patch "user/memberships/orgs/#{org}", options
|
@@ -711,13 +711,13 @@ module Octokit
|
|
711
711
|
|
712
712
|
# Remove an organization membership
|
713
713
|
#
|
714
|
-
# @param org [String] Organization GitHub login.
|
714
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
715
715
|
# @return [Boolean] Success
|
716
716
|
# @see https://developer.github.com/v3/orgs/members/#remove-organization-membership
|
717
717
|
def remove_organization_membership(org, options = {})
|
718
718
|
options = options.dup
|
719
719
|
user = options.delete(:user)
|
720
|
-
user && boolean_from_response(:delete, "
|
720
|
+
user && boolean_from_response(:delete, "#{Organization.path(org)}/memberships/#{user}", options)
|
721
721
|
end
|
722
722
|
alias :remove_org_membership :remove_organization_membership
|
723
723
|
|
@@ -735,7 +735,7 @@ module Octokit
|
|
735
735
|
def start_migration(org, repositories, options = {})
|
736
736
|
options = ensure_api_media_type(:migrations, options)
|
737
737
|
options[:repositories] = repositories
|
738
|
-
post "
|
738
|
+
post "#{Organization.path(org)}/migrations", options
|
739
739
|
end
|
740
740
|
|
741
741
|
# Lists the most recent migrations.
|
@@ -747,7 +747,7 @@ module Octokit
|
|
747
747
|
# @see https://developer.github.com/v3/orgs/migrations/#get-a-list-of-migrations
|
748
748
|
def migrations(org, options = {})
|
749
749
|
options = ensure_api_media_type(:migrations, options)
|
750
|
-
paginate "
|
750
|
+
paginate "#{Organization.path(org)}/migrations", options
|
751
751
|
end
|
752
752
|
|
753
753
|
# Fetches the status of a migration.
|
@@ -759,7 +759,7 @@ module Octokit
|
|
759
759
|
# @see https://developer.github.com/v3/orgs/migrations/#get-the-status-of-a-migration
|
760
760
|
def migration_status(org, id, options = {})
|
761
761
|
options = ensure_api_media_type(:migrations, options)
|
762
|
-
get "
|
762
|
+
get "#{Organization.path(org)}/migrations/#{id}", options
|
763
763
|
end
|
764
764
|
|
765
765
|
# Fetches the URL to a migration archive.
|
@@ -771,7 +771,7 @@ module Octokit
|
|
771
771
|
# @see https://developer.github.com/v3/orgs/migrations/#download-a-migration-archive
|
772
772
|
def migration_archive_url(org, id, options = {})
|
773
773
|
options = ensure_api_media_type(:migrations, options)
|
774
|
-
url = "
|
774
|
+
url = "#{Organization.path(org)}/migrations/#{id}/archive"
|
775
775
|
|
776
776
|
response = client_without_redirects(options).get(url)
|
777
777
|
response.headers['location']
|
@@ -786,7 +786,7 @@ module Octokit
|
|
786
786
|
# @see https://developer.github.com/v3/orgs/migrations/#delete-a-migration-archive
|
787
787
|
def delete_migration_archive(org, id, options = {})
|
788
788
|
options = ensure_api_media_type(:migrations, options)
|
789
|
-
delete "
|
789
|
+
delete "#{Organization.path(org)}/migrations/#{id}/archive", options
|
790
790
|
end
|
791
791
|
|
792
792
|
# Unlock a previous migration archive.
|
@@ -799,7 +799,21 @@ module Octokit
|
|
799
799
|
# @see https://developer.github.com/v3/orgs/migrations/#unlock-a-repository
|
800
800
|
def unlock_repository(org, id, repo, options = {})
|
801
801
|
options = ensure_api_media_type(:migrations, options)
|
802
|
-
delete "
|
802
|
+
delete "#{Organization.path(org)}/migrations/#{id}/repos/#{repo}/lock", options
|
803
|
+
end
|
804
|
+
|
805
|
+
# Get GitHub Actions billing for an organization
|
806
|
+
#
|
807
|
+
# Requires authenticated organization owner.
|
808
|
+
#
|
809
|
+
# @param org [String, Integer] Organization GitHub login or id.
|
810
|
+
# @return [Sawyer::Resource] Hash representing GitHub Actions billing for an organization.
|
811
|
+
# @see https://docs.github.com/en/rest/reference/billing#get-github-actions-billing-for-an-organization
|
812
|
+
#
|
813
|
+
# @example
|
814
|
+
# @client.billing_actions('github')
|
815
|
+
def billing_actions(org)
|
816
|
+
get "#{Organization.path(org)}/settings/billing/actions"
|
803
817
|
end
|
804
818
|
end
|
805
819
|
end
|
data/lib/octokit/client/refs.rb
CHANGED
@@ -23,6 +23,18 @@ module Octokit
|
|
23
23
|
alias :references :refs
|
24
24
|
alias :list_references :refs
|
25
25
|
|
26
|
+
# Fetch matching refs
|
27
|
+
#
|
28
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
29
|
+
# @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt> or <tt>heads/rails-3</tt>
|
30
|
+
# @return [Array<Sawyer::Resource>] The reference matching the given repo and the ref id
|
31
|
+
# @see https://developer.github.com/v3/git/refs/#list-matching-references
|
32
|
+
# @example Fetch refs matching tags/v2 for sferik/rails_admin
|
33
|
+
# Octokit.ref("sferik/rails_admin","tags/v2")
|
34
|
+
def matching_refs(repo, ref, options = {})
|
35
|
+
paginate "#{Repository.path repo}/git/matching-refs/#{ref}", options
|
36
|
+
end
|
37
|
+
|
26
38
|
# Fetch a given reference
|
27
39
|
#
|
28
40
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -32,7 +32,7 @@ module Octokit
|
|
32
32
|
|
33
33
|
# Edit a repository
|
34
34
|
#
|
35
|
-
# @see https://developer.github.com/v3/repos/#
|
35
|
+
# @see https://developer.github.com/v3/repos/#update-a-repository
|
36
36
|
# @param repo [String, Hash, Repository] A GitHub repository
|
37
37
|
# @param options [Hash] Repository information to update
|
38
38
|
# @option options [String] :name Name of the repo
|
@@ -429,7 +429,7 @@ module Octokit
|
|
429
429
|
# @example List topics for octokit/octokit.rb
|
430
430
|
# Octokit.topics('octokit/octokit.rb')
|
431
431
|
# @example List topics for octokit/octokit.rb
|
432
|
-
# client.topics('octokit/octokit.rb')
|
432
|
+
# client.topics('octokit/octokit.rb')
|
433
433
|
def topics(repo, options = {})
|
434
434
|
opts = ensure_api_media_type(:topics, options)
|
435
435
|
paginate "#{Repository.path repo}/topics", opts
|
@@ -586,14 +586,14 @@ module Octokit
|
|
586
586
|
#
|
587
587
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
588
588
|
# @param branch [String] Branch name
|
589
|
-
# @option options [Hash] :required_status_checks If not null, the following keys are required:
|
590
|
-
# <tt>:enforce_admins [boolean] Enforce required status checks for repository administrators.</tt>
|
591
|
-
# <tt>:strict [boolean] Require branches to be up to date before merging.</tt>
|
592
|
-
# <tt>:contexts [Array] The list of status checks to require in order to merge into this branch</tt>
|
589
|
+
# @option options [Hash] :required_status_checks If not null, the following keys are required:
|
590
|
+
# <tt>:enforce_admins [boolean] Enforce required status checks for repository administrators.</tt>
|
591
|
+
# <tt>:strict [boolean] Require branches to be up to date before merging.</tt>
|
592
|
+
# <tt>:contexts [Array] The list of status checks to require in order to merge into this branch</tt>
|
593
593
|
#
|
594
594
|
# @option options [Hash] :restrictions If not null, the following keys are required:
|
595
|
-
# <tt>:users [Array] The list of user logins with push access</tt>
|
596
|
-
# <tt>:teams [Array] The list of team slugs with push access</tt>.
|
595
|
+
# <tt>:users [Array] The list of user logins with push access</tt>
|
596
|
+
# <tt>:teams [Array] The list of team slugs with push access</tt>.
|
597
597
|
#
|
598
598
|
# Teams and users restrictions are only available for organization-owned repositories.
|
599
599
|
# @return [Sawyer::Resource] The protected branch
|
@@ -640,6 +640,24 @@ module Octokit
|
|
640
640
|
boolean_from_response :delete, "#{Repository.path repo}/branches/#{branch}/protection", opts
|
641
641
|
end
|
642
642
|
|
643
|
+
# Rename a single branch from a repository
|
644
|
+
#
|
645
|
+
# Requires authenticated client
|
646
|
+
#
|
647
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
648
|
+
# @param branch [String] Current branch name
|
649
|
+
# @param new_name [String] New branch name
|
650
|
+
# @return [Sawyer::Resource] The renamed branch
|
651
|
+
# @see https://developer.github.com/v3/repos/#rename-a-branch
|
652
|
+
# @example
|
653
|
+
# @client.rename_branch('octokit/octokit.rb', 'master', 'main')
|
654
|
+
def rename_branch(repo, branch, new_name, options = {})
|
655
|
+
params = {
|
656
|
+
new_name: new_name,
|
657
|
+
}
|
658
|
+
post "#{Repository.path repo}/branches/#{branch}/rename", params.merge(options)
|
659
|
+
end
|
660
|
+
|
643
661
|
# List users available for assigning to issues.
|
644
662
|
#
|
645
663
|
# Requires authenticated client for private repos.
|
@@ -720,6 +738,62 @@ module Octokit
|
|
720
738
|
def delete_subscription(repo, options = {})
|
721
739
|
boolean_from_response :delete, "#{Repository.path repo}/subscription", options
|
722
740
|
end
|
741
|
+
|
742
|
+
# Create a repository dispatch event
|
743
|
+
#
|
744
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
745
|
+
# @param event_type [String] A custom webhook event name.
|
746
|
+
# @option options [Hash] :client_payload payload with extra information
|
747
|
+
# about the webhook event that your action or worklow may use.
|
748
|
+
#
|
749
|
+
# @return [Boolean] True if event was dispatched, false otherwise.
|
750
|
+
# @see https://developer.github.com/v3/repos/#create-a-repository-dispatch-event
|
751
|
+
def dispatch_event(repo, event_type, options = {})
|
752
|
+
boolean_from_response :post, "#{Repository.path repo}/dispatches", options.merge({ event_type: event_type })
|
753
|
+
end
|
754
|
+
|
755
|
+
# Check to see if vulnerability alerts are enabled for a repository
|
756
|
+
#
|
757
|
+
# The authenticated user must have admin access to the repository.
|
758
|
+
#
|
759
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
760
|
+
# @return [Boolean] True if vulnerability alerts are enabled, false otherwise.
|
761
|
+
# @see https://docs.github.com/en/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository
|
762
|
+
#
|
763
|
+
# @example
|
764
|
+
# @client.vulnerability_alerts_enabled?("octokit/octokit.rb")
|
765
|
+
def vulnerability_alerts_enabled?(repo, options = {})
|
766
|
+
opts = ensure_api_media_type(:vulnerability_alerts, options)
|
767
|
+
boolean_from_response(:get, "#{Repository.path repo}/vulnerability-alerts", opts)
|
768
|
+
end
|
769
|
+
|
770
|
+
# Enable vulnerability alerts for a repository
|
771
|
+
#
|
772
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
773
|
+
# @param options [Hash]
|
774
|
+
#
|
775
|
+
# @return [Boolean] True if vulnerability alerts enabled, false otherwise.
|
776
|
+
# @see https://docs.github.com/en/rest/reference/repos#enable-vulnerability-alerts
|
777
|
+
# @example Enable vulnerability alerts for a repository
|
778
|
+
# @client.enable_vulnerability_alerts("octokit/octokit.rb")
|
779
|
+
def enable_vulnerability_alerts(repo, options = {})
|
780
|
+
opts = ensure_api_media_type(:vulnerability_alerts, options)
|
781
|
+
boolean_from_response(:put, "#{Repository.path repo}/vulnerability-alerts", opts)
|
782
|
+
end
|
783
|
+
|
784
|
+
# Disable vulnerability alerts for a repository
|
785
|
+
#
|
786
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
787
|
+
# @param options [Hash]
|
788
|
+
#
|
789
|
+
# @return [Boolean] True if vulnerability alerts disabled, false otherwise.
|
790
|
+
# @see https://docs.github.com/en/rest/reference/repos#disable-vulnerability-alerts
|
791
|
+
# @example Disable vulnerability alerts for a repository
|
792
|
+
# @client.disable_vulnerability_alerts("octokit/octokit.rb")
|
793
|
+
def disable_vulnerability_alerts(repo, options = {})
|
794
|
+
opts = ensure_api_media_type(:vulnerability_alerts, options)
|
795
|
+
boolean_from_response(:delete, "#{Repository.path repo}/vulnerability-alerts", opts)
|
796
|
+
end
|
723
797
|
end
|
724
798
|
end
|
725
799
|
end
|
data/lib/octokit/client/users.rb
CHANGED
@@ -340,6 +340,92 @@ module Octokit
|
|
340
340
|
end
|
341
341
|
alias :watched :subscriptions
|
342
342
|
|
343
|
+
# Initiates the generation of a migration archive.
|
344
|
+
#
|
345
|
+
# Requires authenticated user.
|
346
|
+
#
|
347
|
+
# @param repositories [Array<String>] :repositories Repositories for the organization.
|
348
|
+
# @option options [Boolean, optional] :lock_repositories Indicates whether repositories should be locked during migration
|
349
|
+
# @option options [Boolean, optional] :exclude_attachments Exclude attachments fro the migration data
|
350
|
+
# @return [Sawyer::Resource] Hash representing the new migration.
|
351
|
+
# @example
|
352
|
+
# @client.start_migration(['octocat/hello-world'])
|
353
|
+
# @see https://docs.github.com/en/rest/reference/migrations#start-a-user-migration
|
354
|
+
def start_user_migration(repositories, options = {})
|
355
|
+
options = ensure_api_media_type(:migrations, options)
|
356
|
+
options[:repositories] = repositories
|
357
|
+
post "user/migrations", options
|
358
|
+
end
|
359
|
+
|
360
|
+
# Lists the most recent migrations.
|
361
|
+
#
|
362
|
+
# Requires authenticated user.
|
363
|
+
#
|
364
|
+
# @return [Array<Sawyer::Resource>] Array of migration resources.
|
365
|
+
# @see https://docs.github.com/en/rest/reference/migrations#list-user-migrations
|
366
|
+
def user_migrations(options = {})
|
367
|
+
options = ensure_api_media_type(:migrations, options)
|
368
|
+
paginate "user/migrations", options
|
369
|
+
end
|
370
|
+
|
371
|
+
# Fetches the status of a migration.
|
372
|
+
#
|
373
|
+
# Requires authenticated user.
|
374
|
+
#
|
375
|
+
# @param id [Integer] ID number of the migration.
|
376
|
+
# @see https://docs.github.com/en/rest/reference/migrations#get-a-user-migration-status
|
377
|
+
def user_migration_status(id, options = {})
|
378
|
+
options = ensure_api_media_type(:migrations, options)
|
379
|
+
get "user/migrations/#{id}", options
|
380
|
+
end
|
381
|
+
|
382
|
+
# Fetches the URL to a migration archive.
|
383
|
+
#
|
384
|
+
# Requires authenticated user.
|
385
|
+
#
|
386
|
+
# @param id [Integer] ID number of the migration.
|
387
|
+
# @see https://docs.github.com/en/rest/reference/migrations#download-a-user-migration-archive
|
388
|
+
def user_migration_archive_url(id, options = {})
|
389
|
+
options = ensure_api_media_type(:migrations, options)
|
390
|
+
url = "user/migrations/#{id}/archive"
|
391
|
+
|
392
|
+
response = client_without_redirects(options).get(url)
|
393
|
+
response.headers['location']
|
394
|
+
end
|
395
|
+
|
396
|
+
# Deletes a previous migration archive.
|
397
|
+
#
|
398
|
+
# Requires authenticated user.
|
399
|
+
#
|
400
|
+
# @param id [Integer] ID number of the migration.
|
401
|
+
# @see https://docs.github.com/en/rest/reference/migrations#delete-a-user-migration-archive
|
402
|
+
def delete_user_migration_archive(id, options = {})
|
403
|
+
options = ensure_api_media_type(:migrations, options)
|
404
|
+
delete "user/migrations/#{id}/archive", options
|
405
|
+
end
|
406
|
+
|
407
|
+
# List repositories for a user migration.
|
408
|
+
#
|
409
|
+
# Requires authenticated user.
|
410
|
+
#
|
411
|
+
# @param id [Integer] ID number of the migration.
|
412
|
+
# @see https://docs.github.com/en/rest/reference/migrations#list-repositories-for-a-user-migration
|
413
|
+
def user_migration_repositories(id, options = {})
|
414
|
+
options = ensure_api_media_type(:migrations, options)
|
415
|
+
get "user/migrations/#{id}/repositories", options
|
416
|
+
end
|
417
|
+
|
418
|
+
# Unlock a user repository which has been locked by a migration.
|
419
|
+
#
|
420
|
+
# Requires authenticated user.
|
421
|
+
#
|
422
|
+
# @param id [Integer] ID number of the migration.
|
423
|
+
# @param repo [String] Name of the repository.
|
424
|
+
# @see https://docs.github.com/en/rest/reference/migrations#unlock-a-user-repository
|
425
|
+
def unlock_user_repository(id, repo, options = {})
|
426
|
+
options = ensure_api_media_type(:migrations, options)
|
427
|
+
delete "user/migrations/#{id}/repos/#{repo}/lock", options
|
428
|
+
end
|
343
429
|
end
|
344
430
|
|
345
431
|
private
|
data/lib/octokit/connection.rb
CHANGED
@@ -155,6 +155,9 @@ module Octokit
|
|
155
155
|
|
156
156
|
@last_response = response = agent.call(method, Addressable::URI.parse(path.to_s).normalize.to_s, data, options)
|
157
157
|
response.data
|
158
|
+
rescue Octokit::Error => error
|
159
|
+
@last_response = nil
|
160
|
+
raise error
|
158
161
|
end
|
159
162
|
|
160
163
|
# Executes the request, checking if it was successful
|
@@ -162,7 +165,7 @@ module Octokit
|
|
162
165
|
# @return [Boolean] True on success, false otherwise
|
163
166
|
def boolean_from_response(method, path, options = {})
|
164
167
|
request(method, path, options)
|
165
|
-
@last_response.status
|
168
|
+
[201, 202, 204].include? @last_response.status
|
166
169
|
rescue Octokit::NotFound
|
167
170
|
false
|
168
171
|
end
|
@@ -177,12 +180,12 @@ module Octokit
|
|
177
180
|
conn_opts[:proxy] = @proxy if @proxy
|
178
181
|
if conn_opts[:ssl].nil?
|
179
182
|
conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode
|
180
|
-
else
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
183
|
+
else
|
184
|
+
verify = @connection_options[:ssl][:verify]
|
185
|
+
conn_opts[:ssl] = {
|
186
|
+
:verify => verify,
|
187
|
+
:verify_mode => verify == false ? 0 : @ssl_verify_mode
|
188
|
+
}
|
186
189
|
end
|
187
190
|
opts[:faraday] = Faraday.new(conn_opts)
|
188
191
|
|
data/lib/octokit/error.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Octokit
|
2
2
|
# Custom error class for rescuing from all GitHub errors
|
3
3
|
class Error < StandardError
|
4
|
-
|
4
|
+
attr_reader :context
|
5
5
|
# Returns the appropriate Octokit::Error subclass based
|
6
6
|
# on status and response message
|
7
7
|
#
|
@@ -21,7 +21,7 @@ module Octokit
|
|
21
21
|
when 406 then Octokit::NotAcceptable
|
22
22
|
when 409 then Octokit::Conflict
|
23
23
|
when 415 then Octokit::UnsupportedMediaType
|
24
|
-
when 422 then
|
24
|
+
when 422 then error_for_422(body)
|
25
25
|
when 451 then Octokit::UnavailableForLegalReasons
|
26
26
|
when 400..499 then Octokit::ClientError
|
27
27
|
when 500 then Octokit::InternalServerError
|
@@ -34,9 +34,16 @@ module Octokit
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def build_error_context
|
38
|
+
if RATE_LIMITED_ERRORS.include?(self.class)
|
39
|
+
@context = Octokit::RateLimit.from_response(@response)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
37
43
|
def initialize(response=nil)
|
38
44
|
@response = response
|
39
45
|
super(build_error_message)
|
46
|
+
build_error_context
|
40
47
|
end
|
41
48
|
|
42
49
|
# Documentation URL returned by the API for some errors
|
@@ -77,6 +84,8 @@ module Octokit
|
|
77
84
|
Octokit::BillingIssue
|
78
85
|
elsif body =~ /Resource protected by organization SAML enforcement/i
|
79
86
|
Octokit::SAMLProtected
|
87
|
+
elsif body =~ /suspended your access|This installation has been suspended/i
|
88
|
+
Octokit::InstallationSuspended
|
80
89
|
else
|
81
90
|
Octokit::Forbidden
|
82
91
|
end
|
@@ -92,6 +101,18 @@ module Octokit
|
|
92
101
|
end
|
93
102
|
end
|
94
103
|
|
104
|
+
# Return most appropriate error for 422 HTTP status code
|
105
|
+
# @private
|
106
|
+
def self.error_for_422(body)
|
107
|
+
if body =~ /PullRequestReviewComment/i && body =~ /(commit_id|end_commit_oid) is not part of the pull request/i
|
108
|
+
Octokit::CommitIsNotPartOfPullRequest
|
109
|
+
elsif body =~ /Path diff too large/i
|
110
|
+
Octokit::PathDiffTooLarge
|
111
|
+
else
|
112
|
+
Octokit::UnprocessableEntity
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
95
116
|
# Array of validation errors
|
96
117
|
# @return [Array<Hash>] Error info
|
97
118
|
def errors
|
@@ -265,6 +286,10 @@ module Octokit
|
|
265
286
|
# and body matches 'Resource protected by organization SAML enforcement'
|
266
287
|
class SAMLProtected < Forbidden; end
|
267
288
|
|
289
|
+
# Raised when GitHub returns a 403 HTTP status code
|
290
|
+
# and body matches 'suspended your access'
|
291
|
+
class InstallationSuspended < Forbidden; end
|
292
|
+
|
268
293
|
# Raised when GitHub returns a 404 HTTP status code
|
269
294
|
class NotFound < ClientError; end
|
270
295
|
|
@@ -287,6 +312,14 @@ module Octokit
|
|
287
312
|
# Raised when GitHub returns a 422 HTTP status code
|
288
313
|
class UnprocessableEntity < ClientError; end
|
289
314
|
|
315
|
+
# Raised when GitHub returns a 422 HTTP status code
|
316
|
+
# and body matches 'PullRequestReviewComment' and 'commit_id (or end_commit_oid) is not part of the pull request'
|
317
|
+
class CommitIsNotPartOfPullRequest < UnprocessableEntity; end
|
318
|
+
|
319
|
+
# Raised when GitHub returns a 422 HTTP status code and body matches 'Path diff too large'.
|
320
|
+
# It could occur when attempting to post review comments on a "too large" file.
|
321
|
+
class PathDiffTooLarge < UnprocessableEntity; end
|
322
|
+
|
290
323
|
# Raised when GitHub returns a 451 HTTP status code
|
291
324
|
class UnavailableForLegalReasons < ClientError; end
|
292
325
|
|
@@ -315,4 +348,5 @@ module Octokit
|
|
315
348
|
# Raised when a repository is created with an invalid format
|
316
349
|
class InvalidRepository < ArgumentError; end
|
317
350
|
|
351
|
+
RATE_LIMITED_ERRORS = [Octokit::TooManyRequests, Octokit::AbuseDetected]
|
318
352
|
end
|
data/lib/octokit/preview.rb
CHANGED
@@ -6,7 +6,6 @@ module Octokit
|
|
6
6
|
PREVIEW_TYPES = {
|
7
7
|
:applications_api => 'application/vnd.github.doctor-strange-preview+json'.freeze,
|
8
8
|
:branch_protection => 'application/vnd.github.luke-cage-preview+json'.freeze,
|
9
|
-
:checks => 'application/vnd.github.antiope-preview+json'.freeze,
|
10
9
|
:commit_search => 'application/vnd.github.cloak-preview+json'.freeze,
|
11
10
|
:commit_pulls => 'application/vnd.github.groot-preview+json'.freeze,
|
12
11
|
:commit_branches => 'application/vnd.github.groot-preview+json'.freeze,
|
@@ -20,14 +19,12 @@ module Octokit
|
|
20
19
|
:pages => 'application/vnd.github.mister-fantastic-preview+json'.freeze,
|
21
20
|
:projects => 'application/vnd.github.inertia-preview+json'.freeze,
|
22
21
|
:traffic => 'application/vnd.github.spiderman-preview'.freeze,
|
23
|
-
:integrations => 'application/vnd.github.machine-man-preview+json'.freeze,
|
24
22
|
:topics => 'application/vnd.github.mercy-preview+json'.freeze,
|
25
23
|
:community_profile => 'application/vnd.github.black-panther-preview+json'.freeze,
|
26
24
|
:strict_validation => 'application/vnd.github.speedy-preview+json'.freeze,
|
27
|
-
:drafts => 'application/vnd.github.shadow-cat-preview'.freeze,
|
28
25
|
:template_repositories => 'application/vnd.github.baptiste-preview+json'.freeze,
|
29
|
-
:uninstall_github_app => 'application/vnd.github.gambit-preview+json'.freeze,
|
30
26
|
:project_card_events => 'application/vnd.github.starfox-preview+json'.freeze,
|
27
|
+
:vulnerability_alerts => 'application/vnd.github.dorian-preview+json'.freeze,
|
31
28
|
}
|
32
29
|
|
33
30
|
def ensure_api_media_type(type, options)
|
data/lib/octokit/rate_limit.rb
CHANGED
@@ -20,7 +20,7 @@ module Octokit
|
|
20
20
|
# @return [RateLimit]
|
21
21
|
def self.from_response(response)
|
22
22
|
info = new
|
23
|
-
if response && !response.headers.nil?
|
23
|
+
if response && response.respond_to?(:headers) && !response.headers.nil?
|
24
24
|
info.limit = (response.headers['X-RateLimit-Limit'] || 1).to_i
|
25
25
|
info.remaining = (response.headers['X-RateLimit-Remaining'] || 1).to_i
|
26
26
|
info.resets_at = Time.at((response.headers['X-RateLimit-Reset'] || Time.now).to_i)
|
data/lib/octokit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-04-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -85,6 +85,9 @@ files:
|
|
85
85
|
- lib/octokit/arguments.rb
|
86
86
|
- lib/octokit/authentication.rb
|
87
87
|
- lib/octokit/client.rb
|
88
|
+
- lib/octokit/client/actions_secrets.rb
|
89
|
+
- lib/octokit/client/actions_workflow_runs.rb
|
90
|
+
- lib/octokit/client/actions_workflows.rb
|
88
91
|
- lib/octokit/client/apps.rb
|
89
92
|
- lib/octokit/client/authorizations.rb
|
90
93
|
- lib/octokit/client/checks.rb
|