Skip to content

Commit da184c5

Browse files
committed
Remove the prelude saving logic for git diff
1 parent 7541bb2 commit da184c5

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

codeclash/tournaments/utils/git_utils.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def filter_git_diff(diff: str) -> str:
1010
out: list[str] = []
1111
block: list[str] = []
1212
in_block = False
13-
prelude_copied = False
1413

1514
def is_binary_block(bl: list[str]) -> bool:
1615
for ln in bl:
@@ -41,14 +40,10 @@ def extract_file_path_from_block(bl: list[str]) -> str:
4140
else:
4241
out.extend(block)
4342
block = []
44-
else:
45-
if not prelude_copied:
46-
prelude_copied = True
4743
in_block = True
4844
if in_block:
4945
block.append(ln)
50-
else:
51-
out.append(ln)
46+
5247

5348
if in_block and block:
5449
if is_binary_block(block):
@@ -124,15 +119,11 @@ def split_git_diff_by_files(diff: str) -> dict[str, str]:
124119
current_file = None
125120
current_block = []
126121

127-
# Store any prelude (content before first diff --git line)
128-
prelude = []
129-
found_first_diff = False
130-
131122
for line in lines:
132123
if line.startswith("diff --git "):
133124
# Save previous file's diff if we have one
134125
if current_file and current_block:
135-
files_diffs[current_file] = "".join(prelude + current_block)
126+
files_diffs[current_file] = "".join(current_block)
136127
current_block = []
137128

138129
# Extract file path from the diff line
@@ -149,16 +140,12 @@ def split_git_diff_by_files(diff: str) -> dict[str, str]:
149140
current_file = "unknown_file"
150141

151142
current_block.append(line)
152-
found_first_diff = True
153-
else:
154-
if found_first_diff and current_file:
155-
current_block.append(line)
156-
else:
157-
# This is prelude content before any diff
158-
prelude.append(line)
143+
elif current_file:
144+
current_block.append(line)
145+
159146

160147
# Handle the last file
161148
if current_file and current_block:
162-
files_diffs[current_file] = "".join(prelude + current_block)
149+
files_diffs[current_file] = "".join(current_block)
163150

164151
return files_diffs

0 commit comments

Comments
 (0)