Skip to content

Commit 920c6de

Browse files
authored
Merge pull request #60017 from keith/ks/build-ignore-.git-in-ninja-copy
[build] Ignore .git in ninja copy
2 parents be1f429 + a61af54 commit 920c6de

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

utils/swift_build_support/swift_build_support/products/ninja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def build(self):
7777
# Ninja can only be built in-tree. Copy the source tree to the build
7878
# directory.
7979
shell.rmtree(self.build_dir)
80-
shell.copytree(self.source_dir, self.build_dir)
80+
shell.copytree(self.source_dir, self.build_dir, ignore_pattern=".git")
8181
with shell.pushd(self.build_dir):
8282
shell.call([sys.executable, 'configure.py', '--bootstrap'],
8383
env=env)

utils/swift_build_support/swift_build_support/shell.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,14 @@ def rmtree(path, dry_run=None, echo=True):
183183
shutil.rmtree(path)
184184

185185

186-
def copytree(src, dest, dry_run=None, echo=True):
186+
def copytree(src, dest, dry_run=None, ignore_pattern=None, echo=True):
187187
dry_run = _coerce_dry_run(dry_run)
188188
if dry_run or echo:
189189
_echo_command(dry_run, ['cp', '-r', src, dest])
190190
if dry_run:
191191
return
192-
shutil.copytree(src, dest)
192+
ignore = shutil.ignore_patterns(ignore_pattern) if ignore_pattern else None
193+
shutil.copytree(src, dest, ignore=ignore)
193194

194195

195196
def symlink(source, dest, dry_run=None, echo=True):

0 commit comments

Comments
 (0)