2017-04-12 21:42:12 -04:00
|
|
|
module Github
|
|
|
|
module Representation
|
|
|
|
class Comment < Representation::Base
|
|
|
|
def note
|
|
|
|
raw['body'] || ''
|
|
|
|
end
|
|
|
|
|
|
|
|
def author
|
2017-04-19 19:04:58 -04:00
|
|
|
@author ||= Github::Representation::User.new(raw['user'], options)
|
2017-04-12 21:42:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def commit_id
|
|
|
|
raw['commit_id']
|
|
|
|
end
|
|
|
|
|
|
|
|
def line_code
|
|
|
|
return unless on_diff?
|
|
|
|
|
|
|
|
parsed_lines = Gitlab::Diff::Parser.new.parse(diff_hunk.lines)
|
|
|
|
generate_line_code(parsed_lines.to_a.last)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def generate_line_code(line)
|
2017-10-10 13:44:14 -04:00
|
|
|
Gitlab::Git.diff_line_code(file_path, line.new_pos, line.old_pos)
|
2017-04-12 21:42:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def on_diff?
|
|
|
|
diff_hunk.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def diff_hunk
|
2017-04-13 15:24:55 -04:00
|
|
|
raw['diff_hunk']
|
2017-04-12 21:42:12 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def file_path
|
2017-04-13 15:24:55 -04:00
|
|
|
raw['path']
|
2017-04-12 21:42:12 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|