octokit 4.2.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 +5 -5
- data/CONTRIBUTING.md +14 -13
- data/LICENSE.md +1 -1
- data/README.md +275 -127
- data/Rakefile +20 -14
- data/lib/ext/sawyer/relation.rb +12 -0
- data/lib/octokit/arguments.rb +3 -3
- data/lib/octokit/authentication.rb +20 -14
- data/lib/octokit/client/actions_artifacts.rb +71 -0
- data/lib/octokit/client/actions_secrets.rb +161 -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 +259 -0
- data/lib/octokit/client/checks.rb +200 -0
- 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 +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 +32 -35
- data/lib/octokit/client/community_profile.rb +21 -0
- data/lib/octokit/client/contents.rb +24 -21
- data/lib/octokit/client/dependabot_secrets.rb +108 -0
- data/lib/octokit/client/deployments.rb +29 -7
- 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 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +36 -8
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +34 -30
- data/lib/octokit/client/issues.rb +97 -14
- data/lib/octokit/client/labels.rb +17 -17
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +5 -8
- 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 +14 -14
- data/lib/octokit/client/notifications.rb +7 -11
- data/lib/octokit/client/oauth_applications.rb +116 -0
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +256 -73
- data/lib/octokit/client/pages.rb +26 -3
- data/lib/octokit/client/projects.rb +294 -0
- data/lib/octokit/client/pull_requests.rb +74 -51
- data/lib/octokit/client/rate_limit.rb +11 -13
- data/lib/octokit/client/reactions.rb +204 -0
- data/lib/octokit/client/refs.rb +34 -20
- data/lib/octokit/client/releases.rb +16 -13
- data/lib/octokit/client/repositories.rb +276 -60
- data/lib/octokit/client/repository_invitations.rb +96 -0
- 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 +156 -0
- data/lib/octokit/client/stats.rb +39 -17
- data/lib/octokit/client/statuses.rb +6 -6
- data/lib/octokit/client/tokens.rb +31 -0
- data/lib/octokit/client/traffic.rb +64 -0
- data/lib/octokit/client/users.rb +133 -25
- data/lib/octokit/client.rb +85 -19
- data/lib/octokit/configurable.rb +60 -32
- data/lib/octokit/connection.rb +45 -21
- data/lib/octokit/default.rb +82 -35
- 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 +7 -6
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +8 -9
- data/lib/octokit/enterprise_admin_client/users.rb +19 -18
- data/lib/octokit/enterprise_admin_client.rb +11 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +52 -34
- data/lib/octokit/enterprise_management_console_client.rb +9 -3
- data/lib/octokit/error.rb +144 -26
- data/lib/octokit/gist.rb +4 -5
- 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 +18 -14
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/rate_limit.rb +11 -9
- data/lib/octokit/repo_arguments.rb +3 -4
- data/lib/octokit/repository.rb +35 -23
- 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 +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +30 -8
- data/octokit.gemspec +12 -10
- metadata +47 -24
- data/lib/octokit/client/authorizations.rb +0 -256
- data/lib/octokit/client/pub_sub_hubbub.rb +0 -111
- data/lib/octokit/preview.rb +0 -28
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Repository Invitations API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/repos/invitations/
|
8
|
+
module RepositoryInvitations
|
9
|
+
# Invite a user to a repository
|
10
|
+
#
|
11
|
+
# Requires authenticated client
|
12
|
+
#
|
13
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
14
|
+
# @param user [String] User GitHub username to add
|
15
|
+
# @return [Sawyer::Resource] The repository invitation
|
16
|
+
# @see https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator
|
17
|
+
def invite_user_to_repository(repo, user, options = {})
|
18
|
+
put "#{Repository.path repo}/collaborators/#{user}", options
|
19
|
+
end
|
20
|
+
alias invite_user_to_repo invite_user_to_repository
|
21
|
+
|
22
|
+
# List all invitations for a repository
|
23
|
+
#
|
24
|
+
# Requires authenticated client
|
25
|
+
#
|
26
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
27
|
+
# @return [Array<Sawyer::Resource>] A list of invitations
|
28
|
+
# @see https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository
|
29
|
+
def repository_invitations(repo, options = {})
|
30
|
+
paginate "#{Repository.path repo}/invitations", options
|
31
|
+
end
|
32
|
+
alias repo_invitations repository_invitations
|
33
|
+
|
34
|
+
# Delete an invitation for a repository
|
35
|
+
#
|
36
|
+
# Requires authenticated client
|
37
|
+
#
|
38
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
39
|
+
# @param invitation_id [Integer] The id of the invitation
|
40
|
+
# @return [Boolean] True if the invitation was successfully deleted
|
41
|
+
# @see https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation
|
42
|
+
def delete_repository_invitation(repo, invitation_id, options = {})
|
43
|
+
boolean_from_response :delete, "#{Repository.path repo}/invitations/#{invitation_id}", options
|
44
|
+
end
|
45
|
+
alias delete_repo_invitation delete_repository_invitation
|
46
|
+
|
47
|
+
# Update an invitation for a repository
|
48
|
+
#
|
49
|
+
# Requires authenticated client
|
50
|
+
#
|
51
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
52
|
+
# @param invitation_id [Integer] The id of the invitation
|
53
|
+
# @return [Sawyer::Resource] The updated repository invitation
|
54
|
+
# @see https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation
|
55
|
+
def update_repository_invitation(repo, invitation_id, options = {})
|
56
|
+
patch "#{Repository.path repo}/invitations/#{invitation_id}", options
|
57
|
+
end
|
58
|
+
alias update_repo_invitation update_repository_invitation
|
59
|
+
|
60
|
+
# List all repository invitations for the user
|
61
|
+
#
|
62
|
+
# Requires authenticated client
|
63
|
+
#
|
64
|
+
# @return [Array<Sawyer::Resource>] The users repository invitations
|
65
|
+
# @see https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations
|
66
|
+
def user_repository_invitations(options = {})
|
67
|
+
paginate '/user/repository_invitations', options
|
68
|
+
end
|
69
|
+
alias user_repo_invitations user_repository_invitations
|
70
|
+
|
71
|
+
# Accept a repository invitation
|
72
|
+
#
|
73
|
+
# Requires authenticated client
|
74
|
+
#
|
75
|
+
# @param invitation_id [Integer] The id of the invitation
|
76
|
+
# @return [Boolean] True if the acceptance of the invitation was successful
|
77
|
+
# @see https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation
|
78
|
+
def accept_repository_invitation(invitation_id, options = {})
|
79
|
+
patch "/user/repository_invitations/#{invitation_id}", options
|
80
|
+
end
|
81
|
+
alias accept_repo_invitation accept_repository_invitation
|
82
|
+
|
83
|
+
# Decline a repository invitation
|
84
|
+
#
|
85
|
+
# Requires authenticated client
|
86
|
+
#
|
87
|
+
# @param invitation_id [Integer] The id of the invitation
|
88
|
+
# @return [Boolean] True if the acceptance of the invitation was successful
|
89
|
+
# @see https://developer.github.com/v3/repos/invitations/#decline-a-repository-invitation
|
90
|
+
def decline_repository_invitation(invitation_id, options = {})
|
91
|
+
boolean_from_response :delete, "/user/repository_invitations/#{invitation_id}", options
|
92
|
+
end
|
93
|
+
alias decline_invitation decline_repository_invitation
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Reviews API
|
6
|
+
#
|
7
|
+
# @see https://developer.github.com/v3/pulls/reviews/
|
8
|
+
module Reviews
|
9
|
+
# List reviews on a pull request
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
+
# @param number [Integer] Number ID of the pull request
|
13
|
+
# @see https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# @client.pull_request_reviews('octokit/octokit.rb', 2)
|
17
|
+
#
|
18
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reviews
|
19
|
+
def pull_request_reviews(repo, number, options = {})
|
20
|
+
paginate "#{Repository.path repo}/pulls/#{number}/reviews", options
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get a single review
|
24
|
+
#
|
25
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
26
|
+
# @param number [Integer] Number ID of the pull request
|
27
|
+
# @param review [Integer] The id of the review
|
28
|
+
# @see https://developer.github.com/v3/pulls/reviews/#get-a-single-review
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# @client.pull_request_review('octokit/octokit.rb', 825, 6505518)
|
32
|
+
#
|
33
|
+
# @return [Sawyer::Resource] Hash representing the review
|
34
|
+
def pull_request_review(repo, number, review, options = {})
|
35
|
+
get "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
|
36
|
+
end
|
37
|
+
|
38
|
+
# Delete a pending review
|
39
|
+
#
|
40
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
41
|
+
# @param number [Integer] Number ID of the pull request
|
42
|
+
# @param review [Integer] The id of the review
|
43
|
+
# @see https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# @client.delete_pull_request_review('octokit/octokit.rb', 825, 6505518)
|
47
|
+
#
|
48
|
+
# @return [Sawyer::Resource] Hash representing the deleted review
|
49
|
+
def delete_pull_request_review(repo, number, review, options = {})
|
50
|
+
delete "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get comments for a single review
|
54
|
+
#
|
55
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
56
|
+
# @param number [Integer] Number ID of the pull request
|
57
|
+
# @param review [Integer] The id of the review
|
58
|
+
# @see https://developer.github.com/v3/pulls/reviews/#get-comments-for-a-single-review
|
59
|
+
#
|
60
|
+
# @example
|
61
|
+
# @client.pull_request_review_comments('octokit/octokit.rb', 825, 6505518)
|
62
|
+
#
|
63
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the review comments
|
64
|
+
def pull_request_review_comments(repo, number, review, options = {})
|
65
|
+
paginate "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/comments", options
|
66
|
+
end
|
67
|
+
|
68
|
+
# Create a pull request review
|
69
|
+
#
|
70
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
71
|
+
# @param number [Integer] Number ID of the pull request
|
72
|
+
# @param options [Hash] Method options
|
73
|
+
# @option options [String] :event The review action (event) to perform;
|
74
|
+
# can be one of APPROVE, REQUEST_CHANGES, or COMMENT.
|
75
|
+
# If left blank, the review is left PENDING.
|
76
|
+
# @option options [String] :body The body text of the pull request review
|
77
|
+
# @option options [Array<Hash>] :comments Comments part of the review
|
78
|
+
# @option comments [String] :path The path to the file being commented on
|
79
|
+
# @option comments [Integer] :position The position in the file to be commented on
|
80
|
+
# @option comments [String] :body Body of the comment
|
81
|
+
# @see https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review
|
82
|
+
#
|
83
|
+
# @example
|
84
|
+
# comments = [
|
85
|
+
# { path: '.travis.yml', position: 10, body: 'ruby-head is under development that is not stable.' },
|
86
|
+
# { path: '.travis.yml', position: 32, body: 'ruby-head is also required in thervm section.' },
|
87
|
+
# ]
|
88
|
+
# options = { event: 'REQUEST_CHANGES', comments: comments }
|
89
|
+
# @client.create_pull_request_review('octokit/octokit.rb', 844, options)
|
90
|
+
#
|
91
|
+
# @return [Sawyer::Resource>] Hash respresenting the review
|
92
|
+
def create_pull_request_review(repo, number, options = {})
|
93
|
+
post "#{Repository.path repo}/pulls/#{number}/reviews", options
|
94
|
+
end
|
95
|
+
|
96
|
+
# Submit a pull request review
|
97
|
+
#
|
98
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
99
|
+
# @param number [Integer] Number ID of the pull request
|
100
|
+
# @param review [Integer] The id of the review
|
101
|
+
# @param event [String] The review action (event) to perform; can be one of
|
102
|
+
# APPROVE, REQUEST_CHANGES, or COMMENT.
|
103
|
+
# @param options [Hash] Method options
|
104
|
+
# @option options [String] :body The body text of the pull request review
|
105
|
+
# @see https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
# @client.submit_pull_request_review('octokit/octokit.rb', 825, 6505518,
|
109
|
+
# 'APPROVE', body: 'LGTM!')
|
110
|
+
#
|
111
|
+
# @return [Sawyer::Resource] Hash respresenting the review
|
112
|
+
def submit_pull_request_review(repo, number, review, event, options = {})
|
113
|
+
options = options.merge(event: event)
|
114
|
+
post "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/events", options
|
115
|
+
end
|
116
|
+
|
117
|
+
# Dismiss a pull request review
|
118
|
+
#
|
119
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
120
|
+
# @param number [Integer] Number ID of the pull request
|
121
|
+
# @param review [Integer] The id of the review
|
122
|
+
# @param message [String] The message for the pull request review dismissal
|
123
|
+
# @see https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review
|
124
|
+
#
|
125
|
+
# @example
|
126
|
+
# @client.dismiss_pull_request_review('octokit/octokit.rb', 825, 6505518, 'The message.')
|
127
|
+
#
|
128
|
+
# @return [Sawyer::Resource] Hash representing the dismissed review
|
129
|
+
def dismiss_pull_request_review(repo, number, review, message, options = {})
|
130
|
+
options = options.merge(message: message)
|
131
|
+
put "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/dismissals", options
|
132
|
+
end
|
133
|
+
|
134
|
+
# List review requests
|
135
|
+
#
|
136
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
137
|
+
# @param number [Integer] Number ID of the pull request
|
138
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#list-review-requests
|
139
|
+
#
|
140
|
+
# @example
|
141
|
+
# @client.pull_request_review_requests('octokit/octokit.rb', 2)
|
142
|
+
#
|
143
|
+
# @return [Array<Sawyer::Resource>] Array of Hashes representing the review requests
|
144
|
+
def pull_request_review_requests(repo, number, options = {})
|
145
|
+
paginate "#{Repository.path repo}/pulls/#{number}/requested_reviewers", options
|
146
|
+
end
|
147
|
+
|
148
|
+
# Create a review request
|
149
|
+
#
|
150
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
151
|
+
# @param number [Integer] Number ID of the pull request
|
152
|
+
# @param reviewers [Hash] :reviewers [Array<String>] An array of user logins
|
153
|
+
# @param options [Hash] :team_reviewers [Array<String>] An array of team slugs
|
154
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#request-reviewers-for-a-pull-request
|
155
|
+
#
|
156
|
+
# @example
|
157
|
+
# @client.request_pull_request_review('octokit/octokit.rb', 2, reviewers: ['soudy'])
|
158
|
+
#
|
159
|
+
# @return [Sawyer::Resource>] Hash respresenting the pull request
|
160
|
+
def request_pull_request_review(repo, number, reviewers = {}, options = {})
|
161
|
+
# TODO(5.0): remove deprecated behavior
|
162
|
+
if reviewers.is_a?(Array)
|
163
|
+
octokit_warn(
|
164
|
+
'Deprecated: Octokit::Client#request_pull_request_review ' \
|
165
|
+
"no longer takes a separate :reviewers argument.\n" \
|
166
|
+
'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
|
167
|
+
)
|
168
|
+
options = options.merge(reviewers: reviewers)
|
169
|
+
else
|
170
|
+
options = options.merge(reviewers)
|
171
|
+
end
|
172
|
+
|
173
|
+
post "#{Repository.path repo}/pulls/#{number}/requested_reviewers", options
|
174
|
+
end
|
175
|
+
|
176
|
+
# Delete a review request
|
177
|
+
#
|
178
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
179
|
+
# @param id [Integer] The id of the pull request
|
180
|
+
# @param reviewers [Hash] :reviewers [Array] An array of user logins
|
181
|
+
# @param options [Hash] :team_reviewers [Array] An array of team slugs
|
182
|
+
#
|
183
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request
|
184
|
+
#
|
185
|
+
# @example
|
186
|
+
# options = {
|
187
|
+
# "reviewers" => [ "octocat", "hubot", "other_user" ],
|
188
|
+
# "team_reviewers" => [ "justice-league" ]
|
189
|
+
# }
|
190
|
+
# @client.delete_pull_request_review_request('octokit/octokit.rb', 2, options)
|
191
|
+
#
|
192
|
+
# @return [Sawyer::Resource>] Hash representing the pull request
|
193
|
+
def delete_pull_request_review_request(repo, id, reviewers = {}, options = {})
|
194
|
+
# TODO(5.0): remove deprecated behavior
|
195
|
+
if !reviewers.empty? && !options.empty?
|
196
|
+
octokit_warn(
|
197
|
+
'Deprecated: Octokit::Client#delete_pull_request_review_request ' \
|
198
|
+
"no longer takes a separate :reviewers argument.\n" \
|
199
|
+
'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
|
200
|
+
)
|
201
|
+
end
|
202
|
+
# For backwards compatibility, this endpoint can be called with a separate reviewers hash.
|
203
|
+
# If not called with a separate hash, then 'reviewers' is, in fact, 'options'.
|
204
|
+
options = options.merge(reviewers)
|
205
|
+
delete "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
|
206
|
+
end
|
207
|
+
|
208
|
+
# Update a review request comment
|
209
|
+
#
|
210
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
211
|
+
# @param number [Integer] Number ID of the pull request
|
212
|
+
# @param review [Integer] The id of the review
|
213
|
+
# @param body [String] body text of the pull request review.
|
214
|
+
# @param options [Hash] Method options
|
215
|
+
# @see https://developer.github.com/v3/pulls/reviews/#update-a-pull-request-review
|
216
|
+
#
|
217
|
+
# @example
|
218
|
+
# @client.update_pull_request_review('octokit/octokit.rb', 825, 6505518, 'This is close to perfect! Please address the suggested inline change. And add more about this.')
|
219
|
+
#
|
220
|
+
# @return [Sawyer::Resource] Hash representing the review comment
|
221
|
+
def update_pull_request_review(repo, number, review, body, options = {})
|
222
|
+
options[:body] = body
|
223
|
+
put "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
data/lib/octokit/client/say.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the unpublished Octocat API
|
5
6
|
module Say
|
6
|
-
|
7
7
|
# Return a nifty ASCII Octocat with GitHub wisdom
|
8
8
|
# or your own
|
9
9
|
#
|
10
10
|
# @return [String]
|
11
11
|
def say(text = nil, options = {})
|
12
12
|
options[:s] = text if text
|
13
|
-
get
|
13
|
+
get 'octocat', options
|
14
14
|
end
|
15
|
-
alias
|
16
|
-
|
15
|
+
alias octocat say
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -1,23 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Search API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/search/
|
7
8
|
module Search
|
8
|
-
|
9
9
|
# Search code
|
10
10
|
#
|
11
11
|
# @param query [String] Search term and qualifiers
|
12
12
|
# @param options [Hash] Sort and pagination options
|
13
13
|
# @option options [String] :sort Sort field
|
14
14
|
# @option options [String] :order Sort order (asc or desc)
|
15
|
-
# @option options [
|
16
|
-
# @option options [
|
15
|
+
# @option options [Integer] :page Page of paginated results
|
16
|
+
# @option options [Integer] :per_page Number of items per page
|
17
17
|
# @return [Sawyer::Resource] Search results object
|
18
18
|
# @see https://developer.github.com/v3/search/#search-code
|
19
19
|
def search_code(query, options = {})
|
20
|
-
search
|
20
|
+
search 'search/code', query, options
|
21
|
+
end
|
22
|
+
|
23
|
+
# Search commits
|
24
|
+
#
|
25
|
+
# @param query [String] Search terms and qualifiers
|
26
|
+
# @param options [Hash] Sort and pagination options
|
27
|
+
# @option options [String] :sort Sort field
|
28
|
+
# @option options [String] :order Sort order (asc or desc)
|
29
|
+
# @option options [Integer] :page Page of paginated results
|
30
|
+
# @option options [Integer] :per_page Number of items per page
|
31
|
+
# @return [Sawyer::Resource] Search results object
|
32
|
+
# @see https://developer.github.com/v3/search/#search-commits
|
33
|
+
def search_commits(query, options = {})
|
34
|
+
search 'search/commits', query, options
|
21
35
|
end
|
22
36
|
|
23
37
|
# Search issues
|
@@ -26,12 +40,13 @@ module Octokit
|
|
26
40
|
# @param options [Hash] Sort and pagination options
|
27
41
|
# @option options [String] :sort Sort field
|
28
42
|
# @option options [String] :order Sort order (asc or desc)
|
29
|
-
# @option options [
|
30
|
-
# @option options [
|
43
|
+
# @option options [Integer] :page Page of paginated results
|
44
|
+
# @option options [Integer] :per_page Number of items per page
|
31
45
|
# @return [Sawyer::Resource] Search results object
|
32
|
-
# @see https://developer.github.com/v3/search/#search-issues
|
46
|
+
# @see https://developer.github.com/v3/search/#search-issues-and-pull-requests
|
47
|
+
# @see https://docs.github.com/en/rest/search#limitations-on-query-length
|
33
48
|
def search_issues(query, options = {})
|
34
|
-
search
|
49
|
+
search 'search/issues', query, options
|
35
50
|
end
|
36
51
|
|
37
52
|
# Search repositories
|
@@ -40,14 +55,28 @@ module Octokit
|
|
40
55
|
# @param options [Hash] Sort and pagination options
|
41
56
|
# @option options [String] :sort Sort field
|
42
57
|
# @option options [String] :order Sort order (asc or desc)
|
43
|
-
# @option options [
|
44
|
-
# @option options [
|
58
|
+
# @option options [Integer] :page Page of paginated results
|
59
|
+
# @option options [Integer] :per_page Number of items per page
|
45
60
|
# @return [Sawyer::Resource] Search results object
|
46
61
|
# @see https://developer.github.com/v3/search/#search-repositories
|
47
62
|
def search_repositories(query, options = {})
|
48
|
-
search
|
63
|
+
search 'search/repositories', query, options
|
64
|
+
end
|
65
|
+
alias search_repos search_repositories
|
66
|
+
|
67
|
+
# Search topics
|
68
|
+
#
|
69
|
+
# @param query [String] Search term and qualifiers
|
70
|
+
# @param options [Hash] Sort and pagination options
|
71
|
+
# @option options [String] :sort Sort field
|
72
|
+
# @option options [String] :order Sort order (asc or desc)
|
73
|
+
# @option options [Integer] :page Page of paginated results
|
74
|
+
# @option options [Integer] :per_page Number of items per page
|
75
|
+
# @return [Sawyer::Resource] Search results object
|
76
|
+
# @see https://developer.github.com/v3/search/#search-topics
|
77
|
+
def search_topics(query, options = {})
|
78
|
+
search 'search/topics', query, options
|
49
79
|
end
|
50
|
-
alias :search_repos :search_repositories
|
51
80
|
|
52
81
|
# Search users
|
53
82
|
#
|
@@ -55,18 +84,18 @@ module Octokit
|
|
55
84
|
# @param options [Hash] Sort and pagination options
|
56
85
|
# @option options [String] :sort Sort field
|
57
86
|
# @option options [String] :order Sort order (asc or desc)
|
58
|
-
# @option options [
|
59
|
-
# @option options [
|
87
|
+
# @option options [Integer] :page Page of paginated results
|
88
|
+
# @option options [Integer] :per_page Number of items per page
|
60
89
|
# @return [Sawyer::Resource] Search results object
|
61
90
|
# @see https://developer.github.com/v3/search/#search-users
|
62
91
|
def search_users(query, options = {})
|
63
|
-
search
|
92
|
+
search 'search/users', query, options
|
64
93
|
end
|
65
94
|
|
66
95
|
private
|
67
96
|
|
68
97
|
def search(path, query, options = {})
|
69
|
-
opts = options.merge(:
|
98
|
+
opts = options.merge(q: query)
|
70
99
|
paginate(path, opts) do |data, last_response|
|
71
100
|
data.items.concat last_response.data.items
|
72
101
|
end
|
@@ -1,37 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the GitHub Status API
|
5
6
|
#
|
6
7
|
# @see https://status.github.com/api
|
7
8
|
module ServiceStatus
|
8
|
-
|
9
9
|
# Root for status API
|
10
10
|
# @private
|
11
|
-
|
11
|
+
SUMMARY_ROOT = 'https://www.githubstatus.com/api/v2/summary.json'
|
12
|
+
STATUS_ROOT = 'https://www.githubstatus.com/api/v2/status.json'
|
13
|
+
COMPONENTS_ROOT = 'https://www.githubstatus.com/api/v2/components.json'
|
14
|
+
|
15
|
+
# Returns a summary with the current status and the last status messages.
|
16
|
+
#
|
17
|
+
# @return [<Sawyer::Resource>] GitHub status summary
|
18
|
+
# @see https://www.githubstatus.com/api#summory
|
19
|
+
def github_status_summary
|
20
|
+
get(SUMMARY_ROOT)
|
21
|
+
end
|
12
22
|
|
13
23
|
# Returns the current system status
|
14
24
|
#
|
15
25
|
# @return [Sawyer::Resource] GitHub status
|
16
|
-
# @see https://
|
26
|
+
# @see https://www.githubstatus.com/api#status
|
17
27
|
def github_status
|
18
|
-
get(STATUS_ROOT)
|
28
|
+
get(STATUS_ROOT)
|
19
29
|
end
|
20
30
|
|
21
31
|
# Returns the last human communication, status, and timestamp.
|
22
32
|
#
|
23
33
|
# @return [Sawyer::Resource] GitHub status last message
|
24
|
-
# @see https://
|
34
|
+
# @see https://www.githubstatus.com/api/#components
|
25
35
|
def github_status_last_message
|
26
|
-
get(
|
36
|
+
get(COMPONENTS_ROOT).components.first
|
27
37
|
end
|
28
38
|
|
29
39
|
# Returns the most recent human communications with status and timestamp.
|
30
40
|
#
|
31
41
|
# @return [Array<Sawyer::Resource>] GitHub status messages
|
32
|
-
# @see https://
|
42
|
+
# @see https://www.githubstatus.com/api#components
|
33
43
|
def github_status_messages
|
34
|
-
get(
|
44
|
+
get(COMPONENTS_ROOT).components
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|