octokit 3.0.0 → 3.1.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/lib/octokit/authentication.rb +4 -4
- data/lib/octokit/client.rb +70 -5
- data/lib/octokit/client/authorizations.rb +123 -29
- data/lib/octokit/client/commit_comments.rb +7 -7
- data/lib/octokit/client/commits.rb +11 -11
- data/lib/octokit/client/contents.rb +7 -7
- data/lib/octokit/client/deployments.rb +5 -5
- data/lib/octokit/client/downloads.rb +5 -5
- data/lib/octokit/client/emojis.rb +1 -1
- data/lib/octokit/client/events.rb +15 -15
- data/lib/octokit/client/feeds.rb +2 -2
- data/lib/octokit/client/gists.rb +17 -17
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +1 -1
- data/lib/octokit/client/issues.rb +16 -16
- data/lib/octokit/client/labels.rb +14 -14
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/markdown.rb +2 -2
- data/lib/octokit/client/meta.rb +2 -2
- data/lib/octokit/client/milestones.rb +6 -6
- data/lib/octokit/client/notifications.rb +10 -10
- data/lib/octokit/client/objects.rb +8 -8
- data/lib/octokit/client/organizations.rb +30 -30
- data/lib/octokit/client/pages.rb +4 -4
- data/lib/octokit/client/pub_sub_hubbub.rb +5 -5
- data/lib/octokit/client/pull_requests.rb +20 -20
- data/lib/octokit/client/rate_limit.rb +5 -5
- data/lib/octokit/client/refs.rb +9 -9
- data/lib/octokit/client/releases.rb +11 -11
- data/lib/octokit/client/repositories.rb +44 -44
- data/lib/octokit/client/search.rb +5 -5
- data/lib/octokit/client/stats.rb +6 -6
- data/lib/octokit/client/statuses.rb +3 -3
- data/lib/octokit/client/users.rb +36 -36
- data/lib/octokit/configurable.rb +4 -4
- data/lib/octokit/error.rb +4 -0
- data/lib/octokit/rate_limit.rb +1 -1
- data/lib/octokit/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe2687efdf727fedcb991105d4a5c9e7eb60d0d1
|
4
|
+
data.tar.gz: 16621b1aea7885ca2b4d1f7b508c815bcbaa717e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba5add3cb06441c097b1e02f74cecc55d0502d6a9d726680e3d61fb95d5a13d1d41f82203454abb2b42df7cf6588f26917c45d6a2b7d370e467df223f7a4d1d
|
7
|
+
data.tar.gz: aed860c22d4e46ed8b24c721231cd087d0ff497c36f91182091fa2145730e2c4b56504fd27a06abe83d1503fe7b7c44cb1a767f127690339706bad84c4ee3f05
|
@@ -6,7 +6,7 @@ module Octokit
|
|
6
6
|
# Indicates if the client was supplied Basic Auth
|
7
7
|
# username and password
|
8
8
|
#
|
9
|
-
# @see
|
9
|
+
# @see https://developer.github.com/v3/#authentication
|
10
10
|
# @return [Boolean]
|
11
11
|
def basic_authenticated?
|
12
12
|
!!(@login && @password)
|
@@ -15,7 +15,7 @@ module Octokit
|
|
15
15
|
# Indicates if the client was supplied an OAuth
|
16
16
|
# access token
|
17
17
|
#
|
18
|
-
# @see
|
18
|
+
# @see https://developer.github.com/v3/#authentication
|
19
19
|
# @return [Boolean]
|
20
20
|
def token_authenticated?
|
21
21
|
!!@access_token
|
@@ -24,7 +24,7 @@ module Octokit
|
|
24
24
|
# Indicates if the client was supplied an OAuth
|
25
25
|
# access token or Basic Auth username and password
|
26
26
|
#
|
27
|
-
# @see
|
27
|
+
# @see https://developer.github.com/v3/#authentication
|
28
28
|
# @return [Boolean]
|
29
29
|
def user_authenticated?
|
30
30
|
basic_authenticated? || token_authenticated?
|
@@ -34,7 +34,7 @@ module Octokit
|
|
34
34
|
# client_id and secret credentials to make anonymous
|
35
35
|
# requests at a higher rate limit
|
36
36
|
#
|
37
|
-
# @see
|
37
|
+
# @see https://developer.github.com/v3/#unauthenticated-rate-limited-requests
|
38
38
|
# @return Boolean
|
39
39
|
def application_authenticated?
|
40
40
|
!!application_authentication
|
data/lib/octokit/client.rb
CHANGED
@@ -45,7 +45,7 @@ module Octokit
|
|
45
45
|
|
46
46
|
# Client for the GitHub API
|
47
47
|
#
|
48
|
-
# @see
|
48
|
+
# @see https://developer.github.com
|
49
49
|
class Client
|
50
50
|
|
51
51
|
include Octokit::Authentication
|
@@ -243,8 +243,77 @@ module Octokit
|
|
243
243
|
@last_response if defined? @last_response
|
244
244
|
end
|
245
245
|
|
246
|
+
# Duplicate client using client_id and client_secret as
|
247
|
+
# Basic Authentication credentials.
|
248
|
+
# @example
|
249
|
+
# Octokit.client_id = "foo"
|
250
|
+
# Octokit.client_secret = "bar"
|
251
|
+
#
|
252
|
+
# # GET https://api.github.com/?client_id=foo&client_secret=bar
|
253
|
+
# Octokit.get "/"
|
254
|
+
#
|
255
|
+
# Octokit.client.as_app do |client|
|
256
|
+
# # GET https://foo:bar@api.github.com/
|
257
|
+
# client.get "/"
|
258
|
+
# end
|
259
|
+
def as_app(key = client_id, secret = client_secret, &block)
|
260
|
+
if key.to_s.empty? || secret.to_s.empty?
|
261
|
+
raise ApplicationCredentialsRequired, "client_id and client_secret required"
|
262
|
+
end
|
263
|
+
app_client = self.dup
|
264
|
+
app_client.client_id = app_client.client_secret = nil
|
265
|
+
app_client.login = key
|
266
|
+
app_client.password = secret
|
267
|
+
|
268
|
+
yield app_client if block_given?
|
269
|
+
end
|
270
|
+
|
271
|
+
# Set username for authentication
|
272
|
+
#
|
273
|
+
# @param value [String] GitHub username
|
274
|
+
def login=(value)
|
275
|
+
reset_agent
|
276
|
+
@login = value
|
277
|
+
end
|
278
|
+
|
279
|
+
# Set password for authentication
|
280
|
+
#
|
281
|
+
# @param value [String] GitHub password
|
282
|
+
def password=(value)
|
283
|
+
reset_agent
|
284
|
+
@password = value
|
285
|
+
end
|
286
|
+
|
287
|
+
# Set OAuth access token for authentication
|
288
|
+
#
|
289
|
+
# @param value [String] 40 character GitHub OAuth access token
|
290
|
+
def access_token=(value)
|
291
|
+
reset_agent
|
292
|
+
@access_token = value
|
293
|
+
end
|
294
|
+
|
295
|
+
# Set OAuth app client_id
|
296
|
+
#
|
297
|
+
# @param value [String] 20 character GitHub OAuth app client_id
|
298
|
+
def client_id=(value)
|
299
|
+
reset_agent
|
300
|
+
@client_id = value
|
301
|
+
end
|
302
|
+
|
303
|
+
# Set OAuth app client_secret
|
304
|
+
#
|
305
|
+
# @param value [String] 40 character GitHub OAuth app client_secret
|
306
|
+
def client_secret=(value)
|
307
|
+
reset_agent
|
308
|
+
@client_secret = value
|
309
|
+
end
|
310
|
+
|
246
311
|
private
|
247
312
|
|
313
|
+
def reset_agent
|
314
|
+
@agent = nil
|
315
|
+
end
|
316
|
+
|
248
317
|
def request(method, path, data, options = {})
|
249
318
|
if data.is_a?(Hash)
|
250
319
|
options[:query] = data.delete(:query) || {}
|
@@ -254,10 +323,6 @@ module Octokit
|
|
254
323
|
end
|
255
324
|
end
|
256
325
|
|
257
|
-
if application_authenticated?
|
258
|
-
options[:query].merge! application_authentication
|
259
|
-
end
|
260
|
-
|
261
326
|
@last_response = response = agent.call(method, URI::Parser.new.escape(path.to_s), data, options)
|
262
327
|
response.data
|
263
328
|
end
|
@@ -3,7 +3,7 @@ module Octokit
|
|
3
3
|
|
4
4
|
# Methods for the Authorizations API
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#oauth-authorizations-api
|
7
7
|
module Authorizations
|
8
8
|
|
9
9
|
# List the authenticated user's authorizations
|
@@ -13,7 +13,7 @@ module Octokit
|
|
13
13
|
# Basic Authentication.
|
14
14
|
#
|
15
15
|
# @return [Array<Sawyer::Resource>] A list of authorizations for the authenticated user
|
16
|
-
# @see
|
16
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
|
17
17
|
# @example List authorizations for user ctshryock
|
18
18
|
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
19
19
|
# client.authorizations
|
@@ -27,7 +27,7 @@ module Octokit
|
|
27
27
|
# Basic Authentication.
|
28
28
|
#
|
29
29
|
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
30
|
-
# @see
|
30
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
|
31
31
|
# @example Show authorization for user ctshryock's Travis auth
|
32
32
|
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
33
33
|
# client.authorization(999999)
|
@@ -49,9 +49,9 @@ module Octokit
|
|
49
49
|
# @option options [String] :client_secret Client Secret we received when our application was registered with GitHub.
|
50
50
|
#
|
51
51
|
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
52
|
-
# @see
|
53
|
-
# @see
|
54
|
-
# @see
|
52
|
+
# @see https://developer.github.com/v3/oauth/#scopes Available scopes
|
53
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization
|
54
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#get-or-create-an-authorization-for-a-specific-app
|
55
55
|
# @example Create a new authorization for user ctshryock's project Zoidberg
|
56
56
|
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
57
57
|
# client.create_authorization({:scopes => ["public_repo","gist"], :note => "Why not Zoidberg?", :note_url=> "https://en.wikipedia.org/wiki/Zoidberg"})
|
@@ -85,8 +85,8 @@ module Octokit
|
|
85
85
|
# @option options [String] :note_url A URL to remind you what app the OAuth token is for.
|
86
86
|
#
|
87
87
|
# @return [Sawyer::Resource] A single (updated) authorization for the authenticated user
|
88
|
-
# @see
|
89
|
-
# @see
|
88
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
|
89
|
+
# @see https://developer.github.com/v3/oauth/#scopes for available scopes
|
90
90
|
# @example Update the authorization for user ctshryock's project Zoidberg
|
91
91
|
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
92
92
|
# client.update_authorization(999999, {:add_scopes => ["gist", "repo"], :note => "Why not Zoidberg possibly?"})
|
@@ -102,7 +102,7 @@ module Octokit
|
|
102
102
|
# @param number [Number] An existing Authorization ID
|
103
103
|
#
|
104
104
|
# @return [Boolean] Success
|
105
|
-
# @see
|
105
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization
|
106
106
|
# @example Delete an authorization
|
107
107
|
# client = Octokit::Client.new(:login => 'ctshryock', :password => 'secret')
|
108
108
|
# client.delete_authorization(999999)
|
@@ -114,7 +114,7 @@ module Octokit
|
|
114
114
|
#
|
115
115
|
# @param token [String] GitHub OAuth token
|
116
116
|
# @return [Array<String>] OAuth scopes
|
117
|
-
# @see
|
117
|
+
# @see https://developer.github.com/v3/oauth/#scopes
|
118
118
|
def scopes(token = @access_token)
|
119
119
|
raise ArgumentError.new("Access token required") if token.nil?
|
120
120
|
|
@@ -126,28 +126,122 @@ module Octokit
|
|
126
126
|
sort
|
127
127
|
end
|
128
128
|
|
129
|
-
|
129
|
+
# Check if a token is valid.
|
130
|
+
#
|
131
|
+
# Applications can check if a token is valid without rate limits.
|
132
|
+
#
|
133
|
+
# @param token [String] 40 character GitHub OAuth access token
|
134
|
+
#
|
135
|
+
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
136
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#check-an-authorization
|
137
|
+
# @example
|
138
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
139
|
+
# client.check_application_authorization('deadbeef1234567890deadbeef987654321')
|
140
|
+
def check_application_authorization(token, options = {})
|
141
|
+
opts = options.dup
|
142
|
+
key = opts.delete(:client_id) || client_id
|
143
|
+
secret = opts.delete(:client_secret) || client_secret
|
130
144
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
145
|
+
as_app(key, secret) do |app_client|
|
146
|
+
app_client.get "/applications/#{client_id}/tokens/#{token}", opts
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Reset a token
|
151
|
+
#
|
152
|
+
# Applications can reset a token without requiring a user to re-authorize.
|
153
|
+
#
|
154
|
+
# @param token [String] 40 character GitHub OAuth access token
|
155
|
+
#
|
156
|
+
# @return [Sawyer::Resource] A single authorization for the authenticated user
|
157
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization
|
158
|
+
# @example
|
159
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
160
|
+
# client.reset_application_authorization('deadbeef1234567890deadbeef987654321')
|
161
|
+
def reset_application_authorization(token, options = {})
|
162
|
+
opts = options.dup
|
163
|
+
key = opts.delete(:client_id) || client_id
|
164
|
+
secret = opts.delete(:client_secret) || client_secret
|
165
|
+
|
166
|
+
as_app(key, secret) do |app_client|
|
167
|
+
app_client.post "/applications/#{client_id}/tokens/#{token}", opts
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Revoke a token
|
172
|
+
#
|
173
|
+
# Applications can revoke (delete) a token
|
174
|
+
#
|
175
|
+
# @param token [String] 40 character GitHub OAuth access token
|
176
|
+
#
|
177
|
+
# @return [Boolean] Result
|
178
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application
|
179
|
+
# @example
|
180
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
181
|
+
# client.revoke_application_authorization('deadbeef1234567890deadbeef987654321')
|
182
|
+
def revoke_application_authorization(token, options = {})
|
183
|
+
opts = options.dup
|
184
|
+
key = opts.delete(:client_id) || client_id
|
185
|
+
secret = opts.delete(:client_secret) || client_secret
|
186
|
+
|
187
|
+
as_app(key, secret) do |app_client|
|
188
|
+
app_client.delete "/applications/#{client_id}/tokens/#{token}", opts
|
189
|
+
|
190
|
+
app_client.last_response.status == 204
|
191
|
+
end
|
192
|
+
rescue Octokit::NotFound
|
193
|
+
false
|
194
|
+
end
|
195
|
+
alias :delete_application_authorization :revoke_application_authorization
|
196
|
+
|
197
|
+
# Revoke all tokens for an app
|
198
|
+
#
|
199
|
+
# Applications can revoke all of their tokens in a single request
|
200
|
+
#
|
201
|
+
# @return [Boolean] Result
|
202
|
+
# @see https://developer.github.com/v3/oauth_authorizations/#revoke-all-authorizations-for-an-application
|
203
|
+
# @example
|
204
|
+
# client = Octokit::Client.new(:client_id => 'abcdefg12345', :client_secret => 'secret')
|
205
|
+
# client.revoke_all_application_authorizations
|
206
|
+
def revoke_all_application_authorizations(options = {})
|
207
|
+
opts = options.dup
|
208
|
+
key = opts.delete(:client_id) || client_id
|
209
|
+
secret = opts.delete(:client_secret) || client_secret
|
210
|
+
|
211
|
+
as_app(key, secret) do |app_client|
|
212
|
+
app_client.delete "/applications/#{client_id}/tokens", opts
|
213
|
+
|
214
|
+
app_client.last_response.status == 204
|
215
|
+
end
|
216
|
+
rescue Octokit::NotFound
|
217
|
+
false
|
148
218
|
end
|
219
|
+
alias :delete_application_authorization :revoke_application_authorization
|
149
220
|
|
150
|
-
|
221
|
+
# Get the URL to authorize a user for an application via the web flow
|
222
|
+
#
|
223
|
+
# @param app_id [String] Client Id we received when our application was registered with GitHub.
|
224
|
+
# @option options [String] :redirect_uri The url to redirect to after authorizing.
|
225
|
+
# @option options [String] :scope The scopes to request from the user.
|
226
|
+
# @option options [String] :state A random string to protect against CSRF.
|
227
|
+
# @return [String] The url to redirect the user to authorize.
|
228
|
+
# @see Octokit::Client
|
229
|
+
# @see https://developer.github.com/v3/oauth/#web-application-flow
|
230
|
+
# @example
|
231
|
+
# @client.authorize_url('xxxx')
|
232
|
+
def authorize_url(app_id = client_id, options = {})
|
233
|
+
if app_id.to_s.empty?
|
234
|
+
raise Octokit::ApplicationCredentialsRequired.new "client_id required"
|
235
|
+
end
|
236
|
+
authorize_url = options.delete(:endpoint) || Octokit.web_endpoint
|
237
|
+
authorize_url += "login/oauth/authorize?client_id=" + app_id
|
238
|
+
|
239
|
+
options.each do |key, value|
|
240
|
+
authorize_url += "&" + key.to_s + "=" + value
|
241
|
+
end
|
242
|
+
|
243
|
+
authorize_url
|
244
|
+
end
|
151
245
|
end
|
152
246
|
end
|
153
247
|
end
|
@@ -3,14 +3,14 @@ module Octokit
|
|
3
3
|
|
4
4
|
# Methods for the Commit Comments API
|
5
5
|
#
|
6
|
-
# @see
|
6
|
+
# @see https://developer.github.com/v3/repos/comments/
|
7
7
|
module CommitComments
|
8
8
|
|
9
9
|
# List all commit comments
|
10
10
|
#
|
11
11
|
# @param repo [String, Hash, Repository] A GitHub repository
|
12
12
|
# @return [Array] List of commit comments
|
13
|
-
# @see
|
13
|
+
# @see https://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository
|
14
14
|
def list_commit_comments(repo, options = {})
|
15
15
|
get "repos/#{Repository.new(repo)}/comments", options
|
16
16
|
end
|
@@ -20,7 +20,7 @@ module Octokit
|
|
20
20
|
# @param repo [String, Hash, Repository] A GitHub repository
|
21
21
|
# @param sha [String] The SHA of the commit whose comments will be fetched
|
22
22
|
# @return [Array] List of commit comments
|
23
|
-
# @see
|
23
|
+
# @see https://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit
|
24
24
|
def commit_comments(repo, sha, options = {})
|
25
25
|
get "repos/#{Repository.new(repo)}/commits/#{sha}/comments", options
|
26
26
|
end
|
@@ -30,7 +30,7 @@ module Octokit
|
|
30
30
|
# @param repo [String, Hash, Repository] A GitHub repository
|
31
31
|
# @param id [String] The ID of the comment to fetch
|
32
32
|
# @return [Sawyer::Resource] Commit comment
|
33
|
-
# @see
|
33
|
+
# @see https://developer.github.com/v3/repos/comments/#get-a-single-commit-comment
|
34
34
|
def commit_comment(repo, id, options = {})
|
35
35
|
get "repos/#{Repository.new(repo)}/comments/#{id}", options
|
36
36
|
end
|
@@ -44,7 +44,7 @@ module Octokit
|
|
44
44
|
# @param line [Integer] Line number in the file to comment on
|
45
45
|
# @param position [Integer] Line index in the diff to comment on
|
46
46
|
# @return [Sawyer::Resource] Commit comment
|
47
|
-
# @see
|
47
|
+
# @see https://developer.github.com/v3/repos/comments/#create-a-commit-comment
|
48
48
|
# @example Create a commit comment
|
49
49
|
# comment = Octokit.create_commit_comment("octocat/Hello-World", "827efc6d56897b048c772eb4087f854f46256132", "My comment message", "README.md", 10, 1)
|
50
50
|
# comment.commit_id # => "827efc6d56897b048c772eb4087f854f46256132"
|
@@ -69,7 +69,7 @@ module Octokit
|
|
69
69
|
# @param id [String] The ID of the comment to update
|
70
70
|
# @param body [String] Message
|
71
71
|
# @return [Sawyer::Resource] Updated commit comment
|
72
|
-
# @see
|
72
|
+
# @see https://developer.github.com/v3/repos/comments/#update-a-commit-comment
|
73
73
|
# @example Update a commit comment
|
74
74
|
# comment = Octokit.update_commit_comment("octocat/Hello-World", "860296", "Updated commit comment")
|
75
75
|
# comment.id # => 860296
|
@@ -86,7 +86,7 @@ module Octokit
|
|
86
86
|
# @param repo [String, Hash, Repository] A GitHub repository
|
87
87
|
# @param id [String] The ID of the comment to delete
|
88
88
|
# @return [Boolean] Success
|
89
|
-
# @see
|
89
|
+
# @see https://developer.github.com/v3/repos/comments/#delete-a-commit-comment
|
90
90
|
def delete_commit_comment(repo, id, options = {})
|
91
91
|
boolean_from_response :delete, "repos/#{Repository.new(repo)}/comments/#{id}", options
|
92
92
|
end
|
@@ -5,7 +5,7 @@ module Octokit
|
|
5
5
|
|
6
6
|
# Methods for the Commits API
|
7
7
|
#
|
8
|
-
# @see
|
8
|
+
# @see https://developer.github.com/v3/repos/commits/
|
9
9
|
module Commits
|
10
10
|
|
11
11
|
# List commits
|
@@ -19,7 +19,7 @@ module Octokit
|
|
19
19
|
# @param repo [String, Hash, Repository] A GitHub repository
|
20
20
|
# @param options [String] :sha Commit SHA or branch name from which to start the list
|
21
21
|
# @return [Array<Sawyer::Resource>] An array of hashes representing commits
|
22
|
-
# @see
|
22
|
+
# @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
|
23
23
|
def commits(*args)
|
24
24
|
arguments = Octokit::RepoArguments.new(args)
|
25
25
|
sha_or_branch = arguments.pop
|
@@ -43,7 +43,7 @@ module Octokit
|
|
43
43
|
# @param sha_or_branch [String] A commit SHA or branch name
|
44
44
|
# @param options [String] :sha Commit SHA or branch name from which to start the list
|
45
45
|
# @return [Array<Sawyer::Resource>] An array of hashes representing commits
|
46
|
-
# @see
|
46
|
+
# @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
|
47
47
|
# @example
|
48
48
|
# Octokit.commits_since('octokit/octokit.rb', '2012-10-01')
|
49
49
|
def commits_since(*args)
|
@@ -69,7 +69,7 @@ module Octokit
|
|
69
69
|
# @param date [String] Date on which we want to compare
|
70
70
|
# @param sha_or_branch [String] Commit SHA or branch name from which to start the list
|
71
71
|
# @return [Array<Sawyer::Resource>] An array of hashes representing commits
|
72
|
-
# @see
|
72
|
+
# @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
|
73
73
|
# @example
|
74
74
|
# Octokit.commits_before('octokit/octokit.rb', '2012-10-01')
|
75
75
|
def commits_before(*args)
|
@@ -95,7 +95,7 @@ module Octokit
|
|
95
95
|
# @param date [String] Date on which we want to compare
|
96
96
|
# @param sha_or_branch [String] Commit SHA or branch name from which to start the list
|
97
97
|
# @return [Array<Sawyer::Resource>] An array of hashes representing commits
|
98
|
-
# @see
|
98
|
+
# @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
|
99
99
|
# @example
|
100
100
|
# Octokit.commits_on('octokit/octokit.rb', '2012-10-01')
|
101
101
|
def commits_on(*args)
|
@@ -124,7 +124,7 @@ module Octokit
|
|
124
124
|
# @param end_date [String] End Date on which we want to compare
|
125
125
|
# @param sha_or_branch [String] Commit SHA or branch name from which to start the list
|
126
126
|
# @return [Array<Sawyer::Resource>] An array of hashes representing commits
|
127
|
-
# @see
|
127
|
+
# @see https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
|
128
128
|
# @example
|
129
129
|
# Octokit.commits_on('octokit/octokit.rb', '2012-10-01', '2012-11-01')
|
130
130
|
def commits_between(*args)
|
@@ -147,7 +147,7 @@ module Octokit
|
|
147
147
|
# @param repo [String, Hash, Repository] A GitHub repository
|
148
148
|
# @param sha [String] The SHA of the commit to fetch
|
149
149
|
# @return [Sawyer::Resource] A hash representing the commit
|
150
|
-
# @see
|
150
|
+
# @see https://developer.github.com/v3/repos/commits/#get-a-single-commit
|
151
151
|
def commit(repo, sha, options = {})
|
152
152
|
get "repos/#{Repository.new(repo)}/commits/#{sha}", options
|
153
153
|
end
|
@@ -157,7 +157,7 @@ module Octokit
|
|
157
157
|
# @param repo [String, Hash, Repository] A GitHub repository
|
158
158
|
# @param sha [String] The SHA of the commit to fetch
|
159
159
|
# @return [Sawyer::Resource] A hash representing the commit
|
160
|
-
# @see
|
160
|
+
# @see https://developer.github.com/v3/git/commits/#get-a-commit
|
161
161
|
def git_commit(repo, sha, options = {})
|
162
162
|
get "repos/#{Repository.new(repo)}/git/commits/#{sha}", options
|
163
163
|
end
|
@@ -174,7 +174,7 @@ module Octokit
|
|
174
174
|
# @param tree [String] The SHA of the tree object the new commit will point to
|
175
175
|
# @param parents [String, Array] One SHA (for a normal commit) or an array of SHAs (for a merge) of the new commit's parent commits. If ommitted or empty, a root commit will be created
|
176
176
|
# @return [Sawyer::Resource] A hash representing the new commit
|
177
|
-
# @see
|
177
|
+
# @see https://developer.github.com/v3/git/commits/#create-a-commit
|
178
178
|
# @example Create a commit
|
179
179
|
# commit = Octokit.create_commit("octocat/Hello-World", "My commit message", "827efc6d56897b048c772eb4087f854f46256132", "7d1b31e74ee336d15cbd21741bc88a537ed063a0")
|
180
180
|
# commit.sha # => "7638417db6d59f3c431d3e1f261cc637155684cd"
|
@@ -193,7 +193,7 @@ module Octokit
|
|
193
193
|
# @param start [String] The sha of the starting commit
|
194
194
|
# @param endd [String] The sha of the ending commit
|
195
195
|
# @return [Sawyer::Resource] A hash representing the comparison
|
196
|
-
# @see
|
196
|
+
# @see https://developer.github.com/v3/repos/commits/#compare-two-commits
|
197
197
|
def compare(repo, start, endd, options = {})
|
198
198
|
get "repos/#{Repository.new(repo)}/compare/#{start}...#{endd}", options
|
199
199
|
end
|
@@ -205,7 +205,7 @@ module Octokit
|
|
205
205
|
# @param head [String] The branch or SHA1 to merge
|
206
206
|
# @option options [String] :commit_message The commit message for the merge
|
207
207
|
# @return [Sawyer::Resource] A hash representing the comparison
|
208
|
-
# @see
|
208
|
+
# @see https://developer.github.com/v3/repos/merging/#perform-a-merge
|
209
209
|
def merge(repo, base, head, options = {})
|
210
210
|
params = {
|
211
211
|
:base => base,
|