Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions vcs2l/clients/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def import_(self, command):
cmd_fetch = [GitClient._executable, 'fetch', remote]
if command.shallow:
result_version_type, version_name = self._check_version_type(
command.url, checkout_version
command.url, checkout_version, command.retry
)
if result_version_type['returncode']:
return result_version_type
Expand Down Expand Up @@ -398,7 +398,7 @@ def import_(self, command):
version_type = None
if command.version:
result_version_type, version_name = self._check_version_type(
command.url, command.version
command.url, command.version, command.retry
)
if result_version_type['returncode']:
return result_version_type
Expand Down Expand Up @@ -523,7 +523,7 @@ def _get_remote_urls(self):
'returncode': 0 if remote_urls else 1,
}

def _check_version_type(self, url, version):
def _check_version_type(self, url, version, retry=0):
# check if version starts with heads/ or tags/
prefixes = {
'heads/': 'branch',
Expand All @@ -540,7 +540,7 @@ def _check_version_type(self, url, version):
}, version[len(prefix) :]

cmd = [GitClient._executable, 'ls-remote', url, version]
result = self._run_command(cmd)
result = self._run_command(cmd, retry=retry)
if result['returncode']:
result['output'] = (
'Could not determine ref type of version: ' + result['output']
Expand Down
10 changes: 10 additions & 0 deletions vcs2l/clients/vcs_base.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import os
import socket
import subprocess
import sys
import time
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

from vcs2l.executor import ansi


class VcsClientBase(object):
type = None
Expand Down Expand Up @@ -35,6 +38,13 @@ def _not_applicable(self, command, message=None):

def _run_command(self, cmd, env=None, retry=0):
for i in range(retry + 1):
if i > 0:
print(
ansi('yellowf')
+ 'Retrying command (%d/%d): %s' % (i, retry, ' '.join(cmd))
+ ansi('reset'),
file=sys.stderr,
)
result = run_command(cmd, os.path.abspath(self.path), env=env)
if not result['returncode']:
# return successful result
Expand Down
Loading