# HG changeset patch # User Milka Kuzminski # Date 2021-03-04 21:08:18 # Node ID 174761730e24e171bec2e5909470983ca22daa17 # Parent 6f8e3276054b6f7d6c63348a2a5e7360db9483d9 ssh: allow clone by ID via SSH operations. diff --git a/rhodecode/apps/ssh_support/lib/backends/__init__.py b/rhodecode/apps/ssh_support/lib/backends/__init__.py --- a/rhodecode/apps/ssh_support/lib/backends/__init__.py +++ b/rhodecode/apps/ssh_support/lib/backends/__init__.py @@ -89,6 +89,14 @@ class SshWrapper(object): return conn + def maybe_translate_repo_uid(self, repo_name): + if repo_name.startswith('_'): + from rhodecode.model.repo import RepoModel + by_id_match = RepoModel().get_repo_by_id(repo_name) + if by_id_match: + repo_name = by_id_match.repo_name + return repo_name + def get_repo_details(self, mode): vcs_type = mode if mode in ['svn', 'hg', 'git'] else None repo_name = None @@ -97,14 +105,14 @@ class SshWrapper(object): hg_match = re.match(hg_pattern, self.command) if hg_match is not None: vcs_type = 'hg' - repo_name = hg_match.group(1).strip('/') + 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) if git_match is not None: vcs_type = 'git' - repo_name = git_match.group(2).strip('/') + repo_name = self.maybe_translate_repo_uid(git_match.group(2).strip('/')) mode = git_match.group(1) return vcs_type, repo_name, mode