Skip to content

Commit 0fd13b5

Browse files
Merge pull request #5240 from studavekar/retry-on-clone-failure
Add retry to handle git clone failure
2 parents 23d201c + cdd29b8 commit 0fd13b5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/test/examples/examples_lib.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def source_repos(config, examples):
169169

170170
subprocess.call(["mbed-cli", "import", repo_info['repo']])
171171

172-
def clone_repos(config, examples):
172+
def clone_repos(config, examples , retry = 3):
173173
""" Clones each of the repos associated with the specific examples name from the
174174
json config file. Note if there is already a clone of the repo then it will first
175175
be removed to ensure a clean, up to date cloning.
@@ -185,8 +185,11 @@ def clone_repos(config, examples):
185185
if os.path.exists(name):
186186
print("'%s' example directory already exists. Deleting..." % name)
187187
rmtree(name)
188-
189-
subprocess.call([repo_info['type'], "clone", repo_info['repo']])
188+
for i in range(0, retry):
189+
if subprocess.call([repo_info['type'], "clone", repo_info['repo']]) == 0:
190+
break
191+
else:
192+
print("ERROR : unable to clone the repo {}".format(name))
190193

191194
def deploy_repos(config, examples):
192195
""" If the example directory exists as provided by the json config file,

0 commit comments

Comments
 (0)