Esempio n. 1
0
def clone(url, path):
    """Clone a repository."""
    adapter = None
    if url[:4] == "git@" or url[-4:] == ".git":
        adapter = Git(path)

    if adapter is None:
        raise RepositoryAdapterNotFound("Can't find adapter for `%s` repository url" % url)

    adapter.clone(url)
Esempio n. 2
0
class TestGit(unittest.TestCase):
    """Git adapter test suite."""
    sandbox = None
    git = None

    def setUp(self):
        """Set up git adapter and sandbox."""
        self.sandbox = Sandbox()
        self.sandbox.mkdir("repo")

        self.git = Git(os.path.join(self.sandbox.path, "repo"))
        self.git.execute = Mock(return_value=None)

    def tearDown(self):
        """Unset test object."""
        self.sandbox.destroy()
        self.git = None

    def test_status(self):
        """Test git status."""
        self.git.status()
        self.git.execute.assert_called_once_with(
            "git status",
            os.path.join(self.sandbox.path, "repo"))

    def test_update(self):
        """Test git update."""
        self.git.update()
        self.git.execute.assert_called_once_with(
            "git pull --rebase",
            os.path.join(self.sandbox.path, "repo"))

    def test_clone(self):
        """Test git status."""
        self.git.clone("[email protected]:foo/bar")
        self.git.execute.assert_called_once_with(
            "git clone %s %s" % (
                "[email protected]:foo/bar",
                os.path.join(self.sandbox.path, "repo")))
Esempio n. 3
0
def clone(url, path):
    """Clone a repository."""
    adapter = None
    if url[:4] == "git@" or url[-4:] == ".git":
        adapter = Git(path)
    if url[:6] == "svn://":
        adapter = Svn(path)
    if url[:6] == "bzr://":
        adapter = Bzr(path)
    if url[:9] == "ssh://hg@":
        adapter = Hg(path)

    if adapter is None:
        raise RepositoryAdapterNotFound(
            "Can't find adapter for `%s` repository url" % url)

    return adapter.clone(url)