forked from StellarFlow-Network/stellarflow-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolve_easy.py
More file actions
43 lines (37 loc) · 1.11 KB
/
Copy pathresolve_easy.py
File metadata and controls
43 lines (37 loc) · 1.11 KB
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
40
41
42
43
import os
import glob
def resolve_file(filepath, strategy):
with open(filepath, 'r') as f:
content = f.read()
out = []
lines = content.split('\n')
i = 0
while i < len(lines):
if lines[i].startswith('<<<<<<<'):
head = []
upstream = []
i += 1
while not lines[i].startswith('======='):
head.append(lines[i])
i += 1
i += 1
while not lines[i].startswith('>>>>>>>'):
upstream.append(lines[i])
i += 1
if strategy == 'ours':
out.extend(head)
elif strategy == 'theirs':
out.extend(upstream)
else:
out.append(lines[i])
i += 1
with open(filepath, 'w') as f:
f.write('\n'.join(out))
resolve_file('src/auth.rs', 'theirs')
resolve_file('src/governance.rs', 'theirs')
# Resolving test snapshots with ours
for file in glob.glob('test_snapshots/**/*.json', recursive=True):
try:
resolve_file(file, 'ours')
except Exception:
pass