Skip to content
Snippets Groups Projects
Commit 2d639205 authored by Georges Racinet's avatar Georges Racinet
Browse files

git_sync: stop using SSH

This is part of heptapod#144: now that we're firing the
pre-receive hook ourselves, we don't need to go over SSH at all.

This also means that we don't need the `repositories-root`
confiuration item anymore.
parent 4c68254d
No related branches found
No related tags found
1 merge request!7git_sync without SSH
Checking pipeline status
......@@ -10,14 +10,6 @@
if dest:
return dest
repos_root = ui.config('heptapod', 'repositories-root')
if not repos_root:
raise error.Abort(_("heptapod.repositories-root not set"))
# Mercurial gives us `realpath` of repos. Therefore, if the whole
# repositories root turns out to be a symlink, we need to
# use its `realpath`, too.
repos_root = os.path.realpath(repos_root)
repo_path = repo.root
if repo_path is None:
raise error.Abort(_(
......@@ -21,5 +13,4 @@
repo_path = repo.root
if repo_path is None:
raise error.Abort(_(
'heptapod.mirror-path repository not configured, and '
'cannot find current repository filesystem path'))
......@@ -25,5 +16,4 @@
'cannot find current repository filesystem path'))
rpath = os.path.relpath(repo_path, repos_root)
if rpath.startswith(UP_DIR) or not rpath.endswith('.hg'):
if not repo_path.endswith('.hg'):
raise error.Abort(_(
'heptapod.mirror-path repository not configured, and '
......@@ -28,7 +18,7 @@
raise error.Abort(_(
'heptapod.mirror-path repository not configured, and '
'inferred relative path %r is invalid' % rpath))
return 'git+ssh://git@localhost:' + rpath.rsplit('.', 1)[0] + '.git'
'repository path %r is invalid' % repo_path))
return repo_path.rsplit('.', 1)[0] + '.git'
def mirror(ui, repo, *args, **kwargs):
......
......@@ -25,7 +25,8 @@
def test_mirror_path(tmpdir):
wrapper = init_repo(tmpdir, 'proj.hg')
repo = wrapper.repo
assert mirror_path(repo.ui, repo) == 'git+ssh://git@localhost:proj.git'
assert mirror_path(repo.ui, repo) == str(
tmpdir.join('repositories', 'proj.git'))
# now for some sabotage
repo.ui.setconfig('heptapod', 'mirror-path', None)
......@@ -39,15 +40,8 @@
assert mirror_path(ui, None) == '/hard/coded'
def test_mirror_path_no_root(tmpdir):
ui = make_ui(None)
with pytest.raises(error.Abort) as exc_info:
mirror_path(ui, None)
assert "heptapod.repositories-root not set" in exc_info.value.args[0]
def test_mirror_path_unknown(tmpdir):
wrapper = init_repo(tmpdir, 'proj.svn')
repo = wrapper.repo
with pytest.raises(error.Abort) as exc_info:
mirror_path(repo.ui, repo)
......@@ -49,9 +43,9 @@
def test_mirror_path_unknown(tmpdir):
wrapper = init_repo(tmpdir, 'proj.svn')
repo = wrapper.repo
with pytest.raises(error.Abort) as exc_info:
mirror_path(repo.ui, repo)
assert "'proj.svn' is invalid" in exc_info.value.args[0]
assert "%r is invalid" % wrapper.repo.root in exc_info.value.args[0]
def test_mirror(tmpdir):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment