-
Notifications
You must be signed in to change notification settings - Fork 287
Expand file tree
/
Copy pathdelta.rb
More file actions
66 lines (52 loc) · 1.29 KB
/
delta.rb
File metadata and controls
66 lines (52 loc) · 1.29 KB
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
62
63
64
65
66
# Copyright (C) the Rugged contributors. All rights reserved.
#
# This file is part of Rugged, distributed under the MIT license.
# For full terms see the included LICENSE file.
module Rugged
class Diff
class Delta
attr_reader :owner
alias diff owner
attr_reader :old_file
attr_reader :new_file
attr_reader :similarity
attr_reader :status
attr_reader :status_char
attr_reader :binary
alias binary? binary
def added?
status == :added
end
def deleted?
status == :deleted
end
def modified?
status == :modified
end
def renamed?
status == :renamed
end
def copied?
status == :copied
end
def ignored?
status == :ignored
end
def untracked?
status == :untracked
end
def typechange?
status == :typechange
end
def old_blob
owner.owner.lookup(old_file[:oid]) unless added?
end
def new_blob
owner.owner.lookup(new_file[:oid]) unless deleted?
end
def inspect
"#<#{self.class.name}:#{object_id} {old_file: #{old_file.inspect}, new_file: #{new_file.inspect}, similarity: #{similarity.inspect}, status: #{status.inspect}>"
end
end
end
end