octokit 4.6.2 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +239 -118
- data/Rakefile +12 -12
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +59 -0
- data/lib/octokit/client/actions_workflow_jobs.rb +65 -0
- data/lib/octokit/client/actions_workflow_runs.rb +125 -0
- data/lib/octokit/client/actions_workflows.rb +68 -0
- data/lib/octokit/client/apps.rb +222 -0
- data/lib/octokit/client/checks.rb +200 -0
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/commits.rb +31 -34
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +25 -20
- data/lib/octokit/client/deployments.rb +25 -5
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/environments.rb +55 -0
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +7 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +9 -19
- data/lib/octokit/client/issues.rb +60 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +4 -7
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +56 -0
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +5 -5
- data/lib/octokit/client/notifications.rb +6 -10
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +238 -61
- data/lib/octokit/client/pages.rb +5 -7
- data/lib/octokit/client/projects.rb +50 -70
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +58 -46
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +6 -11
- data/lib/octokit/client/refs.rb +32 -19
- data/lib/octokit/client/releases.rb +14 -13
- data/lib/octokit/client/repositories.rb +195 -54
- data/lib/octokit/client/repository_invitations.rb +4 -11
- data/lib/octokit/client/reviews.rb +227 -0
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +46 -17
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +8 -13
- data/lib/octokit/client/stats.rb +12 -9
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +6 -11
- data/lib/octokit/client/users.rb +106 -25
- data/lib/octokit/client.rb +66 -17
- data/lib/octokit/configurable.rb +42 -30
- data/lib/octokit/connection.rb +43 -21
- data/lib/octokit/default.rb +63 -34
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +14 -15
- data/lib/octokit/enterprise_admin_client/license.rb +4 -5
- data/lib/octokit/enterprise_admin_client/orgs.rb +5 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +17 -16
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +33 -33
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +107 -26
- data/lib/octokit/gist.rb +4 -5
- data/lib/octokit/middleware/follow_redirects.rb +17 -13
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +27 -25
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -9
- data/lib/octokit/response/raise_error.rb +4 -6
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +5 -3
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +15 -8
- data/octokit.gemspec +13 -10
- metadata +55 -22
- data/lib/octokit/client/authorizations.rb +0 -244
- data/lib/octokit/preview.rb +0 -35
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Community Profile API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/repos/community/
|
8
|
+
module CommunityProfile
|
9
|
+
# Get community profile metrics for a repository
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @return [Sawyer::Resource] Community profile metrics
|
13
|
+
# @see https://developer.github.com/v3/repos/community/#retrieve-community-profile-metrics
|
14
|
+
# @example Get community profile metrics for octokit/octokit.rb
|
15
|
+
# @client.community_profile('octokit/octokit.rb')
|
16
|
+
def community_profile(repo, options = {})
|
17
|
+
get "#{Repository.path repo}/community/profile", options
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'base64'
|
2
4
|
|
3
5
|
module Octokit
|
4
6
|
class Client
|
5
|
-
|
6
7
|
# Methods for the Repo Contents API
|
7
8
|
#
|
8
9
|
# @see https://developer.github.com/v3/repos/contents/
|
9
10
|
module Contents
|
10
|
-
|
11
11
|
# Receive the default Readme for a repository
|
12
12
|
#
|
13
13
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
@@ -16,7 +16,9 @@ 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
|
-
|
19
|
+
# @example Get the readme file for a particular branch of the repo
|
20
|
+
# Octokit.readme("octokit/octokit.rb", :query => {:ref => 'some-other-branch'})
|
21
|
+
def readme(repo, options = {})
|
20
22
|
get "#{Repository.path repo}/readme", options
|
21
23
|
end
|
22
24
|
|
@@ -29,12 +31,15 @@ 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')
|
32
|
-
|
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'})
|
36
|
+
def contents(repo, options = {})
|
37
|
+
options = options.dup
|
33
38
|
repo_path = options.delete :path
|
34
39
|
url = "#{Repository.path repo}/contents/#{repo_path}"
|
35
40
|
get url, options
|
36
41
|
end
|
37
|
-
alias
|
42
|
+
alias content contents
|
38
43
|
|
39
44
|
# Add content to a repository
|
40
45
|
#
|
@@ -54,6 +59,7 @@ module Octokit
|
|
54
59
|
# "File content",
|
55
60
|
# :branch => "my-new-feature")
|
56
61
|
def create_contents(*args)
|
62
|
+
args = args.map { |item| item&.dup }
|
57
63
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
58
64
|
repo = args.shift
|
59
65
|
path = args.shift
|
@@ -63,7 +69,7 @@ module Octokit
|
|
63
69
|
case file
|
64
70
|
when String
|
65
71
|
if File.exist?(file)
|
66
|
-
file = File.open(file,
|
72
|
+
file = File.open(file, 'r')
|
67
73
|
content = file.read
|
68
74
|
file.close
|
69
75
|
end
|
@@ -72,17 +78,16 @@ module Octokit
|
|
72
78
|
file.close
|
73
79
|
end
|
74
80
|
end
|
75
|
-
raise ArgumentError
|
76
|
-
|
77
|
-
|
78
|
-
Base64.encode64(content).delete("\n") # Ruby 1.9.2
|
81
|
+
raise ArgumentError, 'content or :file option required' if content.nil?
|
82
|
+
|
83
|
+
options[:content] = Base64.strict_encode64(content)
|
79
84
|
options[:message] = message
|
80
85
|
url = "#{Repository.path repo}/contents/#{path}"
|
81
86
|
put url, options
|
82
87
|
end
|
83
|
-
alias
|
84
|
-
alias
|
85
|
-
alias
|
88
|
+
alias create_content create_contents
|
89
|
+
alias add_content create_contents
|
90
|
+
alias add_contents create_contents
|
86
91
|
|
87
92
|
# Update content in a repository
|
88
93
|
#
|
@@ -110,10 +115,10 @@ module Octokit
|
|
110
115
|
message = args.shift
|
111
116
|
sha = args.shift
|
112
117
|
content = args.shift
|
113
|
-
options.merge!(:
|
118
|
+
options.merge!(sha: sha)
|
114
119
|
create_contents(repo, path, message, content, options)
|
115
120
|
end
|
116
|
-
alias
|
121
|
+
alias update_content update_contents
|
117
122
|
|
118
123
|
# Delete content in a repository
|
119
124
|
#
|
@@ -136,9 +141,9 @@ module Octokit
|
|
136
141
|
url = "#{Repository.path repo}/contents/#{path}"
|
137
142
|
delete url, options
|
138
143
|
end
|
139
|
-
alias
|
140
|
-
alias
|
141
|
-
alias
|
144
|
+
alias delete_content delete_contents
|
145
|
+
alias remove_content delete_contents
|
146
|
+
alias remove_contents delete_contents
|
142
147
|
|
143
148
|
# This method will provide a URL to download a tarball or zipball archive for a repository.
|
144
149
|
#
|
@@ -149,8 +154,8 @@ module Octokit
|
|
149
154
|
# @see https://developer.github.com/v3/repos/contents/#get-archive-link
|
150
155
|
# @example Get archive link for octokit/octokit.rb
|
151
156
|
# Octokit.archive_link("octokit/octokit.rb")
|
152
|
-
def archive_link(repo, options={})
|
153
|
-
repo_ref = options.delete
|
157
|
+
def archive_link(repo, options = {})
|
158
|
+
repo_ref = ERB::Util.url_encode(options.delete(:ref))
|
154
159
|
format = (options.delete :format) || 'tarball'
|
155
160
|
url = "#{Repository.path repo}/#{format}/#{repo_ref}"
|
156
161
|
|
@@ -1,10 +1,20 @@
|
|
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
|
9
|
+
# Fetch a single deployment for a repository
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
# @param deployment_id [Integer, String, Repository, Hash] A GitHub repository
|
13
|
+
# @return <Sawyer::Resource> A single deployment
|
14
|
+
# @see https://developer.github.com/v3/repos/deployments/#get-a-single-deployment
|
15
|
+
def deployment(repo, deployment_id, options = {})
|
16
|
+
get("#{Repository.path repo}/deployments/#{deployment_id}", options)
|
17
|
+
end
|
8
18
|
|
9
19
|
# List all deployments for a repository
|
10
20
|
#
|
@@ -14,7 +24,7 @@ module Octokit
|
|
14
24
|
def deployments(repo, options = {})
|
15
25
|
get("#{Repository.path repo}/deployments", options)
|
16
26
|
end
|
17
|
-
alias
|
27
|
+
alias list_deployments deployments
|
18
28
|
|
19
29
|
# Create a deployment for a ref
|
20
30
|
#
|
@@ -33,16 +43,26 @@ module Octokit
|
|
33
43
|
post("#{Repository.path repo}/deployments", options)
|
34
44
|
end
|
35
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
|
+
|
36
56
|
# List all statuses for a Deployment
|
37
57
|
#
|
38
58
|
# @param deployment_url [String] A URL for a deployment resource
|
39
59
|
# @return [Array<Sawyer::Resource>] A list of deployment statuses
|
40
60
|
# @see https://developer.github.com/v3/repos/deployments/#list-deployment-statuses
|
41
61
|
def deployment_statuses(deployment_url, options = {})
|
42
|
-
deployment = get(deployment_url, :
|
62
|
+
deployment = get(deployment_url, accept: options[:accept])
|
43
63
|
get(deployment.rels[:statuses].href, options)
|
44
64
|
end
|
45
|
-
alias
|
65
|
+
alias list_deployment_statuses deployment_statuses
|
46
66
|
|
47
67
|
# Create a deployment status for a Deployment
|
48
68
|
#
|
@@ -53,7 +73,7 @@ module Octokit
|
|
53
73
|
# @return [Sawyer::Resource] A deployment status
|
54
74
|
# @see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status
|
55
75
|
def create_deployment_status(deployment_url, state, options = {})
|
56
|
-
deployment = get(deployment_url, :
|
76
|
+
deployment = get(deployment_url, accept: options[:accept])
|
57
77
|
options[:state] = state.to_s.downcase
|
58
78
|
post(deployment.rels[:statuses].href, options)
|
59
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,55 @@
|
|
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
|
+
get("#{Repository.path repo}/environments", options)
|
28
|
+
end
|
29
|
+
alias list_environments environments
|
30
|
+
|
31
|
+
# Create or update an environment with protection rules, such as required reviewers
|
32
|
+
#
|
33
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
34
|
+
# @param environment_name [String] The name of the environment
|
35
|
+
# @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).
|
36
|
+
# @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.
|
37
|
+
# @option options [Object] :deployment_branch_policy The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.
|
38
|
+
# @return [Sawyer::Resource] An environment
|
39
|
+
# @see https://docs.github.com/en/rest/deployments/environments#create-or-update-an-environment
|
40
|
+
def create_or_update_environment(repo, environment_name, options = {})
|
41
|
+
put("#{Repository.path repo}/environments/#{environment_name}", options)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Delete an Environment
|
45
|
+
#
|
46
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
47
|
+
# @param environment_name [String] The name of the environment
|
48
|
+
# @return [No Content]
|
49
|
+
# @see https://docs.github.com/en/rest/deployments/environments#delete-an-environment
|
50
|
+
def delete_environment(repo, environment_name, options = {})
|
51
|
+
delete("#{Repository.path repo}/environments/#{environment_name}", options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
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
|
#
|
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
|
#
|
@@ -50,6 +50,7 @@ module Octokit
|
|
50
50
|
# @see https://developer.github.com/v3/gists/#get-a-single-gist
|
51
51
|
# @see https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
|
52
52
|
def gist(gist, options = {})
|
53
|
+
options = options.dup
|
53
54
|
if sha = options.delete(:sha)
|
54
55
|
get "gists/#{Gist.new(gist)}/#{sha}", options
|
55
56
|
else
|
@@ -195,7 +196,7 @@ module Octokit
|
|
195
196
|
# @example
|
196
197
|
# @client.create_gist_comment('3528645', 'This is very helpful.')
|
197
198
|
def create_gist_comment(gist_id, comment, options = {})
|
198
|
-
options.merge
|
199
|
+
options = options.merge({ body: comment })
|
199
200
|
post "gists/#{gist_id}/comments", options
|
200
201
|
end
|
201
202
|
|
@@ -211,7 +212,7 @@ module Octokit
|
|
211
212
|
# @example
|
212
213
|
# @client.update_gist_comment('208sdaz3', '3528645', ':heart:')
|
213
214
|
def update_gist_comment(gist_id, gist_comment_id, comment, options = {})
|
214
|
-
options.merge
|
215
|
+
options = options.merge({ body: comment })
|
215
216
|
patch "gists/#{gist_id}/comments/#{gist_comment_id}", options
|
216
217
|
end
|
217
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
|
#
|