github_api 0.4.11 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +76 -72
- data/features/cassettes/gists/starred.yml +48 -0
- data/features/cassettes/pagination/repos/commits/list.yml +193 -0
- data/features/cassettes/pagination/repos/commits/next.yml +183 -0
- data/features/cassettes/pagination/repos/diff/next.yml +45 -0
- data/features/cassettes/pagination/repos/list.yml +176 -0
- data/features/cassettes/pagination/repos/list/next.yml +222 -0
- data/features/cassettes/pagination/repos/per_page/each_page.yml +45 -0
- data/features/cassettes/repos/list.yml +92 -0
- data/features/error_codes.feature +1 -1
- data/features/gists.feature +12 -3
- data/features/gists/comments.feature +3 -3
- data/features/github_api.feature +13 -2
- data/features/pagination.feature +40 -39
- data/features/repos.feature +2 -2
- data/features/step_definitions/common_steps.rb +12 -0
- data/features/step_definitions/github_api_steps.rb +12 -1
- data/lib/github_api.rb +1 -1
- data/lib/github_api/api.rb +4 -2
- data/lib/github_api/api_factory.rb +11 -5
- data/lib/github_api/authorizations.rb +23 -32
- data/lib/github_api/client.rb +1 -0
- data/lib/github_api/events.rb +38 -38
- data/lib/github_api/filter.rb +1 -1
- data/lib/github_api/gists.rb +47 -42
- data/lib/github_api/gists/comments.rb +77 -84
- data/lib/github_api/git_data.rb +25 -6
- data/lib/github_api/git_data/blobs.rb +48 -45
- data/lib/github_api/git_data/commits.rb +76 -73
- data/lib/github_api/git_data/references.rb +137 -118
- data/lib/github_api/git_data/tags.rb +74 -70
- data/lib/github_api/git_data/trees.rb +88 -85
- data/lib/github_api/issues.rb +43 -31
- data/lib/github_api/issues/comments.rb +116 -119
- data/lib/github_api/issues/events.rb +20 -19
- data/lib/github_api/issues/labels.rb +200 -197
- data/lib/github_api/issues/milestones.rb +137 -134
- data/lib/github_api/orgs.rb +27 -23
- data/lib/github_api/orgs/members.rb +105 -108
- data/lib/github_api/orgs/teams.rb +236 -237
- data/lib/github_api/paged_request.rb +1 -1
- data/lib/github_api/pull_requests.rb +40 -42
- data/lib/github_api/pull_requests/comments.rb +140 -143
- data/lib/github_api/repos.rb +101 -67
- data/lib/github_api/repos/collaborators.rb +64 -68
- data/lib/github_api/repos/commits.rb +50 -39
- data/lib/github_api/repos/downloads.rb +107 -110
- data/lib/github_api/repos/forks.rb +38 -39
- data/lib/github_api/repos/hooks.rb +161 -167
- data/lib/github_api/repos/keys.rb +86 -86
- data/lib/github_api/repos/pub_sub_hubbub.rb +99 -87
- data/lib/github_api/repos/watching.rb +80 -82
- data/lib/github_api/request.rb +5 -9
- data/lib/github_api/users.rb +26 -16
- data/lib/github_api/users/emails.rb +47 -47
- data/lib/github_api/users/followers.rb +85 -86
- data/lib/github_api/users/keys.rb +73 -75
- data/lib/github_api/validations.rb +25 -0
- data/lib/github_api/validations/format.rb +23 -0
- data/lib/github_api/validations/presence.rb +25 -0
- data/lib/github_api/validations/required.rb +21 -0
- data/lib/github_api/validations/token.rb +41 -0
- data/lib/github_api/version.rb +3 -3
- data/spec/fixtures/repos/commit_comparison.json +112 -0
- data/spec/github/api_factory_spec.rb +17 -1
- data/spec/github/authorizations_spec.rb +36 -34
- data/spec/github/gists/comments_spec.rb +39 -45
- data/spec/github/gists_spec.rb +50 -53
- data/spec/github/git_data/blobs_spec.rb +27 -20
- data/spec/github/git_data/commits_spec.rb +20 -19
- data/spec/github/git_data/references_spec.rb +83 -46
- data/spec/github/git_data/tags_spec.rb +16 -15
- data/spec/github/git_data/trees_spec.rb +20 -19
- data/spec/github/git_data_spec.rb +10 -1
- data/spec/github/issues/comments_spec.rb +78 -68
- data/spec/github/issues/events_spec.rb +42 -34
- data/spec/github/issues/labels_spec.rb +89 -101
- data/spec/github/issues/milestones_spec.rb +76 -54
- data/spec/github/issues_spec.rb +53 -57
- data/spec/github/orgs/members_spec.rb +64 -49
- data/spec/github/orgs/teams_spec.rb +112 -101
- data/spec/github/orgs_spec.rb +41 -31
- data/spec/github/paged_request_spec.rb +6 -5
- data/spec/github/pull_requests/comments_spec.rb +39 -44
- data/spec/github/pull_requests_spec.rb +32 -48
- data/spec/github/repos/collaborators_spec.rb +40 -29
- data/spec/github/repos/commits_spec.rb +108 -64
- data/spec/github/repos/downloads_spec.rb +46 -45
- data/spec/github/repos/forks_spec.rb +23 -24
- data/spec/github/repos/hooks_spec.rb +69 -71
- data/spec/github/repos/keys_spec.rb +39 -34
- data/spec/github/repos/pub_sub_hubbub_spec.rb +4 -4
- data/spec/github/repos/watching_spec.rb +31 -33
- data/spec/github/repos_spec.rb +74 -83
- data/spec/github/request_spec.rb +31 -2
- data/spec/github/users/emails_spec.rb +19 -17
- data/spec/github/users/followers_spec.rb +30 -28
- data/spec/github/users/keys_spec.rb +37 -33
- data/spec/github/users_spec.rb +124 -125
- data/spec/github/validations/format_spec.rb +42 -0
- data/spec/github/validations/presence_spec.rb +18 -0
- data/spec/github/validations/required_spec.rb +28 -0
- data/spec/github/validations/token_spec.rb +19 -0
- data/spec/github/validations_spec.rb +23 -0
- metadata +33 -10
- data/features/cassettes/pagination/repos.yml +0 -177
- data/features/cassettes/pagination/repos/next.yml +0 -177
- data/lib/github_api/validation.rb +0 -53
- data/spec/github/validation_spec.rb +0 -62
@@ -7,8 +7,6 @@ module Github
|
|
7
7
|
autoload_all 'github_api/pull_requests',
|
8
8
|
:Comments => 'comments'
|
9
9
|
|
10
|
-
include Github::PullRequests::Comments
|
11
|
-
|
12
10
|
VALID_REQUEST_PARAM_NAMES = %w[
|
13
11
|
title
|
14
12
|
body
|
@@ -30,17 +28,22 @@ module Github
|
|
30
28
|
super(options)
|
31
29
|
end
|
32
30
|
|
31
|
+
# Access to PullRequests::Comments API
|
32
|
+
def comments
|
33
|
+
@comments ||= ApiFactory.new 'PullRequests::Comments'
|
34
|
+
end
|
35
|
+
|
33
36
|
# List pull requests
|
34
37
|
#
|
35
38
|
# = Examples
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
+
# github = Github.new :user => 'user-name', :repo => 'repo-name'
|
40
|
+
# github.pull_requests.list
|
41
|
+
# github.pull_requests.list { |req| ... }
|
39
42
|
#
|
40
|
-
#
|
41
|
-
#
|
43
|
+
# pull_reqs = Github::PullRequests.new
|
44
|
+
# pull_reqs.pull_requests.list 'user-name', 'repo-name'
|
42
45
|
#
|
43
|
-
def
|
46
|
+
def list(user_name, repo_name, params={})
|
44
47
|
_update_user_repo_params(user_name, repo_name)
|
45
48
|
_validate_user_repo_params(user, repo) unless (user? && repo?)
|
46
49
|
|
@@ -49,23 +52,22 @@ module Github
|
|
49
52
|
# _merge_mime_type(:pull_request, params)
|
50
53
|
_validate_params_values(VALID_REQUEST_PARAM_VALUES, params)
|
51
54
|
|
52
|
-
response =
|
55
|
+
response = get_request("/repos/#{user}/#{repo}/pulls", params)
|
53
56
|
return response unless block_given?
|
54
57
|
response.each { |el| yield el }
|
55
58
|
end
|
56
|
-
alias :
|
57
|
-
alias :requests :pull_requests
|
59
|
+
alias :all :list
|
58
60
|
|
59
61
|
# Get a single pull request
|
60
62
|
#
|
61
63
|
# = Examples
|
62
|
-
#
|
63
|
-
#
|
64
|
+
# github = Github.new
|
65
|
+
# github.pull_requests.get 'user-name', 'repo-name', 'request-id'
|
64
66
|
#
|
65
67
|
# @pull_reqs = Github::PullRequests.new
|
66
|
-
# @pull_reqs.
|
68
|
+
# @pull_reqs.get 'user-name', 'repo-name', 'request-id'
|
67
69
|
#
|
68
|
-
def
|
70
|
+
def get(user_name, repo_name, request_id, params={})
|
69
71
|
_update_user_repo_params(user_name, repo_name)
|
70
72
|
_validate_user_repo_params(user, repo) unless user? && repo?
|
71
73
|
_validate_presence_of request_id
|
@@ -73,9 +75,9 @@ module Github
|
|
73
75
|
_normalize_params_keys(params)
|
74
76
|
# _merge_mime_type(:pull_request, params)
|
75
77
|
|
76
|
-
|
78
|
+
get_request("/repos/#{user}/#{repo}/pulls/#{request_id}", params)
|
77
79
|
end
|
78
|
-
alias :
|
80
|
+
alias :find :get
|
79
81
|
|
80
82
|
# Create a pull request
|
81
83
|
#
|
@@ -92,8 +94,8 @@ module Github
|
|
92
94
|
# * <tt>issue</tt> - Required number - Issue number in this repository to turn into a Pull Request.
|
93
95
|
#
|
94
96
|
# = Examples
|
95
|
-
#
|
96
|
-
#
|
97
|
+
# github = Github.new :oauth_token => '...'
|
98
|
+
# github.pull_requests.create 'user-name', 'repo-name',
|
97
99
|
# "title" => "Amazing new feature",
|
98
100
|
# "body" => "Please pull this in!",
|
99
101
|
# "head" => "octocat:new-feature",
|
@@ -101,12 +103,12 @@ module Github
|
|
101
103
|
#
|
102
104
|
# alternatively
|
103
105
|
#
|
104
|
-
# @github.pull_requests.
|
106
|
+
# @github.pull_requests.create 'user-name', 'repo-name',
|
105
107
|
# "issue" => "5",
|
106
108
|
# "head" => "octocat:new-feature",
|
107
109
|
# "base" => "master"
|
108
110
|
#
|
109
|
-
def
|
111
|
+
def create(user_name, repo_name, params={})
|
110
112
|
_update_user_repo_params(user_name, repo_name)
|
111
113
|
_validate_user_repo_params(user, repo) unless user? && repo?
|
112
114
|
|
@@ -114,9 +116,8 @@ module Github
|
|
114
116
|
# _merge_mime_type(:pull_request, params)
|
115
117
|
_filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
|
116
118
|
|
117
|
-
|
119
|
+
post_request("/repos/#{user}/#{repo}/pulls", params)
|
118
120
|
end
|
119
|
-
alias :create_pull_request :create_request
|
120
121
|
|
121
122
|
# Update a pull request
|
122
123
|
#
|
@@ -126,13 +127,13 @@ module Github
|
|
126
127
|
# * <tt>:state</tt> - Optional string - State of this Pull Request. Valid values are <tt>open</tt> and <tt>closed</tt>.
|
127
128
|
#
|
128
129
|
# = Examples
|
129
|
-
#
|
130
|
-
#
|
130
|
+
# github = Github.new :oauth_token => '...'
|
131
|
+
# github.pull_requests.update 'user-name', 'repo-name', 'request-id'
|
131
132
|
# "title" => "Amazing new title",
|
132
133
|
# "body" => "Update body",
|
133
134
|
# "state" => "open",
|
134
135
|
#
|
135
|
-
def
|
136
|
+
def update(user_name, repo_name, request_id, params={})
|
136
137
|
_update_user_repo_params(user_name, repo_name)
|
137
138
|
_validate_user_repo_params(user, repo) unless user? && repo?
|
138
139
|
_validate_presence_of request_id
|
@@ -142,15 +143,14 @@ module Github
|
|
142
143
|
# _merge_mime_type(:pull_request, params)
|
143
144
|
_validate_params_values(VALID_REQUEST_PARAM_VALUES, params)
|
144
145
|
|
145
|
-
|
146
|
+
patch_request("/repos/#{user}/#{repo}/pulls/#{request_id}", params)
|
146
147
|
end
|
147
|
-
alias :update_pull_request :update_request
|
148
148
|
|
149
149
|
# List commits on a pull request
|
150
150
|
#
|
151
151
|
# = Examples
|
152
|
-
#
|
153
|
-
#
|
152
|
+
# github = Github.new
|
153
|
+
# github.pull_requests.commits 'user-name', 'repo-name', 'request-id'
|
154
154
|
#
|
155
155
|
def commits(user_name, repo_name, request_id, params={})
|
156
156
|
_update_user_repo_params(user_name, repo_name)
|
@@ -160,17 +160,16 @@ module Github
|
|
160
160
|
_normalize_params_keys(params)
|
161
161
|
# _merge_mime_type(:pull_request, params)
|
162
162
|
|
163
|
-
response =
|
163
|
+
response = get_request("/repos/#{user}/#{repo}/pulls/#{request_id}/commits", params)
|
164
164
|
return response unless block_given?
|
165
165
|
response.each { |el| yield el }
|
166
166
|
end
|
167
|
-
alias :request_commits :commits
|
168
167
|
|
169
168
|
# List pull requests files
|
170
169
|
#
|
171
170
|
# = Examples
|
172
|
-
#
|
173
|
-
#
|
171
|
+
# github = Github.new
|
172
|
+
# github.pull_requests.files 'user-name', 'repo-name', 'request-id'
|
174
173
|
#
|
175
174
|
def files(user_name, repo_name, request_id, params={})
|
176
175
|
_update_user_repo_params(user_name, repo_name)
|
@@ -180,17 +179,16 @@ module Github
|
|
180
179
|
_normalize_params_keys(params)
|
181
180
|
# _merge_mime_type(:pull_request, params)
|
182
181
|
|
183
|
-
response =
|
182
|
+
response = get_request("/repos/#{user}/#{repo}/pulls/#{request_id}/files", params)
|
184
183
|
return response unless block_given?
|
185
184
|
response.each { |el| yield el }
|
186
185
|
end
|
187
|
-
alias :request_files :files
|
188
186
|
|
189
187
|
# Check if pull request has been merged
|
190
188
|
#
|
191
189
|
# = Examples
|
192
|
-
#
|
193
|
-
#
|
190
|
+
# github = Github.new
|
191
|
+
# github.pull_requests.merged? 'user-name', 'repo-name', 'request-id'
|
194
192
|
#
|
195
193
|
def merged?(user_name, repo_name, request_id, params={})
|
196
194
|
_update_user_repo_params(user_name, repo_name)
|
@@ -200,7 +198,7 @@ module Github
|
|
200
198
|
_normalize_params_keys(params)
|
201
199
|
# _merge_mime_type(:pull_request, params)
|
202
200
|
|
203
|
-
|
201
|
+
get_request("/repos/#{user}/#{repo}/pulls/#{request_id}/merge", params)
|
204
202
|
true
|
205
203
|
rescue Github::Error::NotFound
|
206
204
|
false
|
@@ -212,8 +210,8 @@ module Github
|
|
212
210
|
# <tt>:commit_message</tt> - Optional string - The message that will be used for the merge commit
|
213
211
|
#
|
214
212
|
# = Examples
|
215
|
-
#
|
216
|
-
#
|
213
|
+
# github = Github.new
|
214
|
+
# github.pull_requests.merge 'user-name', 'repo-name', 'request-id'
|
217
215
|
#
|
218
216
|
def merge(user_name, repo_name, request_id, params={})
|
219
217
|
_update_user_repo_params(user_name, repo_name)
|
@@ -224,7 +222,7 @@ module Github
|
|
224
222
|
# _merge_mime_type(:pull_request, params)
|
225
223
|
_filter_params_keys(VALID_REQUEST_PARAM_NAMES, params)
|
226
224
|
|
227
|
-
|
225
|
+
put_request("/repos/#{user}/#{repo}/pulls/#{request_id}/merge", params)
|
228
226
|
end
|
229
227
|
|
230
228
|
end # PullRequests
|
@@ -1,149 +1,146 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
module Github
|
4
|
-
class PullRequests
|
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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
elsif !_validate_inputs(VALID_REQUEST_COM_PARAM_NAMES - %w[ in_reply_to ], params)
|
143
|
-
raise ArgumentError, "Required params are: #{VALID_REQUEST_COM_PARAM_NAMES.join(', ')}"
|
144
|
-
end
|
4
|
+
class PullRequests::Comments < API
|
5
|
+
|
6
|
+
VALID_REQUEST_COM_PARAM_NAMES = %w[
|
7
|
+
body
|
8
|
+
commit_id
|
9
|
+
path
|
10
|
+
position
|
11
|
+
in_reply_to
|
12
|
+
mime_type
|
13
|
+
resource
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
# List comments on a pull request
|
17
|
+
#
|
18
|
+
# = Examples
|
19
|
+
# github = Github.new
|
20
|
+
# github.pull_requests.comments.list 'user-name', 'repo-name', 'request-id'
|
21
|
+
#
|
22
|
+
def list(user_name, repo_name, request_id, params={})
|
23
|
+
_update_user_repo_params(user_name, repo_name)
|
24
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
25
|
+
_validate_presence_of request_id
|
26
|
+
|
27
|
+
_normalize_params_keys(params)
|
28
|
+
# _merge_mime_type(:pull_comment, params)
|
29
|
+
|
30
|
+
response = get_request("/repos/#{user}/#{repo}/pulls/#{request_id}/comments", params)
|
31
|
+
return response unless block_given?
|
32
|
+
response.each { |el| yield el }
|
33
|
+
end
|
34
|
+
alias :all :list
|
35
|
+
|
36
|
+
# Get a single comment for pull requests
|
37
|
+
# = Examples
|
38
|
+
# github = Github.new
|
39
|
+
# github.pull_requests.comments.get 'user-name', 'repo-name', 'comment-id'
|
40
|
+
#
|
41
|
+
def get(user_name, repo_name, comment_id, params={})
|
42
|
+
_update_user_repo_params(user_name, repo_name)
|
43
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
44
|
+
_validate_presence_of comment_id
|
45
|
+
|
46
|
+
_normalize_params_keys(params)
|
47
|
+
# _merge_mime_type(:pull_comment, params)
|
48
|
+
|
49
|
+
get_request("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
50
|
+
end
|
51
|
+
alias :find :get
|
52
|
+
|
53
|
+
# Create a pull request comment
|
54
|
+
#
|
55
|
+
# = Inputs
|
56
|
+
# * <tt>:body</tt> - Required string
|
57
|
+
# * <tt>:commit_id</tt> - Required string - sha of the commit to comment on.
|
58
|
+
# * <tt>:path</tt> - Required string - Relative path of the file to comment on.
|
59
|
+
# * <tt>:position</tt> - Required number - Line index in the diff to comment on
|
60
|
+
#
|
61
|
+
# = Examples
|
62
|
+
# github = Github.new
|
63
|
+
# github.pull_requests.comments.create 'user-name','repo-name','request-id',
|
64
|
+
# "body" => "Nice change",
|
65
|
+
# "commit_id" => "6dcb09b5b57875f334f61aebed695e2e4193db5e",
|
66
|
+
# "path" => "file1.txt",
|
67
|
+
# "position" => 4
|
68
|
+
#
|
69
|
+
# = Alternative Inputs
|
70
|
+
# Instead of passing commit_id, path, and position you can reply to
|
71
|
+
# an existing Pull Request Comment like this
|
72
|
+
# * <tt>:body</tt> - Required string
|
73
|
+
# * <tt>:in_reply_to</tt> - Required number - comment id to reply to.
|
74
|
+
#
|
75
|
+
# = Examples
|
76
|
+
# github = Github.new
|
77
|
+
# github.pull_requests.comments.create 'user-name','repo-name','request-id',
|
78
|
+
# "body" => "Nice change",
|
79
|
+
# "in_reply_to" => 4
|
80
|
+
#
|
81
|
+
def create(user_name, repo_name, request_id, params={})
|
82
|
+
_update_user_repo_params(user_name, repo_name)
|
83
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
84
|
+
_validate_presence_of request_id
|
85
|
+
|
86
|
+
_normalize_params_keys(params)
|
87
|
+
# _merge_mime_type(:pull_comment, params)
|
88
|
+
_filter_params_keys(VALID_REQUEST_COM_PARAM_NAMES, params)
|
89
|
+
# _validate_reply_to(params)
|
90
|
+
|
91
|
+
post_request("/repos/#{user}/#{repo}/pulls/#{request_id}/comments", params)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Edit a pull request comment
|
95
|
+
#
|
96
|
+
# = Inputs
|
97
|
+
# * <tt>:body</tt> - Required string
|
98
|
+
#
|
99
|
+
# = Examples
|
100
|
+
# github = Github.new
|
101
|
+
# github.pull_requests.comments.edit 'user-name', 'repo-name','comment-id',
|
102
|
+
# "body" => "Nice change"
|
103
|
+
#
|
104
|
+
def edit(user_name, repo_name, comment_id, params={})
|
105
|
+
_update_user_repo_params(user_name, repo_name)
|
106
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
107
|
+
_validate_presence_of comment_id
|
108
|
+
|
109
|
+
_normalize_params_keys(params)
|
110
|
+
# _merge_mime_type(:pull_comment, params)
|
111
|
+
_filter_params_keys(VALID_REQUEST_COM_PARAM_NAMES, params)
|
112
|
+
|
113
|
+
patch_request("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Delete a pull request comment
|
117
|
+
#
|
118
|
+
# = Examples
|
119
|
+
# github = Github.new
|
120
|
+
# github.pull_requests.comments.delete 'user-name', 'repo-name','comment-id'
|
121
|
+
#
|
122
|
+
def delete(user_name, repo_name, comment_id, params={})
|
123
|
+
_update_user_repo_params(user_name, repo_name)
|
124
|
+
_validate_user_repo_params(user, repo) unless user? && repo?
|
125
|
+
_validate_presence_of comment_id
|
126
|
+
|
127
|
+
_normalize_params_keys(params)
|
128
|
+
# _merge_mime_type(:pull_comment, params)
|
129
|
+
|
130
|
+
delete_request("/repos/#{user}/#{repo}/pulls/comments/#{comment_id}", params)
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
# To let user know that the params supplied are wrong before request is made
|
136
|
+
def _validate_reply_to(params)
|
137
|
+
if params['in_reply_to'] && !_validate_inputs(%w[ body in_reply_to ], params)
|
138
|
+
raise ArgumentError, "Required params are: #{%w[ body in_reply_to].join(',')}"
|
139
|
+
|
140
|
+
elsif !_validate_inputs(VALID_REQUEST_COM_PARAM_NAMES - %w[ in_reply_to ], params)
|
141
|
+
raise ArgumentError, "Required params are: #{VALID_REQUEST_COM_PARAM_NAMES.join(', ')}"
|
145
142
|
end
|
143
|
+
end
|
146
144
|
|
147
|
-
|
148
|
-
end # PullRequests
|
145
|
+
end # PullRequests::Comments
|
149
146
|
end # Github
|