forked from Jagadeeshftw/grainlify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolve_core_conflicts.py
More file actions
39 lines (33 loc) · 936 Bytes
/
resolve_core_conflicts.py
File metadata and controls
39 lines (33 loc) · 936 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
35
36
37
38
39
import re
import glob
files = glob.glob("contracts/grainlify-core/src/*.rs")
for filepath in files:
with open(filepath, 'r') as f:
content = f.read()
lines = content.split('\n')
new_lines = []
in_head = False
in_remote = False
for line in lines:
if line.startswith('<<<<<<< HEAD'):
in_head = True
continue
elif line.startswith('======='):
if in_head:
in_head = False
in_remote = True
else:
new_lines.append(line)
continue
elif line.startswith('>>>>>>>'):
if in_remote:
in_remote = False
else:
new_lines.append(line)
continue
if in_remote:
pass
else:
new_lines.append(line)
with open(filepath, 'w') as f:
f.write('\n'.join(new_lines))