Skip to content

Commit b6be674

Browse files
DanielKristofKissmiyuki
authored andcommitted
Create a shallow clone of the dependent repositories.
No need for the whole history so let's clone only the requested revision. This speeds up the clone significantly and reduce the required disk space.
1 parent 24ec16e commit b6be674

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

scripts/repos.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -263,23 +263,21 @@ def clone_repositories(checkout_path: str, tc_version: LLVMBMTC,
263263
logging.info(' - %s: %s @ %s%s', repo_path, module.branch,
264264
module.revision,
265265
' (detached)' if module.revision != 'HEAD' else '')
266+
refspec = (module.branch if module.revision == 'HEAD'
267+
else module.revision)
268+
266269
repo = git.Repo.clone_from(module.url,
267-
os.path.join(checkout_path, module.name))
268-
if module.revision == 'HEAD':
269-
try:
270-
repo.git.checkout(module.branch)
271-
except git.exc.GitCommandError as ex: # pylint: disable=no-member
272-
die('could not checkout "{}" @ "{}/{}"\n'
273-
'Git command failed with:\n{}'
274-
.format(repo_path, module.branch, module.revision, ex))
275-
else:
276-
# Detached state
277-
try:
278-
repo.git.checkout(module.revision)
279-
except git.exc.GitCommandError as ex: # pylint: disable=no-member
280-
die('could not checkout "{}" @ "{}".\n'
281-
'Git command failed with:\n{}'
282-
.format(repo_path, module.revision, ex))
270+
os.path.join(checkout_path, module.name),
271+
multi_options=[
272+
"--branch %s" % (refspec),
273+
"--depth 1"
274+
])
275+
try:
276+
repo.git.checkout(module.revision)
277+
except git.exc.GitCommandError as ex: # pylint: disable=no-member
278+
die('could not checkout "{}" @ "{}".\n'
279+
'Git command failed with:\n{}'
280+
.format(repo_path, refspec, ex))
283281

284282
patch_repositories(checkout_path, tc_version, patches)
285283

0 commit comments

Comments
 (0)