Skip to content
Snippets Groups Projects
Verified Commit 30bebc10 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Get commit diff using "git diff" instead of comparing files of trees manually

parent 2fb9e33b
No related branches found
No related tags found
No related merge requests found
PATH
remote: .
specs:
gitlab-grit (2.6.8)
gitlab-grit (2.6.9)
charlock_holmes (~> 0.6)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
Loading
Loading
== 2.6.9
* Fix commit diff issue. It shows empty diff for commit when files have changed mode
== 2.6.8
* Fix problem with generating archives
 
Loading
Loading
2.6.8
2.6.9
Loading
Loading
@@ -146,7 +146,7 @@ module Grit
# GITLAB patch
# Skip all garbage unless we get real commit
while !lines.empty? && lines.first !~ /^commit [a-zA-Z0-9]*$/
lines.shift
lines.shift
end
 
id = lines.shift.split.last
Loading
Loading
@@ -214,8 +214,8 @@ module Grit
diff = @repo.git.show({:full_index => true, :pretty => 'raw'}, @id)
end
 
if diff =~ /diff --git "?a/
diff = diff.sub(/.+?(diff --git "?a)/m, '\1')
if diff =~ /diff --git a/
diff = diff.sub(/.*?(diff --git a)/m, '\1')
else
diff = ''
end
Loading
Loading
@@ -228,11 +228,7 @@ module Grit
#
# Returns Grit::Diff[] (baked)
def diffs(options = {})
if parents.empty?
show
else
self.class.diff(@repo, parents.first.id, @id, [], options)
end
show
end
 
def stats
Loading
Loading
Loading
Loading
@@ -91,7 +91,7 @@ class TestCommit < Test::Unit::TestCase
def test_diffs
# git diff --full-index 91169e1f5fa4de2eaea3f176461f5dc784796769 > test/fixtures/diff_p
 
Git.any_instance.expects(:diff).returns(fixture('diff_p'))
Git.any_instance.expects(:native).returns(fixture('diff_p'))
@c = Commit.create(@r, :id => '91169e1f5fa4de2eaea3f176461f5dc784796769')
diffs = @c.diffs
 
Loading
Loading
@@ -150,7 +150,7 @@ class TestCommit < Test::Unit::TestCase
end
 
def test_diffs_with_mode_only_change
Git.any_instance.expects(:diff).returns(fixture('diff_mode_only'))
Git.any_instance.expects(:native).returns(fixture('diff_mode_only'))
@c = Commit.create(@r, :id => '91169e1f5fa4de2eaea3f176461f5dc784796769')
diffs = @c.diffs
 
Loading
Loading
@@ -160,11 +160,7 @@ class TestCommit < Test::Unit::TestCase
end
 
def test_diffs_with_options
Git.any_instance.expects(:diff).
with({:full_index => true, :M => true},
'038af8c329ef7c1bae4568b98bd5c58510465493',
'91169e1f5fa4de2eaea3f176461f5dc784796769').
returns(fixture('diff_mode_only'))
Git.any_instance.expects(:native).returns(fixture('diff_mode_only'))
@c = Commit.create(@r, :id => '91169e1f5fa4de2eaea3f176461f5dc784796769')
@c.diffs :M => true
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment