ssh: use pre-compiled backends for faster matching of vcs detection.
This commit is contained in:
parent
14751ae9c1
commit
1f15dd1741
1 changed files with 6 additions and 7 deletions
|
|
@ -34,6 +34,9 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class SshWrapper(object):
|
||||
hg_cmd_pat = re.compile(r'^hg\s+\-R\s+(\S+)\s+serve\s+\-\-stdio$')
|
||||
git_cmd_pat = re.compile(r'^git-(receive-pack|upload-pack)\s\'[/]?(\S+?)(|\.git)\'$')
|
||||
svn_cmd_pat = re.compile(r'^svnserve -t')
|
||||
|
||||
def __init__(self, command, connection_info, mode,
|
||||
user, user_id, key_id, shell, ini_path, env):
|
||||
|
|
@ -101,24 +104,20 @@ class SshWrapper(object):
|
|||
vcs_type = mode if mode in ['svn', 'hg', 'git'] else None
|
||||
repo_name = None
|
||||
|
||||
hg_pattern = r'^hg\s+\-R\s+(\S+)\s+serve\s+\-\-stdio$'
|
||||
hg_match = re.match(hg_pattern, self.command)
|
||||
hg_match = self.hg_cmd_pat.match(self.command)
|
||||
if hg_match is not None:
|
||||
vcs_type = 'hg'
|
||||
repo_name = self.maybe_translate_repo_uid(hg_match.group(1).strip('/'))
|
||||
return vcs_type, repo_name, mode
|
||||
|
||||
git_pattern = r'^git-(receive-pack|upload-pack)\s\'[/]?(\S+?)(|\.git)\'$'
|
||||
git_match = re.match(git_pattern, self.command)
|
||||
git_match = self.git_cmd_pat.match(self.command)
|
||||
if git_match is not None:
|
||||
vcs_type = 'git'
|
||||
repo_name = self.maybe_translate_repo_uid(git_match.group(2).strip('/'))
|
||||
mode = git_match.group(1)
|
||||
return vcs_type, repo_name, mode
|
||||
|
||||
svn_pattern = r'^svnserve -t'
|
||||
svn_match = re.match(svn_pattern, self.command)
|
||||
|
||||
svn_match = self.svn_cmd_pat.match(self.command)
|
||||
if svn_match is not None:
|
||||
vcs_type = 'svn'
|
||||
# Repo name should be extracted from the input stream, we're unable to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue