def test_GitRepo_ssh_pull(remote_path, repo_path): from datalad import ssh_manager remote_repo = GitRepo(remote_path, create=True) url = "ssh://localhost" + op.abspath(remote_path) socket_path = op.join(ssh_manager.socket_dir, get_connection_hash('localhost')) repo = GitRepo(repo_path, create=True) repo.add_remote("ssh-remote", url) # modify remote: remote_repo.checkout("ssh-test", ['-b']) with open(op.join(remote_repo.path, "ssh_testfile.dat"), "w") as f: f.write("whatever") remote_repo.add("ssh_testfile.dat") remote_repo.commit("ssh_testfile.dat added.") # file is not locally known yet: assert_not_in("ssh_testfile.dat", repo.get_indexed_files()) # pull changes: repo.pull(remote="ssh-remote", refspec=remote_repo.get_active_branch()) ok_clean_git(repo.path, annex=False) # the connection is known to the SSH manager, since fetch() requested it: assert_in(socket_path, ssh_manager._connections) # and socket was created: ok_(op.exists(socket_path)) # we actually pulled the changes assert_in("ssh_testfile.dat", repo.get_indexed_files())
def test_GitRepo_ssh_pull(remote_path, repo_path): from datalad import ssh_manager remote_repo = GitRepo(remote_path, create=True) url = "ssh://localhost" + op.abspath(remote_path) socket_path = op.join(ssh_manager.socket_dir, get_connection_hash('localhost')) repo = GitRepo(repo_path, create=True) repo.add_remote("ssh-remote", url) # modify remote: remote_repo.checkout("ssh-test", ['-b']) with open(op.join(remote_repo.path, "ssh_testfile.dat"), "w") as f: f.write("whatever") remote_repo.add("ssh_testfile.dat") remote_repo.commit("ssh_testfile.dat added.") # file is not locally known yet: assert_not_in("ssh_testfile.dat", repo.get_indexed_files()) # pull changes: repo.pull(remote="ssh-remote", refspec=remote_repo.get_active_branch()) ok_clean_git(repo.path, annex=False) # the connection is known to the SSH manager, since fetch() requested it: assert_in(socket_path, ssh_manager._connections) # and socket was created: ok_(op.exists(socket_path)) # we actually pulled the changes assert_in("ssh_testfile.dat", repo.get_indexed_files())
def test_GitRepo_ssh_push(repo_path, remote_path): from datalad import ssh_manager remote_repo = GitRepo(remote_path, create=True) url = "ssh://localhost" + abspath(remote_path) socket_path = opj(ssh_manager.socket_dir, get_connection_hash('localhost')) repo = GitRepo(repo_path, create=True) repo.add_remote("ssh-remote", url) # modify local repo: repo.checkout("ssh-test", ['-b']) with open(opj(repo.path, "ssh_testfile.dat"), "w") as f: f.write("whatever") repo.add("ssh_testfile.dat") repo.commit("ssh_testfile.dat added.") # file is not known to the remote yet: assert_not_in("ssh_testfile.dat", remote_repo.get_indexed_files()) # push changes: pushed = repo.push(remote="ssh-remote", refspec="ssh-test") # test PushInfo object for assert_in("ssh-remote/ssh-test", [commit.remote_ref.name for commit in pushed]) # the connection is known to the SSH manager, since fetch() requested it: assert_in(socket_path, ssh_manager._connections) # and socket was created: ok_(exists(socket_path)) # remote now knows the changes: assert_in("ssh-test", remote_repo.get_branches()) assert_in("ssh_testfile.dat", remote_repo.get_files("ssh-test"))
def test_GitRepo_ssh_push(repo_path, remote_path): from datalad import ssh_manager remote_repo = GitRepo(remote_path, create=True) url = "ssh://localhost" + op.abspath(remote_path) socket_path = op.join(ssh_manager.socket_dir, get_connection_hash('localhost')) repo = GitRepo(repo_path, create=True) repo.add_remote("ssh-remote", url) # modify local repo: repo.checkout("ssh-test", ['-b']) with open(op.join(repo.path, "ssh_testfile.dat"), "w") as f: f.write("whatever") repo.add("ssh_testfile.dat") repo.commit("ssh_testfile.dat added.") # file is not known to the remote yet: assert_not_in("ssh_testfile.dat", remote_repo.get_indexed_files()) # push changes: pushed = repo.push(remote="ssh-remote", refspec="ssh-test") # test PushInfo object for assert_in("ssh-remote/ssh-test", [commit.remote_ref.name for commit in pushed]) # the connection is known to the SSH manager, since fetch() requested it: assert_in(socket_path, ssh_manager._connections) # and socket was created: ok_(op.exists(socket_path)) # remote now knows the changes: assert_in("ssh-test", remote_repo.get_branches()) assert_in("ssh_testfile.dat", remote_repo.get_files("ssh-test")) # amend to make it require "--force": repo.commit("amended", options=['--amend']) # push without --force should yield an error: pushed = repo.push(remote="ssh-remote", refspec="ssh-test") assert_in("[rejected] (non-fast-forward)", pushed[0].summary) # now push using force: repo.push(remote="ssh-remote", refspec="ssh-test", force=True) # correct commit message in remote: assert_in("amended", list(remote_repo.get_branch_commits('ssh-test'))[-1].summary)
def test_GitRepo_ssh_push(repo_path, remote_path): from datalad import ssh_manager remote_repo = GitRepo(remote_path, create=True) url = "ssh://localhost" + op.abspath(remote_path) socket_path = op.join(ssh_manager.socket_dir, get_connection_hash('localhost')) repo = GitRepo(repo_path, create=True) repo.add_remote("ssh-remote", url) # modify local repo: repo.checkout("ssh-test", ['-b']) with open(op.join(repo.path, "ssh_testfile.dat"), "w") as f: f.write("whatever") repo.add("ssh_testfile.dat") repo.commit("ssh_testfile.dat added.") # file is not known to the remote yet: assert_not_in("ssh_testfile.dat", remote_repo.get_indexed_files()) # push changes: pushed = repo.push(remote="ssh-remote", refspec="ssh-test") # test PushInfo object for assert_in("ssh-remote/ssh-test", [commit.remote_ref.name for commit in pushed]) # the connection is known to the SSH manager, since fetch() requested it: assert_in(socket_path, ssh_manager._connections) # and socket was created: ok_(op.exists(socket_path)) # remote now knows the changes: assert_in("ssh-test", remote_repo.get_branches()) assert_in("ssh_testfile.dat", remote_repo.get_files("ssh-test")) # amend to make it require "--force": repo.commit("amended", options=['--amend']) # push without --force should yield an error: pushed = repo.push(remote="ssh-remote", refspec="ssh-test") assert_in("[rejected] (non-fast-forward)", pushed[0].summary) # now push using force: repo.push(remote="ssh-remote", refspec="ssh-test", force=True) # correct commit message in remote: assert_in("amended", list(remote_repo.get_branch_commits('ssh-test'))[-1].summary)
def test_GitRepo_ssh_fetch(remote_path, repo_path): from datalad import ssh_manager remote_repo = GitRepo(remote_path, create=False) url = "ssh://localhost" + op.abspath(remote_path) socket_path = op.join(ssh_manager.socket_dir, get_connection_hash('localhost')) repo = GitRepo(repo_path, create=True) repo.add_remote("ssh-remote", url) # we don't know any branches of the remote: eq_([], repo.get_remote_branches()) fetched = repo.fetch(remote="ssh-remote") assert_in('ssh-remote/master', [commit.name for commit in fetched]) ok_clean_git(repo) # the connection is known to the SSH manager, since fetch() requested it: assert_in(socket_path, ssh_manager._connections) # and socket was created: ok_(op.exists(socket_path)) # we actually fetched it: assert_in('ssh-remote/master', repo.get_remote_branches())
def test_GitRepo_ssh_fetch(remote_path, repo_path): from datalad import ssh_manager remote_repo = GitRepo(remote_path, create=False) url = "ssh://localhost" + abspath(remote_path) socket_path = opj(ssh_manager.socket_dir, get_connection_hash('localhost')) repo = GitRepo(repo_path, create=True) repo.add_remote("ssh-remote", url) # we don't know any branches of the remote: eq_([], repo.get_remote_branches()) fetched = repo.fetch(remote="ssh-remote") assert_in('ssh-remote/master', [commit.name for commit in fetched]) ok_clean_git(repo) # the connection is known to the SSH manager, since fetch() requested it: assert_in(socket_path, ssh_manager._connections) # and socket was created: ok_(exists(socket_path)) # we actually fetched it: assert_in('ssh-remote/master', repo.get_remote_branches())