octokit 4.22.0 → 9.2.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 +4 -4
- data/README.md +117 -95
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +10 -3
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +111 -8
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +23 -3
- data/lib/octokit/client/actions_workflows.rb +27 -2
- data/lib/octokit/client/apps.rb +63 -26
- data/lib/octokit/client/checks.rb +18 -9
- data/lib/octokit/client/code_scanning.rb +190 -0
- data/lib/octokit/client/codespaces_secrets.rb +108 -0
- data/lib/octokit/client/commit_branches.rb +2 -2
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +2 -2
- data/lib/octokit/client/commits.rb +25 -33
- data/lib/octokit/client/community_profile.rb +2 -3
- data/lib/octokit/client/contents.rb +19 -22
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +8 -8
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +58 -0
- data/lib/octokit/client/events.rb +4 -5
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +6 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +9 -19
- data/lib/octokit/client/issues.rb +14 -15
- data/lib/octokit/client/labels.rb +10 -10
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +3 -6
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +4 -4
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +5 -5
- data/lib/octokit/client/notifications.rb +6 -6
- data/lib/octokit/client/oauth_applications.rb +1 -7
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +100 -56
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +44 -64
- data/lib/octokit/client/pull_requests.rb +66 -45
- data/lib/octokit/client/rate_limit.rb +9 -11
- data/lib/octokit/client/reactions.rb +62 -16
- data/lib/octokit/client/refs.rb +14 -17
- data/lib/octokit/client/releases.rb +13 -13
- data/lib/octokit/client/repositories.rb +92 -69
- data/lib/octokit/client/repository_invitations.rb +3 -3
- data/lib/octokit/client/reviews.rb +8 -8
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +24 -10
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +7 -12
- data/lib/octokit/client/stats.rb +10 -9
- data/lib/octokit/client/statuses.rb +5 -5
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +54 -33
- data/lib/octokit/client.rb +42 -18
- data/lib/octokit/configurable.rb +51 -31
- data/lib/octokit/connection.rb +30 -21
- data/lib/octokit/default.rb +66 -35
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
- data/lib/octokit/enterprise_admin_client/license.rb +3 -4
- data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
- data/lib/octokit/enterprise_admin_client/users.rb +5 -4
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +51 -33
- data/lib/octokit/enterprise_management_console_client.rb +8 -2
- data/lib/octokit/error.rb +51 -34
- data/lib/octokit/gist.rb +3 -4
- data/lib/octokit/manage_ghes_client/manage_ghes.rb +178 -0
- data/lib/octokit/manage_ghes_client.rb +64 -0
- data/lib/octokit/middleware/follow_redirects.rb +13 -12
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +8 -6
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +32 -25
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -7
- data/lib/octokit/response/raise_error.rb +4 -4
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +4 -2
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -11
- metadata +19 -31
- data/lib/octokit/client/authorizations.rb +0 -182
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -46
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the dependabot Secrets API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/dependabot/
|
8
|
+
module DependabotSecrets
|
9
|
+
# Get public key for secrets encryption
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Hash] key_id and key
|
13
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets#get-a-repository-public-key
|
14
|
+
def get_dependabot_public_key(repo)
|
15
|
+
get "#{Repository.path repo}/dependabot/secrets/public-key"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get public key for secrets encryption
|
19
|
+
#
|
20
|
+
# @param org [String] A GitHub organization
|
21
|
+
# @return [Hash] key_id and key
|
22
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-public-key
|
23
|
+
def get_org_dependabot_public_key(org)
|
24
|
+
get "#{Organization.path org}/dependabot/secrets/public-key"
|
25
|
+
end
|
26
|
+
|
27
|
+
# List secrets
|
28
|
+
#
|
29
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
30
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
31
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#list-repository-secrets
|
32
|
+
def list_dependabot_secrets(repo)
|
33
|
+
paginate "#{Repository.path repo}/dependabot/secrets" do |data, last_response|
|
34
|
+
data.secrets.concat last_response.data.secrets
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# List org secrets
|
39
|
+
#
|
40
|
+
# @param org [String] A GitHub organization
|
41
|
+
# @return [Hash] total_count and list of secrets (each item is hash with name, created_at and updated_at)
|
42
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#list-organization-secrets
|
43
|
+
def list_org_dependabot_secrets(org)
|
44
|
+
paginate "#{Organization.path org}/dependabot/secrets" do |data, last_response|
|
45
|
+
data.secrets.concat last_response.data.secrets
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get a secret
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
52
|
+
# @param name [String] Name of secret
|
53
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
54
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#get-a-repository-secret
|
55
|
+
def get_dependabot_secret(repo, name)
|
56
|
+
get "#{Repository.path repo}/dependabot/secrets/#{name}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Get an org secret
|
60
|
+
#
|
61
|
+
# @param org [String] A GitHub organization
|
62
|
+
# @param name [String] Name of secret
|
63
|
+
# @return [Hash] name, created_at, updated_at, and visibility
|
64
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#get-an-organization-secret
|
65
|
+
def get_org_dependabot_secret(org, name)
|
66
|
+
get "#{Organization.path org}/dependabot/secrets/#{name}"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Create or update secrets
|
70
|
+
#
|
71
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
72
|
+
# @param name [String] Name of secret
|
73
|
+
# @param options [Hash] encrypted_value and key_id
|
74
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#create-or-update-a-repository-secret
|
75
|
+
def create_or_update_dependabot_secret(repo, name, options)
|
76
|
+
put "#{Repository.path repo}/dependabot/secrets/#{name}", options
|
77
|
+
end
|
78
|
+
|
79
|
+
# Create or update org secrets
|
80
|
+
#
|
81
|
+
# @param org [String] A GitHub organization
|
82
|
+
# @param name [String] Name of secret
|
83
|
+
# @param options [Hash] encrypted_value and key_id
|
84
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#create-or-update-an-organization-secret
|
85
|
+
def create_or_update_org_dependabot_secret(org, name, options)
|
86
|
+
put "#{Organization.path org}/dependabot/secrets/#{name}", options
|
87
|
+
end
|
88
|
+
|
89
|
+
# Delete a secret
|
90
|
+
#
|
91
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
92
|
+
# @param name [String] Name of secret
|
93
|
+
# @see https://docs.github.com/en/rest/dependabot/repository-secrets?apiVersion=2022-11-28#delete-a-repository-secret
|
94
|
+
def delete_dependabot_secret(repo, name)
|
95
|
+
boolean_from_response :delete, "#{Repository.path repo}/dependabot/secrets/#{name}"
|
96
|
+
end
|
97
|
+
|
98
|
+
# Delete an org secret
|
99
|
+
#
|
100
|
+
# @param org [String] A GitHub organization
|
101
|
+
# @param name [String] Name of secret
|
102
|
+
# @see https://docs.github.com/en/rest/dependabot/organization-secrets?apiVersion=2022-11-28#delete-an-organization-secret
|
103
|
+
def delete_org_dependabot_secret(org, name)
|
104
|
+
boolean_from_response :delete, "#{Organization.path org}/dependabot/secrets/#{name}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Deployments API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/commits/deployments/
|
7
8
|
module Deployments
|
8
|
-
|
9
9
|
# Fetch a single deployment for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -22,9 +22,9 @@ module Octokit
|
|
22
22
|
# @return [Array<Sawyer::Resource>] A list of deployments
|
23
23
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployments
|
24
24
|
def deployments(repo, options = {})
|
25
|
-
|
25
|
+
paginate("#{Repository.path repo}/deployments", options)
|
26
26
|
end
|
27
|
-
alias
|
27
|
+
alias list_deployments deployments
|
28
28
|
|
29
29
|
# Create a deployment for a ref
|
30
30
|
#
|
@@ -59,10 +59,10 @@ module Octokit
|
|
59
59
|
# @return [Array<Sawyer::Resource>] A list of deployment statuses
|
60
60
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
|
61
61
|
def deployment_statuses(deployment_url, options = {})
|
62
|
-
deployment = get(deployment_url, :
|
63
|
-
|
62
|
+
deployment = get(deployment_url, accept: options[:accept])
|
63
|
+
paginate(deployment.rels[:statuses].href, options)
|
64
64
|
end
|
65
|
-
alias
|
65
|
+
alias list_deployment_statuses deployment_statuses
|
66
66
|
|
67
67
|
# Create a deployment status for a Deployment
|
68
68
|
#
|
@@ -73,7 +73,7 @@ module Octokit
|
|
73
73
|
# @return [Sawyer::Resource] A deployment status
|
74
74
|
# @see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
|
75
75
|
def create_deployment_status(deployment_url, state, options = {})
|
76
|
-
deployment = get(deployment_url, :
|
76
|
+
deployment = get(deployment_url, accept: options[:accept])
|
77
77
|
options[:state] = state.to_s.downcase
|
78
78
|
post(deployment.rels[:statuses].href, options)
|
79
79
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Repo Downloads API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/downloads/
|
7
8
|
module Downloads
|
8
|
-
|
9
9
|
# List available downloads for a repository
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Repository, Hash] A Github Repository
|
@@ -14,10 +14,10 @@ module Octokit
|
|
14
14
|
# @see https://developer.github.com/v3/repos/downloads/#list-downloads-for-a-repository
|
15
15
|
# @example List all downloads for Github/Hubot
|
16
16
|
# Octokit.downloads("github/hubot")
|
17
|
-
def downloads(repo, options={})
|
17
|
+
def downloads(repo, options = {})
|
18
18
|
paginate "#{Repository.path repo}/downloads", options
|
19
19
|
end
|
20
|
-
alias
|
20
|
+
alias list_downloads downloads
|
21
21
|
|
22
22
|
# Get single download for a repository
|
23
23
|
#
|
@@ -28,7 +28,7 @@ module Octokit
|
|
28
28
|
# @see https://developer.github.com/v3/repos/downloads/#get-a-single-download
|
29
29
|
# @example Get the "Robawt" download from Github/Hubot
|
30
30
|
# Octokit.download("github/hubot")
|
31
|
-
def download(repo, id, options={})
|
31
|
+
def download(repo, id, options = {})
|
32
32
|
get "#{Repository.path repo}/downloads/#{id}", options
|
33
33
|
end
|
34
34
|
|
@@ -44,7 +44,6 @@ module Octokit
|
|
44
44
|
def delete_download(repo, id, options = {})
|
45
45
|
boolean_from_response :delete, "#{Repository.path repo}/downloads/#{id}", options
|
46
46
|
end
|
47
|
-
|
48
47
|
end
|
49
48
|
end
|
50
49
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Emojis API
|
5
6
|
module Emojis
|
6
|
-
|
7
7
|
# List all emojis used on GitHub
|
8
8
|
#
|
9
9
|
# @return [Sawyer::Resource] A list of all emojis on GitHub
|
@@ -11,7 +11,7 @@ module Octokit
|
|
11
11
|
# @example List all emojis
|
12
12
|
# Octokit.emojis
|
13
13
|
def emojis(options = {})
|
14
|
-
get
|
14
|
+
get 'emojis', options
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Environments API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/deployments/environments
|
8
|
+
module Environments
|
9
|
+
# Fetch a single environment for a repository
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
# @param environment_name [String] The name of the environment
|
13
|
+
# @return <Sawyer::Resource> A single environment
|
14
|
+
# @see https://docs.github.com/en/rest/deployments/environments#get-an-environment
|
15
|
+
def environment(repo, environment_name, options = {})
|
16
|
+
get("#{Repository.path repo}/environments/#{environment_name}", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Lists the environments for a repository
|
20
|
+
#
|
21
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
22
|
+
# @option options [Integer] :per_page The number of results per page (max 100). Default: 30
|
23
|
+
# @option options [Integer] :page Page number of the results to fetch. Default: 1
|
24
|
+
# @return [Sawyer::Resource] Total count of environments and list of environments
|
25
|
+
# @see https://docs.github.com/en/rest/deployments/environments#list-environments
|
26
|
+
def environments(repo, options = {})
|
27
|
+
paginate("#{Repository.path repo}/environments", options) do |data, last_response|
|
28
|
+
data.environments.concat last_response.data.environments
|
29
|
+
data.total_count += last_response.data.total_count
|
30
|
+
end
|
31
|
+
end
|
32
|
+
alias list_environments environments
|
33
|
+
|
34
|
+
# Create or update an environment with protection rules, such as required reviewers
|
35
|
+
#
|
36
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
37
|
+
# @param environment_name [String] The name of the environment
|
38
|
+
# @option options [Integer] :wait_timer The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days).
|
39
|
+
# @option options [Array] :reviewers The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers.
|
40
|
+
# @option options [Object] :deployment_branch_policy The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.
|
41
|
+
# @return [Sawyer::Resource] An environment
|
42
|
+
# @see https://docs.github.com/en/rest/deployments/environments#create-or-update-an-environment
|
43
|
+
def create_or_update_environment(repo, environment_name, options = {})
|
44
|
+
put("#{Repository.path repo}/environments/#{environment_name}", options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Delete an Environment
|
48
|
+
#
|
49
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
50
|
+
# @param environment_name [String] The name of the environment
|
51
|
+
# @return [No Content]
|
52
|
+
# @see https://docs.github.com/en/rest/deployments/environments#delete-an-environment
|
53
|
+
def delete_environment(repo, environment_name, options = {})
|
54
|
+
delete("#{Repository.path repo}/environments/#{environment_name}", options)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Method for the Events API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/activity/events/
|
7
8
|
# @see https://developer.github.com/v3/issues/events/
|
8
9
|
module Events
|
9
|
-
|
10
10
|
# List all public events for GitHub
|
11
11
|
#
|
12
12
|
# @return [Array<Sawyer::Resource>] A list of all public events from GitHub
|
@@ -14,7 +14,7 @@ module Octokit
|
|
14
14
|
# @example List all pubilc events
|
15
15
|
# Octokit.public_events
|
16
16
|
def public_events(options = {})
|
17
|
-
paginate
|
17
|
+
paginate 'events', options
|
18
18
|
end
|
19
19
|
|
20
20
|
# List all user events
|
@@ -119,7 +119,7 @@ module Octokit
|
|
119
119
|
def repository_issue_events(repo, options = {})
|
120
120
|
paginate "#{Repository.path repo}/issues/events", options
|
121
121
|
end
|
122
|
-
alias
|
122
|
+
alias repo_issue_events repository_issue_events
|
123
123
|
|
124
124
|
# List events for an Issue
|
125
125
|
#
|
@@ -131,7 +131,6 @@ module Octokit
|
|
131
131
|
# @example List all issues events for issue #38 on octokit/octokit.rb
|
132
132
|
# Octokit.issue_events("octokit/octokit.rb", 38)
|
133
133
|
def issue_events(repo, number, options = {})
|
134
|
-
options = ensure_api_media_type(:project_card_events, options)
|
135
134
|
paginate "#{Repository.path repo}/issues/#{number}/events", options
|
136
135
|
end
|
137
136
|
|
data/lib/octokit/client/feeds.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Feeds API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/activity/feeds/
|
7
8
|
module Feeds
|
8
|
-
|
9
9
|
# List Feeds
|
10
10
|
#
|
11
11
|
# The feeds returned depend on authentication, see the GitHub API docs
|
@@ -14,7 +14,7 @@ module Octokit
|
|
14
14
|
# @return [Array<Sawyer::Resource>] list of feeds
|
15
15
|
# @see https://developer.github.com/v3/activity/feeds/#list-feeds
|
16
16
|
def feeds
|
17
|
-
get
|
17
|
+
get 'feeds'
|
18
18
|
end
|
19
19
|
|
20
20
|
# Get a Feed by name
|
@@ -24,10 +24,9 @@ module Octokit
|
|
24
24
|
# parser.
|
25
25
|
def feed(name, options = {})
|
26
26
|
if rel = feeds._links[name]
|
27
|
-
get rel.href, :
|
27
|
+
get rel.href, accept: rel.type, options: options
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
31
30
|
end
|
32
31
|
end
|
33
32
|
end
|
data/lib/octokit/client/gists.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Gists API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/gists/
|
7
8
|
module Gists
|
8
|
-
|
9
9
|
# List gists for a user or all public gists
|
10
10
|
#
|
11
11
|
# @param user [String] An optional user to filter listing
|
@@ -15,14 +15,14 @@ module Octokit
|
|
15
15
|
# @example Fetch all public gists
|
16
16
|
# Octokit.gists
|
17
17
|
# @see https://developer.github.com/v3/gists/#list-gists
|
18
|
-
def gists(user=nil, options = {})
|
18
|
+
def gists(user = nil, options = {})
|
19
19
|
if user.nil?
|
20
20
|
paginate 'gists', options
|
21
21
|
else
|
22
22
|
paginate "#{User.path user}/gists", options
|
23
23
|
end
|
24
24
|
end
|
25
|
-
alias
|
25
|
+
alias list_gists gists
|
26
26
|
|
27
27
|
# List public gists
|
28
28
|
#
|
@@ -196,7 +196,7 @@ module Octokit
|
|
196
196
|
# @example
|
197
197
|
# @client.create_gist_comment('3528645', 'This is very helpful.')
|
198
198
|
def create_gist_comment(gist_id, comment, options = {})
|
199
|
-
options = options.merge({:
|
199
|
+
options = options.merge({ body: comment })
|
200
200
|
post "gists/#{gist_id}/comments", options
|
201
201
|
end
|
202
202
|
|
@@ -212,7 +212,7 @@ module Octokit
|
|
212
212
|
# @example
|
213
213
|
# @client.update_gist_comment('208sdaz3', '3528645', ':heart:')
|
214
214
|
def update_gist_comment(gist_id, gist_comment_id, comment, options = {})
|
215
|
-
options = options.merge({:
|
215
|
+
options = options.merge({ body: comment })
|
216
216
|
patch "gists/#{gist_id}/comments/#{gist_comment_id}", options
|
217
217
|
end
|
218
218
|
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Gitignore API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/gitignore/
|
7
8
|
module Gitignore
|
8
|
-
|
9
9
|
# Listing available gitignore templates.
|
10
10
|
#
|
11
11
|
# These templates can be passed option when creating a repository.
|
@@ -17,7 +17,7 @@ module Octokit
|
|
17
17
|
# @example Git all the gitignore templates
|
18
18
|
# @client.gitignore_templates
|
19
19
|
def gitignore_templates(options = {})
|
20
|
-
get
|
20
|
+
get 'gitignore/templates', options
|
21
21
|
end
|
22
22
|
|
23
23
|
# Get a gitignore template.
|
data/lib/octokit/client/hooks.rb
CHANGED
@@ -1,19 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Hooks API
|
5
6
|
module Hooks
|
6
|
-
|
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.
|
@@ -73,7 +63,7 @@ module Octokit
|
|
73
63
|
# }
|
74
64
|
# )
|
75
65
|
def create_hook(repo, name, config, options = {})
|
76
|
-
options = {:
|
66
|
+
options = { name: name, config: config, events: ['push'], active: true }.merge(options)
|
77
67
|
post "#{Repository.path repo}/hooks", options
|
78
68
|
end
|
79
69
|
|
@@ -116,7 +106,7 @@ module Octokit
|
|
116
106
|
# }
|
117
107
|
# )
|
118
108
|
def edit_hook(repo, id, name, config, options = {})
|
119
|
-
options = {:
|
109
|
+
options = { name: name, config: config }.merge(options)
|
120
110
|
patch "#{Repository.path repo}/hooks/#{id}", options
|
121
111
|
end
|
122
112
|
|
@@ -158,7 +148,7 @@ module Octokit
|
|
158
148
|
# @see https://developer.github.com/v3/repos/hooks/#ping-a-hook
|
159
149
|
# @example
|
160
150
|
# @client.ping_hook('octokit/octokit.rb', 1000000)
|
161
|
-
def ping_hook(repo, id, options={})
|
151
|
+
def ping_hook(repo, id, options = {})
|
162
152
|
boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/pings", options
|
163
153
|
end
|
164
154
|
|
@@ -174,7 +164,7 @@ module Octokit
|
|
174
164
|
def org_hooks(org, options = {})
|
175
165
|
paginate "#{Organization.path org}/hooks", options
|
176
166
|
end
|
177
|
-
alias
|
167
|
+
alias list_org_hooks org_hooks
|
178
168
|
|
179
169
|
# Get an org hook
|
180
170
|
#
|
@@ -217,7 +207,7 @@ module Octokit
|
|
217
207
|
# }
|
218
208
|
# )
|
219
209
|
def create_org_hook(org, config, options = {})
|
220
|
-
options = { :
|
210
|
+
options = { name: 'web', config: config }.merge(options)
|
221
211
|
post "#{Organization.path org}/hooks", options
|
222
212
|
end
|
223
213
|
|
@@ -250,10 +240,10 @@ module Octokit
|
|
250
240
|
# }
|
251
241
|
# )
|
252
242
|
def edit_org_hook(org, id, config, options = {})
|
253
|
-
options = { :
|
243
|
+
options = { config: config }.merge(options)
|
254
244
|
patch "#{Organization.path org}/hooks/#{id}", options
|
255
245
|
end
|
256
|
-
alias
|
246
|
+
alias update_org_hook edit_org_hook
|
257
247
|
|
258
248
|
# Ping org hook
|
259
249
|
#
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Issues API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/issues/
|
7
8
|
module Issues
|
8
|
-
|
9
9
|
# List issues for the authenticated user or repository
|
10
10
|
#
|
11
11
|
# @param repository [Integer, String, Repository, Hash] A GitHub repository.
|
@@ -28,10 +28,10 @@ module Octokit
|
|
28
28
|
# @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
|
29
29
|
# @client.list_issues
|
30
30
|
def list_issues(repository = nil, options = {})
|
31
|
-
path = repository ? "#{Repository.new(repository).path}/issues" :
|
31
|
+
path = repository ? "#{Repository.new(repository).path}/issues" : 'issues'
|
32
32
|
paginate path, options
|
33
33
|
end
|
34
|
-
alias
|
34
|
+
alias issues list_issues
|
35
35
|
|
36
36
|
# List all issues across owned and member repositories for the authenticated user
|
37
37
|
#
|
@@ -91,17 +91,17 @@ module Octokit
|
|
91
91
|
def create_issue(repo, title, body = nil, options = {})
|
92
92
|
options[:labels] = case options[:labels]
|
93
93
|
when String
|
94
|
-
options[:labels].split(
|
94
|
+
options[:labels].split(',').map(&:strip)
|
95
95
|
when Array
|
96
96
|
options[:labels]
|
97
97
|
else
|
98
98
|
[]
|
99
99
|
end
|
100
|
-
parameters = { :
|
100
|
+
parameters = { title: title }
|
101
101
|
parameters[:body] = body unless body.nil?
|
102
102
|
post "#{Repository.path repo}/issues", options.merge(parameters)
|
103
103
|
end
|
104
|
-
alias
|
104
|
+
alias open_issue create_issue
|
105
105
|
|
106
106
|
# Get a single issue from a repository
|
107
107
|
#
|
@@ -129,7 +129,7 @@ module Octokit
|
|
129
129
|
# @example Close Issue #25 from octokit/octokit.rb
|
130
130
|
# Octokit.close_issue("octokit/octokit.rb", "25")
|
131
131
|
def close_issue(repo, number, options = {})
|
132
|
-
patch "#{Repository.path repo}/issues/#{number}", options.merge({:
|
132
|
+
patch "#{Repository.path repo}/issues/#{number}", options.merge({ state: 'closed' })
|
133
133
|
end
|
134
134
|
|
135
135
|
# Reopen an issue
|
@@ -146,7 +146,7 @@ module Octokit
|
|
146
146
|
# @example Reopen Issue #25 from octokit/octokit.rb
|
147
147
|
# Octokit.reopen_issue("octokit/octokit.rb", "25")
|
148
148
|
def reopen_issue(repo, number, options = {})
|
149
|
-
patch "#{Repository.path repo}/issues/#{number}", options.merge({:
|
149
|
+
patch "#{Repository.path repo}/issues/#{number}", options.merge({ state: 'open' })
|
150
150
|
end
|
151
151
|
|
152
152
|
# Lock an issue's conversation, limiting it to collaborators
|
@@ -210,7 +210,7 @@ module Octokit
|
|
210
210
|
arguments = Arguments.new(args)
|
211
211
|
opts = arguments.options
|
212
212
|
|
213
|
-
|
213
|
+
unless arguments.empty?
|
214
214
|
opts[:title] = arguments.shift
|
215
215
|
opts[:body] = arguments.shift
|
216
216
|
end
|
@@ -281,7 +281,7 @@ module Octokit
|
|
281
281
|
# @example Add the comment "Almost to v1" to Issue #23 on octokit/octokit.rb
|
282
282
|
# Octokit.add_comment("octokit/octokit.rb", 23, "Almost to v1")
|
283
283
|
def add_comment(repo, number, comment, options = {})
|
284
|
-
post "#{Repository.path repo}/issues/#{number}/comments", options.merge({:
|
284
|
+
post "#{Repository.path repo}/issues/#{number}/comments", options.merge({ body: comment })
|
285
285
|
end
|
286
286
|
|
287
287
|
# Update a single comment on an issue
|
@@ -294,7 +294,7 @@ module Octokit
|
|
294
294
|
# @example Update the comment #1194549 with body "I've started this on my 25-issue-comments-v3 fork" on an issue on octokit/octokit.rb
|
295
295
|
# Octokit.update_comment("octokit/octokit.rb", 1194549, "Almost to v1, added this on my fork")
|
296
296
|
def update_comment(repo, number, comment, options = {})
|
297
|
-
patch "#{Repository.path repo}/issues/comments/#{number}", options.merge({:
|
297
|
+
patch "#{Repository.path repo}/issues/comments/#{number}", options.merge({ body: comment })
|
298
298
|
end
|
299
299
|
|
300
300
|
# Delete a single comment
|
@@ -318,7 +318,6 @@ module Octokit
|
|
318
318
|
# @example Get timeline for issue #1435 on octokit/octokit.rb
|
319
319
|
# Octokit.issue_timeline("octokit/octokit.rb", 1435)
|
320
320
|
def issue_timeline(repo, number, options = {})
|
321
|
-
options = ensure_api_media_type(:issue_timelines, options)
|
322
321
|
paginate "#{Repository.path repo}/issues/#{number}/timeline", options
|
323
322
|
end
|
324
323
|
|
@@ -343,7 +342,7 @@ module Octokit
|
|
343
342
|
# @example Add assignees "pengwynn" and "joeyw" to Issue #23 on octokit/octokit.rb
|
344
343
|
# Octokit.add_assignees("octokit/octokit.rb", 23, ["pengwynn", "joeyw"])
|
345
344
|
def add_assignees(repo, number, assignees, options = {})
|
346
|
-
post "#{Repository.path repo}/issues/#{number}/assignees", options.merge({:assignees
|
345
|
+
post "#{Repository.path repo}/issues/#{number}/assignees", options.merge({ assignees: assignees })
|
347
346
|
end
|
348
347
|
|
349
348
|
# Remove assignees from an issue
|
@@ -361,7 +360,7 @@ module Octokit
|
|
361
360
|
# Octokit.remove_assignees("octokit/octokit.rb", 23, ["pengwynn"],
|
362
361
|
# :accept => "application/vnd.github.v3+json")
|
363
362
|
def remove_assignees(repo, number, assignees, options = {})
|
364
|
-
delete "#{Repository.path repo}/issues/#{number}/assignees", options.merge({:assignees
|
363
|
+
delete "#{Repository.path repo}/issues/#{number}/assignees", options.merge({ assignees: assignees })
|
365
364
|
end
|
366
365
|
end
|
367
366
|
end
|