@@ -73,7 +73,13 @@ def _all_fnames(root_dir):
73
73
return fnames
74
74
75
75
76
- def sync_dirs (source_dir , dest_dir , ignore_dot_git = True , update_git = True ):
76
+ def sync_dirs (
77
+ source_dir ,
78
+ dest_dir ,
79
+ ignore_dot_git = True ,
80
+ update_git = True ,
81
+ sync_stat_metadata = False ,
82
+ ):
77
83
"""Sync the contents of source_dir to dest_dir.
78
84
79
85
By default, this function ignores `.git` directories and will update the git index
@@ -89,6 +95,9 @@ def sync_dirs(source_dir, dest_dir, ignore_dot_git=True, update_git=True):
89
95
Ignore .git directories, by default True
90
96
update_git : bool, optional
91
97
Update the git index via `git add` and `git rm`, by default True
98
+ sync_stat_metadata : bool, optional
99
+ If True, synchronize the file/directory permissions, access/modification
100
+ times, and flags in addition to the contents. Default is False.
92
101
"""
93
102
os .makedirs (dest_dir , exist_ok = True )
94
103
@@ -137,6 +146,9 @@ def sync_dirs(source_dir, dest_dir, ignore_dot_git=True, update_git=True):
137
146
cwd = dest_dir ,
138
147
)
139
148
149
+ if sync_stat_metadata :
150
+ shutil .copystat (src_fname , dest_fname )
151
+
140
152
141
153
def _chmod_plus_rw (file_or_dir , skip_on_error = False ):
142
154
try :
0 commit comments