Skip to content

Commit 741decd

Browse files
committed
little bugfix in commit checker
1 parent 908ead4 commit 741decd

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

tests/sourcetree.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ def check_chunks_against_future_contents(listing_contents, future_contents):
263263
f"{len(missing_lines)} lines did not match future contents"
264264
)
265265
else:
266+
print('reindented listing')
267+
print(repr(reindented_chunk))
268+
print('future contents')
269+
print(repr(future_contents))
266270
raise ApplyCommitException(f"Commit lines in wrong order (?)")
267271

268272

@@ -301,7 +305,10 @@ def split_into_chunks(code):
301305
yield chunk
302306
chunk = ""
303307
else:
304-
chunk = f"{chunk}\n{line}"
308+
if chunk:
309+
chunk = f"{chunk}\n{line}"
310+
else:
311+
chunk = line
305312

306313
if chunk:
307314
yield chunk

tests/test_sourcetree.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,25 @@ def method1(self):
825825
check_chunks_against_future_contents(code, future_contents)
826826

827827

828+
def test_leading_blank_lines_in_listing_are_ignored(self):
829+
code = dedent(
830+
"""
831+
def method1(self):
832+
# amend method 1
833+
return 2
834+
835+
"""
836+
)
837+
future_contents = dedent(
838+
"""
839+
class Thing:
840+
def method1(self):
841+
# amend method 1
842+
return 2
843+
"""
844+
).strip()
845+
check_chunks_against_future_contents(code, future_contents) # should not raise
846+
828847
def test_trailing_blank_lines_in_listing_are_ignored(self):
829848
code = dedent(
830849
"""

0 commit comments

Comments
 (0)