Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14cef2b

Browse files
jelmerempty
authored andcommitted
Avoid stripping newlines in blob data.
(cherry picked from commit ccca12ee26e40fb4c4df2d77154ed496144569b9)
1 parentd3ce120 commit14cef2b

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

‎lib/git/blob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def data(self):
5757
Returns
5858
str
5959
"""
60-
self.data_stored=self.data_storedorself.repo.git.cat_file(self.id,**{'p':True})
60+
self.data_stored=self.data_storedorself.repo.git.cat_file(self.id,**{'p':True,'with_raw_output':True})
6161
returnself.data_stored
6262

6363
@property

‎test/fixtures/cat_file_blob_nl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world

‎test/git/test_blob.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ def test_should_return_blob_contents(self, git):
1818
blob=Blob(self.repo,**{'id':'abc'})
1919
assert_equal("Hello world",blob.data)
2020
assert_true(git.called)
21-
assert_equal(git.call_args, (('cat_file','abc'), {'p':True}))
21+
assert_equal(git.call_args, (('cat_file','abc'), {'p':True,'with_raw_output':True}))
22+
23+
@patch(Git,'_call_process')
24+
deftest_should_return_blob_contents_with_newline(self,git):
25+
git.return_value=fixture('cat_file_blob_nl')
26+
blob=Blob(self.repo,**{'id':'abc'})
27+
assert_equal("Hello world\n",blob.data)
28+
assert_true(git.called)
29+
assert_equal(git.call_args, (('cat_file','abc'), {'p':True,'with_raw_output':True}))
2230

2331
@patch(Git,'_call_process')
2432
deftest_should_cache_data(self,git):
@@ -28,7 +36,7 @@ def test_should_cache_data(self, git):
2836
blob.data
2937
assert_true(git.called)
3038
assert_equal(git.call_count,1)
31-
assert_equal(git.call_args, (('cat_file','abc'), {'p':True}))
39+
assert_equal(git.call_args, (('cat_file','abc'), {'p':True,'with_raw_output':True}))
3240

3341
@patch(Git,'_call_process')
3442
deftest_should_return_file_size(self,git):

‎test/git/test_repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_blob(self, git):
107107
assert_equal("Hello world",blob.data)
108108

109109
assert_true(git.called)
110-
assert_equal(git.call_args, (('cat_file','abc'), {'p':True}))
110+
assert_equal(git.call_args, (('cat_file','abc'), {'p':True,'with_raw_output':True}))
111111

112112
@patch(Repo,'__init__')
113113
@patch(Git,'_call_process')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp