Skip to content

Commit d33caab

Browse files
Update rsync excludes list (#152)
Prevent unnecessary files from being copied when rsyncing local clones of repositories by using a targeted list of items to exclude.
1 parent 2bd7d4b commit d33caab

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

github_scripts/get_git_sources.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from typing import Optional
1313
from pathlib import Path
1414
from shutil import rmtree
15+
import shlex
1516

1617

1718
def run_command(
@@ -24,7 +25,7 @@ def run_command(
2425
Outputs:
2526
- result object from subprocess.run
2627
"""
27-
command = command.split()
28+
command = shlex.split(command)
2829
result = subprocess.run(
2930
command,
3031
capture_output=True,
@@ -117,8 +118,31 @@ def sync_repo(repo_source: str, repo_ref: str, loc: Path) -> None:
117118
# Create a clean clone location
118119
loc.mkdir(parents=True)
119120

121+
exclude_dirs = (
122+
"applications/*/working",
123+
"applications/*/test",
124+
"applications/*/bin",
125+
"science/*/working",
126+
"science/*/test",
127+
"science/*/bin",
128+
"interfaces/*/working",
129+
"interfaces/*/test",
130+
"interfaces/*/bin",
131+
"components/*/working",
132+
"components/*/test",
133+
"components/*/bin",
134+
"infrastructure/*/working",
135+
"infrastructure/*/test",
136+
"infrastructure/*/bin",
137+
"mesh_tools/*/working",
138+
"mesh_tools/*/test",
139+
"mesh_tools/*/bin",
140+
)
141+
120142
# Trailing slash required for rsync
121143
command = f"rsync -av {repo_source}/ {loc}"
144+
for item in exclude_dirs:
145+
command = f"{command} --exclude '{item}'"
122146
run_command(command)
123147

124148
# Fetch the main branch from origin

0 commit comments

Comments
 (0)