github_api 0.7.1 → 0.7.2
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.
- data/README.md +11 -0
- data/lib/github_api/api.rb +20 -22
- data/lib/github_api/core_ext/hash.rb +17 -0
- data/lib/github_api/events.rb +3 -3
- data/lib/github_api/git_data/blobs.rb +2 -2
- data/lib/github_api/git_data/commits.rb +2 -2
- data/lib/github_api/git_data/references.rb +5 -5
- data/lib/github_api/git_data/tags.rb +2 -2
- data/lib/github_api/git_data/trees.rb +2 -2
- data/lib/github_api/issues.rb +4 -4
- data/lib/github_api/issues/comments.rb +6 -6
- data/lib/github_api/issues/events.rb +2 -2
- data/lib/github_api/issues/labels.rb +10 -10
- data/lib/github_api/issues/milestones.rb +5 -5
- data/lib/github_api/page_iterator.rb +4 -3
- data/lib/github_api/pull_requests.rb +8 -8
- data/lib/github_api/pull_requests/comments.rb +5 -5
- data/lib/github_api/repos.rb +15 -8
- data/lib/github_api/repos/collaborators.rb +4 -4
- data/lib/github_api/repos/comments.rb +121 -0
- data/lib/github_api/repos/commits.rb +56 -177
- data/lib/github_api/repos/contents.rb +3 -0
- data/lib/github_api/repos/downloads.rb +4 -4
- data/lib/github_api/repos/forks.rb +2 -2
- data/lib/github_api/repos/hooks.rb +6 -6
- data/lib/github_api/repos/keys.rb +5 -5
- data/lib/github_api/repos/merging.rb +1 -0
- data/lib/github_api/repos/starring.rb +3 -1
- data/lib/github_api/repos/statuses.rb +2 -2
- data/lib/github_api/repos/watching.rb +1 -1
- data/lib/github_api/version.rb +1 -1
- data/spec/github/api/set_spec.rb +19 -0
- data/spec/github/repos/comments/create_spec.rb +86 -0
- data/spec/github/repos/comments/delete_spec.rb +47 -0
- data/spec/github/repos/comments/get_spec.rb +54 -0
- data/spec/github/repos/comments/list_spec.rb +120 -0
- data/spec/github/repos/comments/update_spec.rb +54 -0
- data/spec/github/repos/commits/compare_spec.rb +37 -0
- data/spec/github/repos/commits/get_spec.rb +56 -0
- data/spec/github/repos/commits/list_spec.rb +63 -0
- data/spec/github/repos/downloads/create_spec.rb +66 -0
- data/spec/github/repos/downloads/delete_spec.rb +48 -0
- data/spec/github/repos/downloads/get_spec.rb +58 -0
- data/spec/github/repos/downloads/list_spec.rb +63 -0
- data/spec/github/repos/downloads/upload_spec.rb +32 -0
- data/spec/github/repos/downloads_spec.rb +1 -233
- data/spec/github/repos_spec.rb +2 -0
- data/spec/spec_helper.rb +1 -0
- metadata +48 -34
- data/spec/github/repos/commits_spec.rb +0 -471
@@ -95,10 +95,11 @@ module Github
|
|
95
95
|
# last page URI then there is only one page.
|
96
96
|
page_uri = first_page_uri || last_page_uri
|
97
97
|
return nil unless page_uri
|
98
|
+
params = parse_query page_uri.split(QUERY_STR_SEP).last
|
99
|
+
params['page'] = page_number
|
100
|
+
params['per_page'] = parse_per_page_number(page_uri)
|
101
|
+
response = page_request page_uri.split(QUERY_STR_SEP).first, params
|
98
102
|
|
99
|
-
response = page_request page_uri.split(QUERY_STR_SEP).first,
|
100
|
-
'page' => page_number,
|
101
|
-
'per_page' => parse_per_page_number(page_uri)
|
102
103
|
update_page_links response.links
|
103
104
|
response
|
104
105
|
end
|
@@ -44,7 +44,7 @@ module Github
|
|
44
44
|
# pull_reqs.pull_requests.list 'user-name', 'repo-name'
|
45
45
|
#
|
46
46
|
def list(user_name, repo_name, params={})
|
47
|
-
|
47
|
+
set :user => user_name, :repo => repo_name
|
48
48
|
assert_presence_of user, repo
|
49
49
|
|
50
50
|
normalize! params
|
@@ -68,7 +68,7 @@ module Github
|
|
68
68
|
# @pull_reqs.get 'user-name', 'repo-name', 'request-id'
|
69
69
|
#
|
70
70
|
def get(user_name, repo_name, request_id, params={})
|
71
|
-
|
71
|
+
set :user => user_name, :repo => repo_name
|
72
72
|
assert_presence_of user, repo, request_id
|
73
73
|
normalize! params
|
74
74
|
# _merge_mime_type(:pull_request, params)
|
@@ -107,7 +107,7 @@ module Github
|
|
107
107
|
# "base" => "master"
|
108
108
|
#
|
109
109
|
def create(user_name, repo_name, params={})
|
110
|
-
|
110
|
+
set :user => user_name, :repo => repo_name
|
111
111
|
assert_presence_of user, repo
|
112
112
|
|
113
113
|
normalize! params
|
@@ -132,7 +132,7 @@ module Github
|
|
132
132
|
# "state" => "open",
|
133
133
|
#
|
134
134
|
def update(user_name, repo_name, request_id, params={})
|
135
|
-
|
135
|
+
set :user => user_name, :repo => repo_name
|
136
136
|
assert_presence_of user, repo, request_id
|
137
137
|
|
138
138
|
normalize! params
|
@@ -150,7 +150,7 @@ module Github
|
|
150
150
|
# github.pull_requests.commits 'user-name', 'repo-name', 'request-id'
|
151
151
|
#
|
152
152
|
def commits(user_name, repo_name, request_id, params={})
|
153
|
-
|
153
|
+
set :user => user_name, :repo => repo_name
|
154
154
|
assert_presence_of user, repo, request_id
|
155
155
|
|
156
156
|
normalize! params
|
@@ -168,7 +168,7 @@ module Github
|
|
168
168
|
# github.pull_requests.files 'user-name', 'repo-name', 'request-id'
|
169
169
|
#
|
170
170
|
def files(user_name, repo_name, request_id, params={})
|
171
|
-
|
171
|
+
set :user => user_name, :repo => repo_name
|
172
172
|
assert_presence_of user, repo, request_id
|
173
173
|
normalize! params
|
174
174
|
# _merge_mime_type(:pull_request, params)
|
@@ -185,7 +185,7 @@ module Github
|
|
185
185
|
# github.pull_requests.merged? 'user-name', 'repo-name', 'request-id'
|
186
186
|
#
|
187
187
|
def merged?(user_name, repo_name, request_id, params={})
|
188
|
-
|
188
|
+
set :user => user_name, :repo => repo_name
|
189
189
|
assert_presence_of user, repo, request_id
|
190
190
|
|
191
191
|
normalize! params
|
@@ -207,7 +207,7 @@ module Github
|
|
207
207
|
# github.pull_requests.merge 'user-name', 'repo-name', 'request-id'
|
208
208
|
#
|
209
209
|
def merge(user_name, repo_name, request_id, params={})
|
210
|
-
|
210
|
+
set :user => user_name, :repo => repo_name
|
211
211
|
assert_presence_of user, repo, request_id
|
212
212
|
|
213
213
|
normalize! params
|
@@ -20,7 +20,7 @@ module Github
|
|
20
20
|
# github.pull_requests.comments.list 'user-name', 'repo-name', 'request-id'
|
21
21
|
#
|
22
22
|
def list(user_name, repo_name, request_id, params={})
|
23
|
-
|
23
|
+
set :user => user_name, :repo => repo_name
|
24
24
|
assert_presence_of user, repo, request_id
|
25
25
|
|
26
26
|
normalize! params
|
@@ -38,7 +38,7 @@ module Github
|
|
38
38
|
# github.pull_requests.comments.get 'user-name', 'repo-name', 'comment-id'
|
39
39
|
#
|
40
40
|
def get(user_name, repo_name, comment_id, params={})
|
41
|
-
|
41
|
+
set :user => user_name, :repo => repo_name
|
42
42
|
assert_presence_of user, repo, comment_id
|
43
43
|
|
44
44
|
normalize! params
|
@@ -77,7 +77,7 @@ module Github
|
|
77
77
|
# "in_reply_to" => 4
|
78
78
|
#
|
79
79
|
def create(user_name, repo_name, request_id, params={})
|
80
|
-
|
80
|
+
set :user => user_name, :repo => repo_name
|
81
81
|
assert_presence_of user, repo, request_id
|
82
82
|
|
83
83
|
normalize! params
|
@@ -99,7 +99,7 @@ module Github
|
|
99
99
|
# "body" => "Nice change"
|
100
100
|
#
|
101
101
|
def edit(user_name, repo_name, comment_id, params={})
|
102
|
-
|
102
|
+
set :user => user_name, :repo => repo_name
|
103
103
|
assert_presence_of user, repo, comment_id
|
104
104
|
|
105
105
|
normalize! params
|
@@ -116,7 +116,7 @@ module Github
|
|
116
116
|
# github.pull_requests.comments.delete 'user-name', 'repo-name','comment-id'
|
117
117
|
#
|
118
118
|
def delete(user_name, repo_name, comment_id, params={})
|
119
|
-
|
119
|
+
set :user => user_name, :repo => repo_name
|
120
120
|
assert_presence_of user, repo, comment_id
|
121
121
|
|
122
122
|
normalize! params
|
data/lib/github_api/repos.rb
CHANGED
@@ -7,6 +7,7 @@ module Github
|
|
7
7
|
# Load all the modules after initializing Repos to avoid superclass mismatch
|
8
8
|
autoload_all 'github_api/repos',
|
9
9
|
:Collaborators => 'collaborators',
|
10
|
+
:Comments => 'comments',
|
10
11
|
:Commits => 'commits',
|
11
12
|
:Contents => 'contents',
|
12
13
|
:Downloads => 'downloads',
|
@@ -50,6 +51,11 @@ module Github
|
|
50
51
|
@collaborators ||= ApiFactory.new 'Repos::Collaborators'
|
51
52
|
end
|
52
53
|
|
54
|
+
# Access to Repos::Comments API
|
55
|
+
def comments
|
56
|
+
@commits ||= ApiFactory.new 'Repos::Comments'
|
57
|
+
end
|
58
|
+
|
53
59
|
# Access to Repos::Commits API
|
54
60
|
def commits
|
55
61
|
@commits ||= ApiFactory.new 'Repos::Commits'
|
@@ -116,7 +122,7 @@ module Github
|
|
116
122
|
# repos.branches 'user-name', 'repo-name'
|
117
123
|
#
|
118
124
|
def branches(user_name, repo_name, params={})
|
119
|
-
|
125
|
+
set :user => user_name, :repo => repo_name
|
120
126
|
assert_presence_of user, repo
|
121
127
|
normalize! params
|
122
128
|
|
@@ -134,6 +140,7 @@ module Github
|
|
134
140
|
# github.repos.branch 'user-name', 'repo-name', 'branch-name'
|
135
141
|
#
|
136
142
|
def branch(user_name, repo_name, branch, params={})
|
143
|
+
set :user => user_name, :repo => repo_name
|
137
144
|
assert_presence_of user_name, repo_name, branch
|
138
145
|
normalize! params
|
139
146
|
|
@@ -194,7 +201,7 @@ module Github
|
|
194
201
|
# github.repos.delete 'user-name', 'repo-name'
|
195
202
|
#
|
196
203
|
def delete(user_name, repo_name, params={})
|
197
|
-
|
204
|
+
set :user => user_name, :repo => repo_name
|
198
205
|
assert_presence_of user, repo
|
199
206
|
normalize! params
|
200
207
|
|
@@ -214,7 +221,7 @@ module Github
|
|
214
221
|
# github.repos.contributors 'user-name','repo-name' { |cont| ... }
|
215
222
|
#
|
216
223
|
def contributors(user_name, repo_name, params={})
|
217
|
-
|
224
|
+
set :user => user_name, :repo => repo_name
|
218
225
|
assert_presence_of user, repo
|
219
226
|
normalize! params
|
220
227
|
filter! ['anon'], params
|
@@ -247,7 +254,7 @@ module Github
|
|
247
254
|
# :public => true, :has_issues => true
|
248
255
|
#
|
249
256
|
def edit(user_name, repo_name, params={})
|
250
|
-
|
257
|
+
set :user => user_name, :repo => repo_name
|
251
258
|
assert_presence_of user, repo
|
252
259
|
|
253
260
|
normalize! params
|
@@ -264,7 +271,7 @@ module Github
|
|
264
271
|
# github.repos.get 'user-name', 'repo-name'
|
265
272
|
#
|
266
273
|
def get(user_name, repo_name, params={})
|
267
|
-
|
274
|
+
set :user => user_name, :repo => repo_name
|
268
275
|
assert_presence_of user, repo
|
269
276
|
normalize! params
|
270
277
|
|
@@ -280,7 +287,7 @@ module Github
|
|
280
287
|
# github.repos.languages 'user-name', 'repo-name' { |lang| ... }
|
281
288
|
#
|
282
289
|
def languages(user_name, repo_name, params={})
|
283
|
-
|
290
|
+
set :user => user_name, :repo => repo_name
|
284
291
|
assert_presence_of user, repo
|
285
292
|
normalize! params
|
286
293
|
|
@@ -337,7 +344,7 @@ module Github
|
|
337
344
|
# github.repos.tags 'user-name', 'repo-name' { |tag| ... }
|
338
345
|
#
|
339
346
|
def tags(user_name, repo_name, params={})
|
340
|
-
|
347
|
+
set :user => user_name, :repo => repo_name
|
341
348
|
assert_presence_of user, repo
|
342
349
|
normalize! params
|
343
350
|
|
@@ -357,7 +364,7 @@ module Github
|
|
357
364
|
# github.repos.teams 'user-name', 'repo-name' { |team| ... }
|
358
365
|
#
|
359
366
|
def teams(user_name, repo_name, params={})
|
360
|
-
|
367
|
+
set :user => user_name, :repo => repo_name
|
361
368
|
assert_presence_of user, repo
|
362
369
|
normalize! params
|
363
370
|
|
@@ -13,7 +13,7 @@ module Github
|
|
13
13
|
# collaborators.add 'user', 'repo', 'collaborator'
|
14
14
|
#
|
15
15
|
def add(user_name, repo_name, collaborator, params={})
|
16
|
-
|
16
|
+
set :user => user_name, :repo => repo_name
|
17
17
|
assert_presence_of user, repo, collaborator
|
18
18
|
normalize! params
|
19
19
|
|
@@ -28,7 +28,7 @@ module Github
|
|
28
28
|
# github.collaborators.collaborator?('user', 'repo', 'collaborator')
|
29
29
|
#
|
30
30
|
def collaborator?(user_name, repo_name, collaborator, params={})
|
31
|
-
|
31
|
+
set :user => user_name, :repo => repo_name
|
32
32
|
assert_presence_of user, repo, collaborator
|
33
33
|
normalize! params
|
34
34
|
|
@@ -46,7 +46,7 @@ module Github
|
|
46
46
|
# github.repos.collaborators.list 'user-name', 'repo-name' { |cbr| .. }
|
47
47
|
#
|
48
48
|
def list(user_name, repo_name, params={})
|
49
|
-
|
49
|
+
set :user => user_name, :repo => repo_name
|
50
50
|
assert_presence_of user, repo
|
51
51
|
normalize! params
|
52
52
|
|
@@ -63,7 +63,7 @@ module Github
|
|
63
63
|
# github.repos.collaborators.remove 'user', 'repo', 'collaborator'
|
64
64
|
#
|
65
65
|
def remove(user_name, repo_name, collaborator, params={})
|
66
|
-
|
66
|
+
set :user => user_name, :repo => repo_name
|
67
67
|
assert_presence_of collaborator
|
68
68
|
normalize! params
|
69
69
|
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Github
|
4
|
+
class Repos::Comments < API
|
5
|
+
|
6
|
+
REQUIRED_COMMENT_PARAMS = %w[
|
7
|
+
body
|
8
|
+
commit_id
|
9
|
+
line
|
10
|
+
path
|
11
|
+
position
|
12
|
+
].freeze
|
13
|
+
|
14
|
+
# List commit comments for a repository
|
15
|
+
#
|
16
|
+
# = Examples
|
17
|
+
# github = Github.new
|
18
|
+
# github.repos.comments.list 'user-name', 'repo-name'
|
19
|
+
# github.repos.comments.list 'user-name', 'repo-name' { |com| ... }
|
20
|
+
#
|
21
|
+
# List comments for a single commit
|
22
|
+
#
|
23
|
+
# = Examples
|
24
|
+
# github.repos.comments.list 'user-name', 'repo-name',
|
25
|
+
# :sha => '6dcb09b5b57875f334f61aebed695e2e4193db5e'
|
26
|
+
#
|
27
|
+
def list(user_name, repo_name, params={})
|
28
|
+
set :user => user_name, :repo => repo_name
|
29
|
+
assert_presence_of user, repo
|
30
|
+
normalize! params
|
31
|
+
|
32
|
+
response = if (sha = params.delete('sha'))
|
33
|
+
get_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
|
34
|
+
else
|
35
|
+
get_request("/repos/#{user}/#{repo}/comments", params)
|
36
|
+
end
|
37
|
+
return response unless block_given?
|
38
|
+
response.each { |el| yield el }
|
39
|
+
end
|
40
|
+
alias :all :list
|
41
|
+
|
42
|
+
# Gets a single commit comment
|
43
|
+
#
|
44
|
+
# = Examples
|
45
|
+
# github = Github.new
|
46
|
+
# github.repos.comments.get 'user-name', 'repo-name', 'comment-id'
|
47
|
+
#
|
48
|
+
def get(user_name, repo_name, comment_id, params={})
|
49
|
+
set :user => user_name, :repo => repo_name
|
50
|
+
assert_presence_of user, repo, comment_id
|
51
|
+
normalize! params
|
52
|
+
|
53
|
+
get_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
54
|
+
end
|
55
|
+
alias :find :get
|
56
|
+
|
57
|
+
# Creates a commit comment
|
58
|
+
#
|
59
|
+
# = Inputs
|
60
|
+
# * <tt>:body</tt> - Required string.
|
61
|
+
# * <tt>:comment_id</tt> - Required string - Sha of the commit to comment on.
|
62
|
+
# * <tt>:line</tt> - Required number - Line number in the file to comment on.
|
63
|
+
# * <tt>:path</tt> - Required string - Relative path of the file to comment on.
|
64
|
+
# * <tt>:position</tt> - Required number - Line index in the diff to comment on.
|
65
|
+
#
|
66
|
+
# = Examples
|
67
|
+
# github = Github.new
|
68
|
+
# github.repos.comments.create 'user-name', 'repo-name', 'sha-key',
|
69
|
+
# "body" => "Nice change",
|
70
|
+
# "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
71
|
+
# "line" => 1,
|
72
|
+
# "path" => "file1.txt",
|
73
|
+
# "position" => 4
|
74
|
+
#
|
75
|
+
def create(user_name, repo_name, sha, params={})
|
76
|
+
set :user => user_name, :repo => repo_name
|
77
|
+
assert_presence_of user, repo, sha
|
78
|
+
|
79
|
+
normalize! params
|
80
|
+
filter! REQUIRED_COMMENT_PARAMS, params
|
81
|
+
|
82
|
+
assert_required_keys(REQUIRED_COMMENT_PARAMS, params)
|
83
|
+
|
84
|
+
post_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Update a commit comment
|
88
|
+
#
|
89
|
+
# = Inputs
|
90
|
+
# * <tt>:body</tt> - Required string.
|
91
|
+
#
|
92
|
+
# = Examples
|
93
|
+
# github = Github.new
|
94
|
+
# github.repos.comments.update 'user-name', 'repo-name',
|
95
|
+
# 'comment-id', "body" => "Nice change"
|
96
|
+
#
|
97
|
+
def update(user_name, repo_name, comment_id, params={})
|
98
|
+
set :user => user_name, :repo => repo_name
|
99
|
+
assert_presence_of user, repo, comment_id
|
100
|
+
normalize! params
|
101
|
+
assert_required_keys(%w[ body ], params)
|
102
|
+
|
103
|
+
patch_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Deletes a commit comment
|
107
|
+
#
|
108
|
+
# = Examples
|
109
|
+
# github = Github.new
|
110
|
+
# github.repos.comments.delete 'user-name', 'repo-name', 'comment-id'
|
111
|
+
#
|
112
|
+
def delete(user_name, repo_name, comment_id, params={})
|
113
|
+
set :user => user_name, :repo => repo_name
|
114
|
+
assert_presence_of user, repo, comment_id
|
115
|
+
normalize! params
|
116
|
+
|
117
|
+
delete_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
118
|
+
end
|
119
|
+
|
120
|
+
end # Repos::Comments
|
121
|
+
end # Github
|
@@ -3,183 +3,62 @@
|
|
3
3
|
module Github
|
4
4
|
class Repos::Commits < API
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
# = Examples
|
64
|
-
# github = Github.new
|
65
|
-
# github.repos.commits.delete_comment 'user-name', 'repo-name', 'comment-id'
|
66
|
-
#
|
67
|
-
def delete_comment(user_name, repo_name, comment_id, params={})
|
68
|
-
_update_user_repo_params(user_name, repo_name)
|
69
|
-
assert_presence_of user, repo, comment_id
|
70
|
-
normalize! params
|
71
|
-
|
72
|
-
delete_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
73
|
-
end
|
74
|
-
|
75
|
-
# List commits on a repository
|
76
|
-
#
|
77
|
-
# = Parameters
|
78
|
-
# * <tt>:sha</tt> Optional string. Sha or branch to start listing commits from.
|
79
|
-
# * <tt>:path</tt> Optional string. Only commits containing this file path will be returned.
|
80
|
-
# * <tt>:author</tt> GitHub login, name, or email by which to filter by commit author.
|
81
|
-
#
|
82
|
-
# = Examples
|
83
|
-
# github = Github.new
|
84
|
-
# github.repos.commits.list 'user-name', 'repo-name', :sha => '...'
|
85
|
-
# github.repos.commits.list 'user-name', 'repo-name', :sha => '...' { |commit| ... }
|
86
|
-
#
|
87
|
-
def list(user_name, repo_name, params={})
|
88
|
-
_update_user_repo_params(user_name, repo_name)
|
89
|
-
assert_presence_of user, repo
|
90
|
-
normalize! params
|
91
|
-
filter! %w[sha path author], params
|
92
|
-
|
93
|
-
response = get_request("/repos/#{user}/#{repo}/commits", params)
|
94
|
-
return response unless block_given?
|
95
|
-
response.each { |el| yield el }
|
96
|
-
end
|
97
|
-
alias :all :list
|
98
|
-
|
99
|
-
# List commit comments for a repository
|
100
|
-
#
|
101
|
-
# = Examples
|
102
|
-
# github = Github.new
|
103
|
-
# github.repos.commits.repo_comments 'user-name', 'repo-name'
|
104
|
-
# github.repos.commits.repo_comments 'user-name', 'repo-name' { |com| ... }
|
105
|
-
#
|
106
|
-
def repo_comments(user_name, repo_name, params={})
|
107
|
-
_update_user_repo_params(user_name, repo_name)
|
108
|
-
assert_presence_of user, repo
|
109
|
-
normalize! params
|
110
|
-
|
111
|
-
response = get_request("/repos/#{user}/#{repo}/comments", params)
|
112
|
-
return response unless block_given?
|
113
|
-
response.each { |el| yield el }
|
114
|
-
end
|
115
|
-
alias :list_repo_comments :repo_comments
|
116
|
-
alias :list_repository_comments :repo_comments
|
117
|
-
|
118
|
-
# List comments for a single commit
|
119
|
-
#
|
120
|
-
# = Examples
|
121
|
-
# github = Github.new
|
122
|
-
# github.repos.commits.commit_comments 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed695e2e4193db5e'
|
123
|
-
#
|
124
|
-
def commit_comments(user_name, repo_name, sha, params={})
|
125
|
-
_update_user_repo_params(user_name, repo_name)
|
126
|
-
assert_presence_of user, repo, sha
|
127
|
-
normalize! params
|
128
|
-
|
129
|
-
response = get_request("/repos/#{user}/#{repo}/commits/#{sha}/comments", params)
|
130
|
-
return response unless block_given?
|
131
|
-
response.each { |el| yield el }
|
132
|
-
end
|
133
|
-
alias :list_commit_comments :commit_comments
|
134
|
-
|
135
|
-
# Gets a single commit
|
136
|
-
#
|
137
|
-
# = Examples
|
138
|
-
# @github = Github.new
|
139
|
-
# @github.repos.commits.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
|
140
|
-
#
|
141
|
-
def get(user_name, repo_name, sha, params={})
|
142
|
-
_update_user_repo_params(user_name, repo_name)
|
143
|
-
assert_presence_of user, repo, sha
|
144
|
-
normalize! params
|
145
|
-
|
146
|
-
get_request("/repos/#{user}/#{repo}/commits/#{sha}", params)
|
147
|
-
end
|
148
|
-
alias :find :get
|
149
|
-
|
150
|
-
# Gets a single commit comment
|
151
|
-
#
|
152
|
-
# = Examples
|
153
|
-
# github = Github.new
|
154
|
-
# github.repos.commits.commit_comment 'user-name', 'repo-name', 'comment-id'
|
155
|
-
#
|
156
|
-
def commit_comment(user_name, repo_name, comment_id, params={})
|
157
|
-
_update_user_repo_params(user_name, repo_name)
|
158
|
-
assert_presence_of user, repo, comment_id
|
159
|
-
normalize! params
|
160
|
-
|
161
|
-
get_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
162
|
-
end
|
163
|
-
alias :get_commit_comment :commit_comment
|
164
|
-
|
165
|
-
# Update a commit comment
|
166
|
-
#
|
167
|
-
# = Inputs
|
168
|
-
# * <tt>:body</tt> - Required string.
|
169
|
-
#
|
170
|
-
# = Examples
|
171
|
-
# github = Github.new
|
172
|
-
# github.repos.commits.update_comment 'user-name', 'repo-name',
|
173
|
-
# 'comment-id', "body" => "Nice change"
|
174
|
-
#
|
175
|
-
def update_comment(user_name, repo_name, comment_id, params={})
|
176
|
-
_update_user_repo_params(user_name, repo_name)
|
177
|
-
assert_presence_of user, repo, comment_id
|
178
|
-
normalize! params
|
179
|
-
assert_required_keys(%w[ body ], params)
|
180
|
-
|
181
|
-
patch_request("/repos/#{user}/#{repo}/comments/#{comment_id}", params)
|
182
|
-
end
|
6
|
+
# List commits on a repository
|
7
|
+
#
|
8
|
+
# = Parameters
|
9
|
+
# * <tt>:sha</tt> Optional string. Sha or branch to start listing commits from.
|
10
|
+
# * <tt>:path</tt> Optional string. Only commits containing this file path will be returned.
|
11
|
+
# * <tt>:author</tt> GitHub login, name, or email by which to filter by commit author.
|
12
|
+
#
|
13
|
+
# = Examples
|
14
|
+
# github = Github.new
|
15
|
+
# github.repos.commits.list 'user-name', 'repo-name', :sha => '...'
|
16
|
+
# github.repos.commits.list 'user-name', 'repo-name', :sha => '...' { |commit| ... }
|
17
|
+
#
|
18
|
+
def list(user_name, repo_name, params={})
|
19
|
+
set :user => user_name, :repo => repo_name
|
20
|
+
assert_presence_of user, repo
|
21
|
+
normalize! params
|
22
|
+
filter! %w[sha path author], params
|
23
|
+
|
24
|
+
response = get_request("/repos/#{user}/#{repo}/commits", params)
|
25
|
+
return response unless block_given?
|
26
|
+
response.each { |el| yield el }
|
27
|
+
end
|
28
|
+
alias :all :list
|
29
|
+
|
30
|
+
# Gets a single commit
|
31
|
+
#
|
32
|
+
# = Examples
|
33
|
+
# github = Github.new
|
34
|
+
# github.repos.commits.get 'user-name', 'repo-name', '6dcb09b5b57875f334f61aebed6')
|
35
|
+
#
|
36
|
+
def get(user_name, repo_name, sha, params={})
|
37
|
+
set :user => user_name, :repo => repo_name
|
38
|
+
assert_presence_of user, repo, sha
|
39
|
+
normalize! params
|
40
|
+
|
41
|
+
get_request("/repos/#{user}/#{repo}/commits/#{sha}", params)
|
42
|
+
end
|
43
|
+
alias :find :get
|
44
|
+
|
45
|
+
# Compares two commits
|
46
|
+
#
|
47
|
+
# = Examples
|
48
|
+
# github = Github.new
|
49
|
+
# github.repos.commits.compare
|
50
|
+
# 'user-name',
|
51
|
+
# 'repo-name',
|
52
|
+
# 'v0.4.8',
|
53
|
+
# 'master'
|
54
|
+
#
|
55
|
+
def compare(user_name, repo_name, base, head, params={})
|
56
|
+
set :user => user_name, :repo => repo_name
|
57
|
+
assert_presence_of base, head
|
58
|
+
normalize! params
|
59
|
+
|
60
|
+
get_request("/repos/#{user_name}/#{repo_name}/compare/#{base}...#{head}", params)
|
61
|
+
end
|
183
62
|
|
184
63
|
end # Repos::Commits
|
185
64
|
end # Github
|