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,222 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Apps API
|
6
|
+
module Apps
|
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
|
+
|
18
|
+
# Find all installations that belong to an App
|
19
|
+
#
|
20
|
+
# @param options [Hash] A customizable set of options
|
21
|
+
#
|
22
|
+
# @see https://developer.github.com/v3/apps/#list-installations
|
23
|
+
#
|
24
|
+
# @return [Array<Sawyer::Resource>] the total_count and an array of installations
|
25
|
+
def find_app_installations(options = {})
|
26
|
+
paginate 'app/installations', options
|
27
|
+
end
|
28
|
+
alias find_installations find_app_installations
|
29
|
+
|
30
|
+
def find_integration_installations(options = {})
|
31
|
+
octokit_warn(
|
32
|
+
'Deprecated: Octokit::Client::Apps#find_integration_installations ' \
|
33
|
+
'method is deprecated. Please update your call to use ' \
|
34
|
+
'Octokit::Client::Apps#find_app_installations before the next major ' \
|
35
|
+
'Octokit version update.'
|
36
|
+
)
|
37
|
+
find_app_installations(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Find all installations that are accessible to the authenticated user
|
41
|
+
#
|
42
|
+
# @param options [Hash] A customizable set of options
|
43
|
+
#
|
44
|
+
# @see https://developer.github.com/v3/apps/installations/#list-installations-for-a-user
|
45
|
+
#
|
46
|
+
# @return [Sawyer::Resource] the total_count and an array of installations
|
47
|
+
def find_user_installations(options = {})
|
48
|
+
paginate('user/installations', options) do |data, last_response|
|
49
|
+
data.installations.concat last_response.data.installations
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get a single installation
|
54
|
+
#
|
55
|
+
# @param id [Integer] Installation id
|
56
|
+
#
|
57
|
+
# @see https://developer.github.com/v3/apps/#get-an-installation
|
58
|
+
#
|
59
|
+
# @return [Sawyer::Resource] Installation information
|
60
|
+
def installation(id, options = {})
|
61
|
+
get "app/installations/#{id}", options
|
62
|
+
end
|
63
|
+
|
64
|
+
# Create a new installation token
|
65
|
+
#
|
66
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
67
|
+
# @param options [Hash] A customizable set of options
|
68
|
+
#
|
69
|
+
# @see https://developer.github.com/v3/apps/#create-a-new-installation-token
|
70
|
+
#
|
71
|
+
# @return [<Sawyer::Resource>] An installation token
|
72
|
+
def create_app_installation_access_token(installation, options = {})
|
73
|
+
post "app/installations/#{installation}/access_tokens", options
|
74
|
+
end
|
75
|
+
alias create_installation_access_token create_app_installation_access_token
|
76
|
+
|
77
|
+
def create_integration_installation_access_token(installation, options = {})
|
78
|
+
octokit_warn(
|
79
|
+
'Deprecated: Octokit::Client::Apps#create_integration_installation_access_token ' \
|
80
|
+
'method is deprecated. Please update your call to use ' \
|
81
|
+
'Octokit::Client::Apps#create_app_installation_access_token before the next major ' \
|
82
|
+
'Octokit version update.'
|
83
|
+
)
|
84
|
+
create_app_installation_access_token(installation, options)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Enables an app to find the organization's installation information.
|
88
|
+
#
|
89
|
+
# @param organization [String] Organization GitHub login
|
90
|
+
# @param options [Hash] A customizable set of options
|
91
|
+
#
|
92
|
+
# @see https://developer.github.com/v3/apps/#get-an-organization-installation
|
93
|
+
#
|
94
|
+
# @return [Sawyer::Resource] Installation information
|
95
|
+
def find_organization_installation(organization, options = {})
|
96
|
+
get "#{Organization.path(organization)}/installation", options
|
97
|
+
end
|
98
|
+
|
99
|
+
# Enables an app to find the repository's installation information.
|
100
|
+
#
|
101
|
+
# @param repo [String] A GitHub repository
|
102
|
+
# @param options [Hash] A customizable set of options
|
103
|
+
#
|
104
|
+
# @see https://developer.github.com/v3/apps/#get-a-repository-installation
|
105
|
+
#
|
106
|
+
# @return [Sawyer::Resource] Installation information
|
107
|
+
def find_repository_installation(repo, options = {})
|
108
|
+
get "#{Repository.path(repo)}/installation", options
|
109
|
+
end
|
110
|
+
|
111
|
+
# Enables an app to find the user's installation information.
|
112
|
+
#
|
113
|
+
# @param user [String] GitHub user login
|
114
|
+
# @param options [Hash] A customizable set of options
|
115
|
+
#
|
116
|
+
# @see https://developer.github.com/v3/apps/#get-a-user-installation
|
117
|
+
#
|
118
|
+
# @return [Sawyer::Resource] Installation information
|
119
|
+
def find_user_installation(user, options = {})
|
120
|
+
get "#{User.path(user)}/installation", options
|
121
|
+
end
|
122
|
+
|
123
|
+
# List repositories that are accessible to the authenticated installation
|
124
|
+
#
|
125
|
+
# @param options [Hash] A customizable set of options
|
126
|
+
#
|
127
|
+
# @see https://developer.github.com/v3/apps/installations/#list-repositories
|
128
|
+
#
|
129
|
+
# @return [Sawyer::Resource] the total_count and an array of repositories
|
130
|
+
def list_app_installation_repositories(options = {})
|
131
|
+
paginate('installation/repositories', options) do |data, last_response|
|
132
|
+
data.repositories.concat last_response.data.repositories
|
133
|
+
end
|
134
|
+
end
|
135
|
+
alias list_installation_repos list_app_installation_repositories
|
136
|
+
|
137
|
+
def list_integration_installation_repositories(options = {})
|
138
|
+
octokit_warn(
|
139
|
+
'Deprecated: Octokit::Client::Apps#list_integration_installation_repositories ' \
|
140
|
+
'method is deprecated. Please update your call to use ' \
|
141
|
+
'Octokit::Client::Apps#list_app_installation_repositories before the next major ' \
|
142
|
+
'Octokit version update.'
|
143
|
+
)
|
144
|
+
list_app_installation_repositories(options)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Add a single repository to an installation
|
148
|
+
#
|
149
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
150
|
+
# @param repo [Integer] The id of the GitHub repository
|
151
|
+
# @param options [Hash] A customizable set of options
|
152
|
+
#
|
153
|
+
# @see https://developer.github.com/v3/apps/installations/#add-repository-to-installation
|
154
|
+
#
|
155
|
+
# @return [Boolean] Success
|
156
|
+
def add_repository_to_app_installation(installation, repo, options = {})
|
157
|
+
boolean_from_response :put, "user/installations/#{installation}/repositories/#{repo}", options
|
158
|
+
end
|
159
|
+
alias add_repo_to_installation add_repository_to_app_installation
|
160
|
+
|
161
|
+
def add_repository_to_integration_installation(installation, repo, options = {})
|
162
|
+
octokit_warn(
|
163
|
+
'Deprecated: Octokit::Client::Apps#add_repository_to_integration_installation ' \
|
164
|
+
'method is deprecated. Please update your call to use ' \
|
165
|
+
'Octokit::Client::Apps#add_repository_to_app_installation before the next major ' \
|
166
|
+
'Octokit version update.'
|
167
|
+
)
|
168
|
+
add_repository_to_app_installation(installation, repo, options)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Remove a single repository to an installation
|
172
|
+
#
|
173
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
174
|
+
# @param repo [Integer] The id of the GitHub repository
|
175
|
+
# @param options [Hash] A customizable set of options
|
176
|
+
#
|
177
|
+
# @see https://developer.github.com/v3/apps/installations/#remove-repository-from-installation
|
178
|
+
#
|
179
|
+
# @return [Boolean] Success
|
180
|
+
def remove_repository_from_app_installation(installation, repo, options = {})
|
181
|
+
boolean_from_response :delete, "user/installations/#{installation}/repositories/#{repo}", options
|
182
|
+
end
|
183
|
+
alias remove_repo_from_installation remove_repository_from_app_installation
|
184
|
+
|
185
|
+
def remove_repository_from_integration_installation(installation, repo, options = {})
|
186
|
+
octokit_warn(
|
187
|
+
'Deprecated: Octokit::Client::Apps#remove_repository_from_integration_installation ' \
|
188
|
+
'method is deprecated. Please update your call to use ' \
|
189
|
+
'Octokit::Client::Apps#remove_repository_from_app_installation before the next major ' \
|
190
|
+
'Octokit version update.'
|
191
|
+
)
|
192
|
+
remove_repository_from_app_installation(installation, repo, options)
|
193
|
+
end
|
194
|
+
|
195
|
+
# List repositories accessible to the user for an installation
|
196
|
+
#
|
197
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
198
|
+
# @param options [Hash] A customizable set of options
|
199
|
+
#
|
200
|
+
# @see https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation
|
201
|
+
#
|
202
|
+
# @return [Sawyer::Resource] the total_count and an array of repositories
|
203
|
+
def find_installation_repositories_for_user(installation, options = {})
|
204
|
+
paginate("user/installations/#{installation}/repositories", options) do |data, last_response|
|
205
|
+
data.repositories.concat last_response.data.repositories
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Delete an installation and uninstall a GitHub App
|
210
|
+
#
|
211
|
+
# @param installation [Integer] The id of a GitHub App Installation
|
212
|
+
# @param options [Hash] A customizable set of options
|
213
|
+
#
|
214
|
+
# @see https://developer.github.com/v3/apps/#delete-an-installation
|
215
|
+
#
|
216
|
+
# @return [Boolean] Success
|
217
|
+
def delete_installation(installation, options = {})
|
218
|
+
boolean_from_response :delete, "app/installations/#{installation}", options
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Checks API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/checks/
|
8
|
+
module Checks
|
9
|
+
# Methods for Check Runs
|
10
|
+
#
|
11
|
+
# @see https://developer.github.com/v3/checks/runs/
|
12
|
+
|
13
|
+
# Create a check run
|
14
|
+
#
|
15
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
16
|
+
# @param name [String] The name of the check
|
17
|
+
# @param head_sha [String] The SHA of the commit to check
|
18
|
+
# @return [Sawyer::Resource] A hash representing the new check run
|
19
|
+
# @see https://developer.github.com/v3/checks/runs/#create-a-check-run
|
20
|
+
# @example Create a check run
|
21
|
+
# check_run = @client.create_check_run("octocat/Hello-World", "my-check", "7638417db6d59f3c431d3e1f261cc637155684cd")
|
22
|
+
# check_run.name # => "my-check"
|
23
|
+
# check_run.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
|
24
|
+
# check_run.status # => "queued"
|
25
|
+
def create_check_run(repo, name, head_sha, options = {})
|
26
|
+
options[:name] = name
|
27
|
+
options[:head_sha] = head_sha
|
28
|
+
|
29
|
+
post "#{Repository.path repo}/check-runs", options
|
30
|
+
end
|
31
|
+
|
32
|
+
# Update a check run
|
33
|
+
#
|
34
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
35
|
+
# @param id [Integer] The ID of the check run
|
36
|
+
# @return [Sawyer::Resource] A hash representing the updated check run
|
37
|
+
# @see https://developer.github.com/v3/checks/runs/#update-a-check-run
|
38
|
+
# @example Update a check run
|
39
|
+
# check_run = @client.update_check_run("octocat/Hello-World", 51295429, status: "in_progress")
|
40
|
+
# check_run.id # => 51295429
|
41
|
+
# check_run.status # => "in_progress"
|
42
|
+
def update_check_run(repo, id, options = {})
|
43
|
+
patch "#{Repository.path repo}/check-runs/#{id}", options
|
44
|
+
end
|
45
|
+
|
46
|
+
# List check runs for a specific ref
|
47
|
+
#
|
48
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
49
|
+
# @param ref [String] A SHA, branch name, or tag name
|
50
|
+
# @param options [Hash] A set of optional filters
|
51
|
+
# @option options [String] :check_name Returns check runs with the specified <tt>name</tt>
|
52
|
+
# @option options [String] :status Returns check runs with the specified <tt>status</tt>
|
53
|
+
# @option options [String] :filter Filters check runs by their <tt>completed_at</tt> timestamp
|
54
|
+
# @return [Sawyer::Resource] A hash representing a collection of check runs
|
55
|
+
# @see https://developer.github.com/v3/checks/runs/#list-check-runs-for-a-specific-ref
|
56
|
+
# @example List check runs for a specific ref
|
57
|
+
# result = @client.check_runs_for_ref("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd", status: "in_progress")
|
58
|
+
# result.total_count # => 1
|
59
|
+
# result.check_runs.count # => 1
|
60
|
+
# result.check_runs[0].id # => 51295429
|
61
|
+
# result.check_runs[0].status # => "in_progress"
|
62
|
+
def check_runs_for_ref(repo, ref, options = {})
|
63
|
+
paginate "#{Repository.path repo}/commits/#{ref}/check-runs", options do |data, last_response|
|
64
|
+
data.check_runs.concat last_response.data.check_runs
|
65
|
+
data.total_count += last_response.data.total_count
|
66
|
+
end
|
67
|
+
end
|
68
|
+
alias list_check_runs_for_ref check_runs_for_ref
|
69
|
+
|
70
|
+
# List check runs in a check suite
|
71
|
+
#
|
72
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
73
|
+
# @param id [Integer] The ID of the check suite
|
74
|
+
# @param options [Hash] A set of optional filters
|
75
|
+
# @option options [String] :check_name Returns check runs with the specified <tt>name</tt>
|
76
|
+
# @option options [String] :status Returns check runs with the specified <tt>status</tt>
|
77
|
+
# @option options [String] :filter Filters check runs by their <tt>completed_at</tt> timestamp
|
78
|
+
# @return [Sawyer::Resource] A hash representing a collection of check runs
|
79
|
+
# @see https://developer.github.com/v3/checks/runs/#list-check-runs-in-a-check-suite
|
80
|
+
# @example List check runs in a check suite
|
81
|
+
# result = @client.check_runs_for_check_suite("octocat/Hello-World", 50440400, status: "in_progress")
|
82
|
+
# result.total_count # => 1
|
83
|
+
# result.check_runs.count # => 1
|
84
|
+
# result.check_runs[0].check_suite.id # => 50440400
|
85
|
+
# result.check_runs[0].status # => "in_progress"
|
86
|
+
def check_runs_for_check_suite(repo, id, options = {})
|
87
|
+
paginate "#{Repository.path repo}/check-suites/#{id}/check-runs", options do |data, last_response|
|
88
|
+
data.check_runs.concat last_response.data.check_runs
|
89
|
+
data.total_count += last_response.data.total_count
|
90
|
+
end
|
91
|
+
end
|
92
|
+
alias list_check_runs_for_check_suite check_runs_for_check_suite
|
93
|
+
|
94
|
+
# Get a single check run
|
95
|
+
#
|
96
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
97
|
+
# @param id [Integer] The ID of the check run
|
98
|
+
# @return [Sawyer::Resource] A hash representing the check run
|
99
|
+
# @see https://developer.github.com/v3/checks/runs/#get-a-single-check-run
|
100
|
+
def check_run(repo, id, options = {})
|
101
|
+
get "#{Repository.path repo}/check-runs/#{id}", options
|
102
|
+
end
|
103
|
+
|
104
|
+
# List annotations for a check run
|
105
|
+
#
|
106
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
107
|
+
# @param id [Integer] The ID of the check run
|
108
|
+
# @return [Array<Sawyer::Resource>] An array of hashes representing check run annotations
|
109
|
+
# @see https://developer.github.com/v3/checks/runs/#list-annotations-for-a-check-run
|
110
|
+
# @example List annotations for a check run
|
111
|
+
# annotations = @client.check_run_annotations("octocat/Hello-World", 51295429)
|
112
|
+
# annotations.count # => 1
|
113
|
+
# annotations[0].path # => "README.md"
|
114
|
+
# annotations[0].message # => "Looks good!"
|
115
|
+
def check_run_annotations(repo, id, options = {})
|
116
|
+
paginate "#{Repository.path repo}/check-runs/#{id}/annotations", options
|
117
|
+
end
|
118
|
+
|
119
|
+
# Methods for Check Suites
|
120
|
+
#
|
121
|
+
# @see https://developer.github.com/v3/checks/suites/
|
122
|
+
|
123
|
+
# Get a single check suite
|
124
|
+
#
|
125
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
126
|
+
# @param id [Integer] The ID of the check suite
|
127
|
+
# @return [Sawyer::Resource] A hash representing the check suite
|
128
|
+
# @see https://developer.github.com/v3/checks/suites/#get-a-single-check-suite
|
129
|
+
def check_suite(repo, id, options = {})
|
130
|
+
get "#{Repository.path repo}/check-suites/#{id}", options
|
131
|
+
end
|
132
|
+
|
133
|
+
# List check suites for a specific ref
|
134
|
+
#
|
135
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
136
|
+
# @param ref [String] A SHA, branch name, or tag name
|
137
|
+
# @param options [Hash] A set of optional filters
|
138
|
+
# @option options [Integer] :app_id Filters check suites by GitHub App <tt>id</tt>
|
139
|
+
# @option options [String] :check_name Filters checks suites by the <tt>name</tt> of the check run
|
140
|
+
# @return [Sawyer::Resource] A hash representing a collection of check suites
|
141
|
+
# @see https://developer.github.com/v3/checks/suites/#list-check-suites-for-a-specific-ref
|
142
|
+
# @example List check suites for a specific ref
|
143
|
+
# result = @client.check_suites_for_ref("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd", app_id: 76765)
|
144
|
+
# result.total_count # => 1
|
145
|
+
# result.check_suites.count # => 1
|
146
|
+
# result.check_suites[0].id # => 50440400
|
147
|
+
# result.check_suites[0].app.id # => 76765
|
148
|
+
def check_suites_for_ref(repo, ref, options = {})
|
149
|
+
paginate "#{Repository.path repo}/commits/#{ref}/check-suites", options do |data, last_response|
|
150
|
+
data.check_suites.concat last_response.data.check_suites
|
151
|
+
data.total_count += last_response.data.total_count
|
152
|
+
end
|
153
|
+
end
|
154
|
+
alias list_check_suites_for_ref check_suites_for_ref
|
155
|
+
|
156
|
+
# Set preferences for check suites on a repository
|
157
|
+
#
|
158
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
159
|
+
# @param options [Hash] Preferences to set
|
160
|
+
# @return [Sawyer::Resource] A hash representing the repository's check suite preferences
|
161
|
+
# @see https://developer.github.com/v3/checks/suites/#set-preferences-for-check-suites-on-a-repository
|
162
|
+
# @example Set preferences for check suites on a repository
|
163
|
+
# result = @client.set_check_suite_preferences("octocat/Hello-World", auto_trigger_checks: [{ app_id: 76765, setting: false }])
|
164
|
+
# result.preferences.auto_trigger_checks.count # => 1
|
165
|
+
# result.preferences.auto_trigger_checks[0].app_id # => 76765
|
166
|
+
# result.preferences.auto_trigger_checks[0].setting # => false
|
167
|
+
# result.repository.full_name # => "octocat/Hello-World"
|
168
|
+
def set_check_suite_preferences(repo, options = {})
|
169
|
+
patch "#{Repository.path repo}/check-suites/preferences", options
|
170
|
+
end
|
171
|
+
|
172
|
+
# Create a check suite
|
173
|
+
#
|
174
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
175
|
+
# @param head_sha [String] The SHA of the commit to check
|
176
|
+
# @return [Sawyer::Resource] A hash representing the new check suite
|
177
|
+
# @see https://developer.github.com/v3/checks/suites/#create-a-check-suite
|
178
|
+
# @example Create a check suite
|
179
|
+
# check_suite = @client.create_check_suite("octocat/Hello-World", "7638417db6d59f3c431d3e1f261cc637155684cd")
|
180
|
+
# check_suite.head_sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
|
181
|
+
# check_suite.status # => "queued"
|
182
|
+
def create_check_suite(repo, head_sha, options = {})
|
183
|
+
options[:head_sha] = head_sha
|
184
|
+
|
185
|
+
post "#{Repository.path repo}/check-suites", options
|
186
|
+
end
|
187
|
+
|
188
|
+
# Rerequest check suite
|
189
|
+
#
|
190
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
191
|
+
# @param id [Integer] The ID of the check suite
|
192
|
+
# @return [Boolean] True if successful, raises an error otherwise
|
193
|
+
# @see https://developer.github.com/v3/checks/suites/#rerequest-check-suite
|
194
|
+
def rerequest_check_suite(repo, id, options = {})
|
195
|
+
post "#{Repository.path repo}/check-suites/#{id}/rerequest", options
|
196
|
+
true
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Branches for HEAD API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/repos/commits/
|
8
|
+
module CommitBranches
|
9
|
+
# List branches for a single HEAD commit
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @param sha [String] The SHA of the commit whose branches will be fetched
|
13
|
+
# @return [Array] List of branches
|
14
|
+
# @see https://developer.github.com/v3/repos/commits/#list-branches-for-head-commit
|
15
|
+
def commit_branches(repo, sha, options = {})
|
16
|
+
paginate "#{Repository.path repo}/commits/#{sha}/branches-where-head", options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Commit Comments API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/repos/comments/
|
7
8
|
module CommitComments
|
8
|
-
|
9
9
|
# List all commit comments
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -53,12 +53,12 @@ module Octokit
|
|
53
53
|
# comment.path # => "README.md"
|
54
54
|
# comment.line # => 10
|
55
55
|
# comment.position # => 1
|
56
|
-
def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, options = {})
|
56
|
+
def create_commit_comment(repo, sha, body, path = nil, line = nil, position = nil, options = {})
|
57
57
|
params = {
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
61
|
-
:
|
58
|
+
body: body,
|
59
|
+
path: path,
|
60
|
+
line: line,
|
61
|
+
position: position
|
62
62
|
}
|
63
63
|
post "#{Repository.path repo}/commits/#{sha}/comments", options.merge(params)
|
64
64
|
end
|
@@ -76,7 +76,7 @@ module Octokit
|
|
76
76
|
# comment.body # => "Updated commit comment"
|
77
77
|
def update_commit_comment(repo, id, body, options = {})
|
78
78
|
params = {
|
79
|
-
:
|
79
|
+
body: body
|
80
80
|
}
|
81
81
|
patch "#{Repository.path repo}/comments/#{id}", options.merge(params)
|
82
82
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Commit Pulls API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/repos/comments/
|
8
|
+
module CommitPulls
|
9
|
+
# List pulls for a single commit
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @param sha [String] The SHA of the commit whose pulls will be fetched
|
13
|
+
# @return [Array] List of commit pulls
|
14
|
+
# @see https://developer.github.com/v3/repos/commits/#list-pull-requests-associated-with-commit
|
15
|
+
def commit_pulls(repo, sha, options = {})
|
16
|
+
paginate "#{Repository.path repo}/commits/#{sha}/pulls", options
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'date'
|
2
4
|
|
3
5
|
module Octokit
|
4
6
|
class Client
|
5
|
-
|
6
7
|
# Methods for the Commits API
|
7
8
|
#
|
8
9
|
# @see https://developer.github.com/v3/repos/commits/
|
9
10
|
module Commits
|
10
|
-
|
11
11
|
# List commits
|
12
12
|
#
|
13
13
|
# @overload commits(repo, sha_or_branch, options = {})
|
@@ -23,12 +23,10 @@ module Octokit
|
|
23
23
|
def commits(*args)
|
24
24
|
arguments = Octokit::RepoArguments.new(args)
|
25
25
|
sha_or_branch = arguments.pop
|
26
|
-
if sha_or_branch
|
27
|
-
arguments.options[:sha] = sha_or_branch
|
28
|
-
end
|
26
|
+
arguments.options[:sha] = sha_or_branch if sha_or_branch
|
29
27
|
paginate "#{Repository.new(arguments.repo).path}/commits", arguments.options
|
30
28
|
end
|
31
|
-
alias
|
29
|
+
alias list_commits commits
|
32
30
|
|
33
31
|
# Get commits after a specified date
|
34
32
|
#
|
@@ -48,13 +46,11 @@ module Octokit
|
|
48
46
|
# Octokit.commits_since('octokit/octokit.rb', '2012-10-01')
|
49
47
|
def commits_since(*args)
|
50
48
|
arguments = Octokit::RepoArguments.new(args)
|
51
|
-
date
|
49
|
+
date = parse_date(arguments.shift)
|
52
50
|
params = arguments.options
|
53
|
-
params.merge!(:
|
51
|
+
params.merge!(since: iso8601(date))
|
54
52
|
sha_or_branch = arguments.pop
|
55
|
-
if sha_or_branch
|
56
|
-
params[:sha] = sha_or_branch
|
57
|
-
end
|
53
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
58
54
|
commits(arguments.repo, params)
|
59
55
|
end
|
60
56
|
|
@@ -74,13 +70,11 @@ module Octokit
|
|
74
70
|
# Octokit.commits_before('octokit/octokit.rb', '2012-10-01')
|
75
71
|
def commits_before(*args)
|
76
72
|
arguments = Octokit::RepoArguments.new(args)
|
77
|
-
date
|
73
|
+
date = parse_date(arguments.shift)
|
78
74
|
params = arguments.options
|
79
|
-
params.merge!(:
|
75
|
+
params.merge!(until: iso8601(date))
|
80
76
|
sha_or_branch = arguments.pop
|
81
|
-
if sha_or_branch
|
82
|
-
params[:sha] = sha_or_branch
|
83
|
-
end
|
77
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
84
78
|
commits(arguments.repo, params)
|
85
79
|
end
|
86
80
|
|
@@ -100,14 +94,12 @@ module Octokit
|
|
100
94
|
# Octokit.commits_on('octokit/octokit.rb', '2012-10-01')
|
101
95
|
def commits_on(*args)
|
102
96
|
arguments = Octokit::RepoArguments.new(args)
|
103
|
-
date
|
97
|
+
date = parse_date(arguments.shift)
|
104
98
|
params = arguments.options
|
105
99
|
end_date = date + 1
|
106
|
-
params.merge!(:
|
100
|
+
params.merge!(since: iso8601(date), until: iso8601(end_date))
|
107
101
|
sha_or_branch = arguments.pop
|
108
|
-
if sha_or_branch
|
109
|
-
params[:sha] = sha_or_branch
|
110
|
-
end
|
102
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
111
103
|
commits(arguments.repo, params)
|
112
104
|
end
|
113
105
|
|
@@ -129,16 +121,16 @@ module Octokit
|
|
129
121
|
# Octokit.commits_between('octokit/octokit.rb', '2012-10-01', '2012-11-01')
|
130
122
|
def commits_between(*args)
|
131
123
|
arguments = Octokit::RepoArguments.new(args)
|
132
|
-
date
|
133
|
-
end_date
|
134
|
-
|
124
|
+
date = parse_date(arguments.shift)
|
125
|
+
end_date = parse_date(arguments.shift)
|
126
|
+
if date > end_date
|
127
|
+
raise ArgumentError, "Start date #{date} does not precede #{end_date}"
|
128
|
+
end
|
135
129
|
|
136
130
|
params = arguments.options
|
137
|
-
params.merge!(:
|
131
|
+
params.merge!(since: iso8601(date), until: iso8601(end_date))
|
138
132
|
sha_or_branch = arguments.pop
|
139
|
-
if sha_or_branch
|
140
|
-
params[:sha] = sha_or_branch
|
141
|
-
end
|
133
|
+
params[:sha] = sha_or_branch if sha_or_branch
|
142
134
|
commits(arguments.repo, params)
|
143
135
|
end
|
144
136
|
|
@@ -181,21 +173,26 @@ module Octokit
|
|
181
173
|
# commit.tree.sha # => "827efc6d56897b048c772eb4087f854f46256132"
|
182
174
|
# commit.message # => "My commit message"
|
183
175
|
# commit.committer # => { "name" => "Wynn Netherland", "email" => "wynn@github.com", ... }
|
184
|
-
def create_commit(repo, message, tree, parents=nil, options = {})
|
185
|
-
params = { :
|
176
|
+
def create_commit(repo, message, tree, parents = nil, options = {})
|
177
|
+
params = { message: message, tree: tree }
|
186
178
|
params[:parents] = [parents].flatten if parents
|
187
179
|
post "#{Repository.path repo}/git/commits", options.merge(params)
|
188
180
|
end
|
189
181
|
|
190
182
|
# Compare two commits
|
191
183
|
#
|
184
|
+
# When using auto_pagination, commits from all pages will be concatenated
|
185
|
+
# into the <tt>commits</tt> attribute of the first page's response.
|
186
|
+
#
|
192
187
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
193
188
|
# @param start [String] The sha of the starting commit
|
194
189
|
# @param endd [String] The sha of the ending commit
|
195
190
|
# @return [Sawyer::Resource] A hash representing the comparison
|
196
191
|
# @see https://developer.github.com/v3/repos/commits/#compare-two-commits
|
197
192
|
def compare(repo, start, endd, options = {})
|
198
|
-
|
193
|
+
paginate "#{Repository.path repo}/compare/#{start}...#{endd}", options do |data, last_response|
|
194
|
+
data.commits.concat last_response.data.commits
|
195
|
+
end
|
199
196
|
end
|
200
197
|
|
201
198
|
# Merge a branch or sha
|
@@ -208,8 +205,8 @@ module Octokit
|
|
208
205
|
# @see https://developer.github.com/v3/repos/merging/#perform-a-merge
|
209
206
|
def merge(repo, base, head, options = {})
|
210
207
|
params = {
|
211
|
-
:
|
212
|
-
:
|
208
|
+
base: base,
|
209
|
+
head: head
|
213
210
|
}.merge(options)
|
214
211
|
post "#{Repository.path repo}/merges", params
|
215
212
|
end
|
@@ -220,7 +217,7 @@ module Octokit
|
|
220
217
|
if date.respond_to?(:iso8601)
|
221
218
|
date.iso8601
|
222
219
|
else
|
223
|
-
date.strftime(
|
220
|
+
date.strftime('%Y-%m-%dT%H:%M:%S%Z')
|
224
221
|
end
|
225
222
|
end
|
226
223
|
|