blob: 5e923b9e6025dbee61939d277db2a9b1b38642cf (
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
57
58
59
60
61
|
module Gitlab
module Diff
module Formatters
class BaseFormatter
attr_reader :old_path
attr_reader :new_path
attr_reader :base_sha
attr_reader :start_sha
attr_reader :head_sha
attr_reader :position_type
def initialize(attrs)
if diff_file = attrs[:diff_file]
attrs[:diff_refs] = diff_file.diff_refs
attrs[:old_path] = diff_file.old_path
attrs[:new_path] = diff_file.new_path
end
if diff_refs = attrs[:diff_refs]
attrs[:base_sha] = diff_refs.base_sha
attrs[:start_sha] = diff_refs.start_sha
attrs[:head_sha] = diff_refs.head_sha
end
@old_path = attrs[:old_path]
@new_path = attrs[:new_path]
@base_sha = attrs[:base_sha]
@start_sha = attrs[:start_sha]
@head_sha = attrs[:head_sha]
end
def key
[base_sha, start_sha, head_sha, Digest::SHA1.hexdigest(old_path || ""), Digest::SHA1.hexdigest(new_path || "")]
end
def to_h
{
base_sha: base_sha,
start_sha: start_sha,
head_sha: head_sha,
old_path: old_path,
new_path: new_path,
position_type: position_type
}
end
def position_type
raise NotImplementedError
end
def ==(other)
raise NotImplementedError
end
def complete?
raise NotImplementedError
end
end
end
end
end
|