@@ -197,22 +197,30 @@ def pull_request_comment(repo, comment_id, options = {})
197
197
# @param body [String] Comment content
198
198
# @param commit_id [String] Sha of the commit to comment on.
199
199
# @param path [String] Relative path of the file to comment on.
200
- # @param line [Integer] Line index in the diff to comment on.
200
+ # @param line [Integer] Optional line index in the diff to comment on.
201
201
# For a multi-line comment, the last line of the range
202
202
# and specify 'start_line' in the 'options'.
203
+ # If not specified, the comment will be on the whole file.
203
204
# @return [Sawyer::Resource] Hash representing the new comment
204
205
# @deprecated The position will be deprecated in the next major version. Please refer to the details below.
205
206
# @see https://developer.github.com/v3/pulls/comments/#create-a-comment
206
207
# @example
207
208
# @client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
208
209
# "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
209
- def create_pull_request_comment ( repo , pull_id , body , commit_id , path , line , options = { } )
210
- options . merge! ( {
211
- body : body ,
212
- commit_id : commit_id ,
213
- path : path ,
214
- line : line
215
- } )
210
+ def create_pull_request_comment ( repo , pull_id , body , commit_id , path , line = nil , options = { } )
211
+ comment = {
212
+ body : body ,
213
+ commit_id : commit_id ,
214
+ path : path
215
+ }
216
+
217
+ if line . nil?
218
+ comment [ :subject_type ] = 'file'
219
+ else
220
+ comment [ :line ] = line
221
+ end
222
+
223
+ options . merge! comment
216
224
post "#{ Repository . path repo } /pulls/#{ pull_id } /comments" , options
217
225
end
218
226
alias create_pull_comment create_pull_request_comment
0 commit comments