Class: Git::Diff
Overview
object that holds the diff between two commits
Defined Under Namespace
Classes: DiffFile
Instance Attribute Summary collapse
Instance Method Summary collapse
- #[](key)
- #deletions
- #each(&block)
-
#initialize(base, from = nil, to = nil) ⇒ Diff
constructor
A new instance of Diff.
- #insertions
- #lines
-
#name_status
DEPRECATED METHODS.
- #patch (also: #to_s)
- #path(path)
- #size
- #stats
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 && from.to_s @to = to && to.to_s @path = nil @full_diff_files = nil end |
Instance Attribute Details
#from (readonly)
Returns the value of attribute from.
19 20 21 |
# File 'lib/git/diff.rb', line 19 def from @from end |
#to (readonly)
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
62 63 64 65 |
# File 'lib/git/diff.rb', line 62 def deletions Git::Deprecation.warn("Git::Diff#deletions is deprecated. Use Git::Base#diff_stats(...).deletions instead.") stats_provider.deletions end |
#each(&block)
36 37 38 39 |
# File 'lib/git/diff.rb', line 36 def each(&block) process_full @full_diff_files.map { |file| file[1] }.each(&block) end |
#insertions
67 68 69 70 |
# File 'lib/git/diff.rb', line 67 def insertions Git::Deprecation.warn("Git::Diff#insertions is deprecated. Use Git::Base#diff_stats(...).insertions instead.") stats_provider.insertions end |
#lines
57 58 59 60 |
# File 'lib/git/diff.rb', line 57 def lines Git::Deprecation.warn("Git::Diff#lines is deprecated. Use Git::Base#diff_stats(...).lines instead.") stats_provider.lines end |
#name_status
DEPRECATED METHODS
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
72 73 74 75 76 77 78 79 |
# File 'lib/git/diff.rb', line 72 def stats Git::Deprecation.warn("Git::Diff#stats is deprecated. Use Git::Base#diff_stats instead.") # CORRECTED: Re-create the original hash structure for backward compatibility { files: stats_provider.files, total: stats_provider.total } end |