Skip to content

Commit 33401c3

Browse files
committed
Fixed git.blob.Blob.blame function which would return the text-per-commit as individual characters
1 parent 4c39f9d commit 33401c3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/git/blob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def blame(cls, repo, commit, file):
135135
m = re.search(r'^\t(.*)$', line)
136136
text, = m.groups()
137137
blames[-1][0] = c
138-
blames[-1][1] += text
138+
blames[-1][1].append( text )
139139
info = None
140140

141141
return blames

test/git/test_blob.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def test_should_display_blame_information(self, git):
6969
git.return_value = fixture('blame')
7070
b = Blob.blame(self.repo, 'master', 'lib/git.py')
7171
assert_equal(13, len(b))
72+
assert_equal( 2, len(b[0]) )
7273
# assert_equal(25, reduce(lambda acc, x: acc + len(x[-1]), b))
7374
assert_equal(hash(b[0][0]), hash(b[9][0]))
7475
c = b[0][0]
@@ -83,6 +84,13 @@ def test_should_display_blame_information(self, git):
8384
assert_equal('tom@mojombo.com', c.committer.email)
8485
assert_equal(time.gmtime(1191997100), c.committed_date)
8586
assert_equal('initial grit setup', c.message)
87+
88+
# test the 'lines per commit' entries
89+
tlist = b[0][1]
90+
assert_true( tlist )
91+
assert_true( isinstance( tlist[0], basestring ) )
92+
assert_true( len( tlist ) < sum( len(t) for t in tlist ) ) # test for single-char bug
93+
8694

8795
def test_should_return_appropriate_representation(self):
8896
blob = Blob(self.repo, **{'id': 'abc'})

0 commit comments

Comments
 (0)