mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
Merge pull request #70 from nspring/git-no-rename
use --no-rename to ensure consistent behavior for shortspec on renamed files
This commit is contained in:
commit
4c28474128
3 changed files with 3 additions and 3 deletions
|
@ -41,7 +41,7 @@ module GitStats
|
||||||
end
|
end
|
||||||
|
|
||||||
def lines_count
|
def lines_count
|
||||||
@lines_count ||= repo.run("git diff --shortstat `git hash-object -t tree /dev/null` #{self.sha} -- #{repo.tree_path}").lines.map do |line|
|
@lines_count ||= repo.run("git diff --shortstat --no-renames `git hash-object -t tree /dev/null` #{self.sha} -- #{repo.tree_path}").lines.map do |line|
|
||||||
line[/(\d+) insertions?/, 1].to_i
|
line[/(\d+) insertions?/, 1].to_i
|
||||||
end.sum
|
end.sum
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ module GitStats
|
||||||
|
|
||||||
private
|
private
|
||||||
def calculate_stat
|
def calculate_stat
|
||||||
stat_line = commit.repo.run("git show --shortstat --oneline #{commit.sha} -- #{commit.repo.tree_path}").lines.to_a[1]
|
stat_line = commit.repo.run("git show --shortstat --oneline --no-renames #{commit.sha} -- #{commit.repo.tree_path}").lines.to_a[1]
|
||||||
if stat_line.blank?
|
if stat_line.blank?
|
||||||
@files_changed = @insertions = @deletions = 0
|
@files_changed = @insertions = @deletions = 0
|
||||||
else
|
else
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe GitStats::GitData::ShortStat do
|
||||||
{content: '', expect: [0, 0, 0]},
|
{content: '', expect: [0, 0, 0]},
|
||||||
].each do |test|
|
].each do |test|
|
||||||
it "#{test[:content]} parsing" do
|
it "#{test[:content]} parsing" do
|
||||||
commit.repo.should_receive(:run).with("git show --shortstat --oneline abc -- .").and_return("abc some commit\n#{test[:content]}")
|
commit.repo.should_receive(:run).with("git show --shortstat --oneline --no-renames abc -- .").and_return("abc some commit\n#{test[:content]}")
|
||||||
|
|
||||||
|
|
||||||
commit.short_stat.should be_a(GitStats::GitData::ShortStat)
|
commit.short_stat.should be_a(GitStats::GitData::ShortStat)
|
||||||
|
|
Loading…
Reference in a new issue