Class: Git::Diff
- Inherits:
-
Object
show all
- Includes:
- Enumerable
- Defined in:
- lib/git/diff.rb
Overview
object that holds the diff between two commits
Defined Under Namespace
Classes: DiffFile, FullDiffParser
Instance Attribute Summary collapse
-
#from
readonly
Returns the value of attribute from.
-
#to
readonly
Returns the value of attribute to.
Instance Method Summary
collapse
Constructor Details
#initialize(base, from = nil, to = nil) ⇒ Diff
Returns a new instance of Diff.
11
12
13
14
15
16
17
18
|
# File 'lib/git/diff.rb', line 11
def initialize(base, from = nil, to = nil)
@base = base
@from = from&.to_s
@to = to&.to_s
@path = nil
@full_diff_files = nil
end
|
Instance Attribute Details
#from
Returns the value of attribute from.
19
20
21
|
# File 'lib/git/diff.rb', line 19
def from
@from
end
|
#to
Returns the value of attribute to.
19
20
21
|
# File 'lib/git/diff.rb', line 19
def to
@to
end
|
Instance Method Details
#[](key)
31
32
33
34
|
# File 'lib/git/diff.rb', line 31
def [](key)
process_full
@full_diff_files.assoc(key)[1]
end
|
#deletions
57
58
59
|
# File 'lib/git/diff.rb', line 57
def deletions
stats_provider.deletions
end
|
#each
36
37
38
39
|
# File 'lib/git/diff.rb', line 36
def each(&)
process_full
@full_diff_files.map { |file| file[1] }.each(&)
end
|
#insertions
61
62
63
|
# File 'lib/git/diff.rb', line 61
def insertions
stats_provider.insertions
end
|
#lines
53
54
55
|
# File 'lib/git/diff.rb', line 53
def lines
stats_provider.lines
end
|
#name_status
49
50
51
|
# File 'lib/git/diff.rb', line 49
def name_status
path_status_provider.to_h
end
|
#patch
Also known as:
to_s
26
27
28
|
# File 'lib/git/diff.rb', line 26
def patch
@base.lib.diff_full(@from, @to, { path_limiter: @path })
end
|
#path(path)
21
22
23
24
|
# File 'lib/git/diff.rb', line 21
def path(path)
@path = path
self
end
|
#size
41
42
43
|
# File 'lib/git/diff.rb', line 41
def size
stats_provider.total[:files]
end
|
#stats
65
66
67
68
69
70
|
# File 'lib/git/diff.rb', line 65
def stats
{
files: stats_provider.files,
total: stats_provider.total
}
end
|