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:
Tomasz Gieniusz 2016-11-28 10:31:00 +01:00 committed by GitHub
commit 4c28474128
3 changed files with 3 additions and 3 deletions

View File

@ -41,7 +41,7 @@ module GitStats
end
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
end.sum
end

View File

@ -19,7 +19,7 @@ module GitStats
private
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?
@files_changed = @insertions = @deletions = 0
else

View File

@ -14,7 +14,7 @@ describe GitStats::GitData::ShortStat do
{content: '', expect: [0, 0, 0]},
].each do |test|
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)