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
60
61
62
63
|
# File 'lib/git/diff.rb', line 60
def deletions
Git::Deprecation.warn('Git::Diff#deletions is deprecated. Use Git::Base#diff_stats(...).deletions instead.')
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
65
66
67
68
|
# File 'lib/git/diff.rb', line 65
def insertions
Git::Deprecation.warn('Git::Diff#insertions is deprecated. Use Git::Base#diff_stats(...).insertions instead.')
stats_provider.insertions
end
|
#lines
55
56
57
58
|
# File 'lib/git/diff.rb', line 55
def lines
Git::Deprecation.warn('Git::Diff#lines is deprecated. Use Git::Base#diff_stats(...).lines instead.')
stats_provider.lines
end
|
#name_status
45
46
47
48
|
# File 'lib/git/diff.rb', line 45
def name_status
Git::Deprecation.warn('Git::Diff#name_status is deprecated. Use Git::Base#diff_path_status instead.')
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
50
51
52
53
|
# File 'lib/git/diff.rb', line 50
def size
Git::Deprecation.warn('Git::Diff#size is deprecated. Use Git::Base#diff_stats(...).total[:files] instead.')
stats_provider.total[:files]
end
|
#stats
70
71
72
73
74
75
76
77
|
# File 'lib/git/diff.rb', line 70
def stats
Git::Deprecation.warn('Git::Diff#stats is deprecated. Use Git::Base#diff_stats instead.')
{
files: stats_provider.files,
total: stats_provider.total
}
end
|