Example #1
0
    def testPullRepoFromNamedRemote(self):
        """Test if it is possible to pull from a remote repository, which is not called origin."""
        graphContent = """
            <http://ex.org/x> <http://ex.org/y> <http://ex.org/z> <http://example.org/> ."""
        with TemporaryRepositoryFactory().withGraph("http://example.org/",
                                                    graphContent) as remote:
            with TemporaryRepository(False) as local:
                local.remotes.create("upstream", remote.path)
                quitRepo = quit.git.Repository(local.workdir)

                self.assertFalse(remote.is_empty)
                self.assertTrue(local.is_empty)
                self.assertTrue(quitRepo.is_empty)

                remoteHead = remote.revparse_single('HEAD').hex

                with self.assertRaises(RevisionNotFound):
                    quitRepo.revision('HEAD')

                quitRepo.pull(remote_name='upstream', refspec="master")

                self.assertEqual(quitRepo.revision('HEAD').id, remoteHead)

                self.assertFalse(remote.is_empty)
                self.assertFalse(local.is_empty)
                self.assertFalse(quitRepo.is_empty)
Example #2
0
    def testPullRepoWithUnbornHead(self):
        """Test if it is possible to pull from a remote repository."""
        graphContent = """
            <http://ex.org/x> <http://ex.org/y> <http://ex.org/z> <http://example.org/> ."""
        with TemporaryRepositoryFactory().withGraph("http://example.org/",
                                                    graphContent) as remote:
            with TemporaryRepository(False) as local:
                local.remotes.create("origin", remote.path)
                quitRepo = quit.git.Repository(local.workdir)

                self.assertFalse(remote.is_empty)
                self.assertTrue(local.is_empty)
                self.assertTrue(quitRepo.is_empty)

                remoteHead = remote.revparse_single('HEAD').hex

                with self.assertRaises(RevisionNotFound):
                    quitRepo.revision('HEAD')

                quitRepo.pull()

                self.assertEqual(
                    quitRepo.revision('origin/master').id, remoteHead)

                self.assertFalse(remote.is_empty)
                self.assertFalse(local.is_empty)
                self.assertFalse(quitRepo.is_empty)
Example #3
0
    def testFetchUpstreamRepo(self):
        """Test if it is possible to from from a remote, which set as upstream."""
        graphContent = """
            <http://ex.org/x> <http://ex.org/x> <http://ex.org/x> <http://example.org/> ."""
        with TemporaryRepositoryFactory().withGraph("http://example.org/",
                                                    graphContent) as remote:
            with TemporaryRepository(clone_from_repo=remote) as local:
                quitRepo = quit.git.Repository(local.workdir)

                self.assertFalse(remote.is_empty)
                self.assertFalse(local.is_empty)
                self.assertFalse(quitRepo.is_empty)

                with open(path.join(remote.workdir, "graph.nq"),
                          "a") as graphFile:
                    graphContent = """
                        <http://ex.org/x> <http://ex.org/y> <http://ex.org/z> <http://example.org/> ."""
                    graphFile.write(graphContent)

                createCommit(repository=remote)

                remoteHead = remote.revparse_single('HEAD').hex
                localHead = local.revparse_single('HEAD').hex

                self.assertNotEqual(localHead, remoteHead)

                quitRepo.fetch()

                self.assertEqual(
                    quitRepo.revision('origin/master').id, remoteHead)

                self.assertFalse(remote.is_empty)
                self.assertFalse(local.is_empty)
                self.assertFalse(quitRepo.is_empty)
Example #4
0
    def testPushRepoWithRemoteName(self):
        """Test if it is possible to push to a remote repository, which is not called orign."""
        with TemporaryRepository(True) as remote:
            graphContent = "<http://ex.org/x> <http://ex.org/y> <http://ex.org/z> <http://example.org/> ."
            with TemporaryRepositoryFactory().withGraph(
                    "http://example.org/", graphContent) as local:
                local.remotes.create("upstream", remote.path)
                quitRepo = quit.git.Repository(local.workdir)

                self.assertTrue(remote.is_empty)
                self.assertFalse(local.is_empty)

                quitRepo.push("upstream", "master")

                self.assertFalse(remote.is_empty)
                self.assertFalse(local.is_empty)
Example #5
0
    def testPushRepo(self):
        """Test if it is possible to push to an empty remote repository."""
        with TemporaryRepository(True) as remote:
            graphContent = """
                <http://ex.org/x> <http://ex.org/y> <http://ex.org/z> ."""
            with TemporaryRepositoryFactory().withGraph(
                    "http://example.org/", graphContent) as local:
                local.remotes.create("origin", remote.path)
                quitRepo = quit.git.Repository(local.workdir)

                self.assertTrue(remote.is_empty)
                self.assertFalse(local.is_empty)

                quitRepo.push("origin", "master")

                self.assertFalse(remote.is_empty)
                self.assertFalse(local.is_empty)
Example #6
0
    def testPushRepoNotConfiguredNamedRemote(self):
        """Test if the push failes if the specified remote was not defined."""
        with TemporaryRepository(is_bare=True) as remote:
            graphContent = """
                <http://ex.org/x> <http://ex.org/y> <http://ex.org/z> <http://example.org/> ."""
            with TemporaryRepositoryFactory().withGraph(
                    "http://example.org/", graphContent) as local:
                local.remotes.create("origin", remote.path)
                quitRepo = quit.git.Repository(local.workdir)

                self.assertTrue(remote.is_empty)
                self.assertFalse(local.is_empty)

                with self.assertRaises(RemoteNotFound):
                    quitRepo.push("upstream", "master")

                self.assertTrue(remote.is_empty)
                self.assertFalse(local.is_empty)
Example #7
0
    def testPullRepoFromNotConfiguredRemote(self):
        """Test if it is possible to pull from a remote repository, which is not called origin."""
        graphContent = """
            <http://ex.org/x> <http://ex.org/y> <http://ex.org/z> <http://example.org/> ."""
        with TemporaryRepositoryFactory().withGraph("http://example.org/",
                                                    graphContent) as remote:
            with TemporaryRepository(False) as local:
                local.remotes.create("origin", remote.path)
                quitRepo = quit.git.Repository(local.workdir)

                self.assertFalse(remote.is_empty)
                self.assertTrue(local.is_empty)
                self.assertTrue(quitRepo.is_empty)

                with self.assertRaises(RemoteNotFound):
                    quitRepo.pull(remote_name='upstream')

                self.assertFalse(remote.is_empty)
                self.assertTrue(local.is_empty)
                self.assertTrue(quitRepo.is_empty)