Skip to content

Commit 7338d60

Browse files
Clean up the copied repo first.
1 parent ef579ac commit 7338d60

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Tools/freeze/test/freeze.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def git_copy_repo(newroot, remote=None, *, verbose=True):
7474
remote = SRCDIR
7575
if os.path.exists(newroot):
7676
print(f'updating copied repo {newroot}...')
77+
if newroot == SRCDIR:
78+
raise Exception('this probably isn\'t what you wanted')
79+
_run_cmd([GIT, '-C', newroot, 'clean', '-d', '-f'], verbose=verbose)
7780
_run_cmd([GIT, '-C', newroot, 'reset'], verbose=verbose)
7881
_run_cmd([GIT, '-C', newroot, 'checkout', '.'], verbose=verbose)
7982
_run_cmd([GIT, '-C', newroot, 'pull', '-f', remote], verbose=verbose)
@@ -87,10 +90,15 @@ def git_copy_repo(newroot, remote=None, *, verbose=True):
8790
for line in text.splitlines():
8891
_, _, relfile = line.strip().partition(' ')
8992
relfile = relfile.strip()
93+
isdir = relfile.endswith(os.path.sep)
94+
relfile = relfile.rstrip(os.path.sep)
9095
srcfile = os.path.join(reporoot, relfile)
9196
dstfile = os.path.join(newroot, relfile)
9297
os.makedirs(os.path.dirname(dstfile), exist_ok=True)
93-
shutil.copy2(srcfile, dstfile)
98+
if isdir:
99+
shutil.copytree(srcfile, dstfile, dirs_exist_ok=True)
100+
else:
101+
shutil.copy2(srcfile, dstfile)
94102

95103

96104
##################################

0 commit comments

Comments
 (0)