@@ -74,6 +74,9 @@ def git_copy_repo(newroot, remote=None, *, verbose=True):
74
74
remote = SRCDIR
75
75
if os .path .exists (newroot ):
76
76
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 )
77
80
_run_cmd ([GIT , '-C' , newroot , 'reset' ], verbose = verbose )
78
81
_run_cmd ([GIT , '-C' , newroot , 'checkout' , '.' ], verbose = verbose )
79
82
_run_cmd ([GIT , '-C' , newroot , 'pull' , '-f' , remote ], verbose = verbose )
@@ -87,10 +90,15 @@ def git_copy_repo(newroot, remote=None, *, verbose=True):
87
90
for line in text .splitlines ():
88
91
_ , _ , relfile = line .strip ().partition (' ' )
89
92
relfile = relfile .strip ()
93
+ isdir = relfile .endswith (os .path .sep )
94
+ relfile = relfile .rstrip (os .path .sep )
90
95
srcfile = os .path .join (reporoot , relfile )
91
96
dstfile = os .path .join (newroot , relfile )
92
97
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 )
94
102
95
103
96
104
##################################
0 commit comments