-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathresolve_conflicts.py
More file actions
34 lines (27 loc) · 942 Bytes
/
resolve_conflicts.py
File metadata and controls
34 lines (27 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys
def resolve_conflicts(filename):
with open(filename, 'r', encoding='utf-8') as f:
lines = f.readlines()
result = []
in_conflict = False
keep_section = True
for line in lines:
if line.startswith('<<<<<<<'):
in_conflict = True
keep_section = True
continue
elif line.startswith('======='):
keep_section = False
continue
elif line.startswith('>>>>>>>'):
in_conflict = False
keep_section = True
continue
if not in_conflict or keep_section:
result.append(line)
with open(filename, 'w', encoding='utf-8') as f:
f.writelines(result)
print(f"Resolved conflicts in {filename}")
if __name__ == '__main__':
resolve_conflicts('src/app/ai-generator/page.tsx')
resolve_conflicts('src/app/api/generate-assignment/route.ts')