blob: 7e3053e58810de60713d7f3b97486b1f45cb62c9 (
plain)
1
2
3
4
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
|
# frozen_string_literal: true
class MergeRequestDiffEntity < Grape::Entity
include Gitlab::Routing
include GitHelper
include MergeRequestsHelper
expose :version_index do |merge_request_diff|
@merge_request_diffs = options[:merge_request_diffs]
diff = options[:merge_request_diff]
next unless diff.present?
next unless @merge_request_diffs.size > 1
version_index(merge_request_diff)
end
expose :created_at
expose :commits_count
expose :latest?, as: :latest
expose :short_commit_sha do |merge_request_diff|
short_sha(merge_request_diff.head_commit_sha)
end
expose :base_version_path do |merge_request_diff|
project = merge_request.target_project
next unless project
merge_request_version_path(project, merge_request, merge_request_diff)
end
expose :version_path do |merge_request_diff|
start_sha = options[:start_sha]
project = merge_request.target_project
next unless project
merge_request_version_path(project, merge_request, merge_request_diff, start_sha)
end
expose :compare_path do |merge_request_diff|
project = merge_request.target_project
diff = options[:merge_request_diff]
if project && diff
merge_request_version_path(project, merge_request, diff, merge_request_diff.head_commit_sha)
end
end
def merge_request
options[:merge_request]
end
end
|