Skip to content

Commit 761b6ff

Browse files
committed
fix: un-deprecate Git::Diff methods
These methods were deprecated with the same thinking that the Git::Log methods were deprecated. However, where Git::Log is a query builder, Git::Diff is (mostly) not... it is a facade over diff, diff_stats, and diff_path_stats. A problem remains with the Git::Diff class in that if you call the #path method after retrieving results, the results are not updated which may cause unexpected results. I'll consider what changes should be made to the Git::Diff class at a later date.
1 parent 5f29124 commit 761b6ff

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/git/diff.rb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,38 +38,31 @@ def each(&)
3838
@full_diff_files.map { |file| file[1] }.each(&)
3939
end
4040

41+
def size
42+
stats_provider.total[:files]
43+
end
44+
4145
#
4246
# DEPRECATED METHODS
4347
#
4448

4549
def name_status
46-
Git::Deprecation.warn('Git::Diff#name_status is deprecated. Use Git::Base#diff_path_status instead.')
4750
path_status_provider.to_h
4851
end
4952

50-
def size
51-
Git::Deprecation.warn('Git::Diff#size is deprecated. Use Git::Base#diff_stats(...).total[:files] instead.')
52-
stats_provider.total[:files]
53-
end
54-
5553
def lines
56-
Git::Deprecation.warn('Git::Diff#lines is deprecated. Use Git::Base#diff_stats(...).lines instead.')
5754
stats_provider.lines
5855
end
5956

6057
def deletions
61-
Git::Deprecation.warn('Git::Diff#deletions is deprecated. Use Git::Base#diff_stats(...).deletions instead.')
6258
stats_provider.deletions
6359
end
6460

6561
def insertions
66-
Git::Deprecation.warn('Git::Diff#insertions is deprecated. Use Git::Base#diff_stats(...).insertions instead.')
6762
stats_provider.insertions
6863
end
6964

7065
def stats
71-
Git::Deprecation.warn('Git::Diff#stats is deprecated. Use Git::Base#diff_stats instead.')
72-
# CORRECTED: Re-create the original hash structure for backward compatibility
7366
{
7467
files: stats_provider.files,
7568
total: stats_provider.total

0 commit comments

Comments
 (0)