Skip to content

Commit be908a6

Browse files
committed
Fail merge if there are any symlinks
1 parent d19d45a commit be908a6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

contrib/devtools/github-merge.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ def ask_prompt(text):
7070
print("",file=stderr)
7171
return reply
7272

73+
def get_symlink_files():
74+
files = sorted(subprocess.check_output([GIT, 'ls-tree', '--full-tree', '-r', 'HEAD']).splitlines())
75+
ret = []
76+
for f in files:
77+
if (int(f.decode('utf-8').split(" ")[0], 8) & 0o170000) == 0o120000:
78+
ret.append(f.decode('utf-8').split("\t")[1])
79+
return ret
80+
7381
def tree_sha512sum():
7482
files = sorted(subprocess.check_output([GIT, 'ls-tree', '--full-tree', '-r', '--name-only', 'HEAD']).splitlines())
7583
overall = hashlib.sha512()
@@ -200,6 +208,12 @@ def main():
200208
print("ERROR: Creating merge failed (already merged?).",file=stderr)
201209
exit(4)
202210

211+
symlink_files = get_symlink_files()
212+
for f in symlink_files;
213+
print("ERROR: File %s was a symlink" % f)
214+
if len(symlink_files) > 0:
215+
exit(4)
216+
203217
# Put tree SHA512 into the message
204218
try:
205219
first_sha512 = tree_sha512sum()

0 commit comments

Comments
 (0)