Exemplo n.º 1
0
    def test_get_scm(self):
        """Test get scm for a repository."""
        self.sandbox.mkdir("git_repo")
        self.sandbox.mkdir("git_repo/.git")

        repo = Repository("%s/git_repo" % self.sandbox.path)
        self.assertEqual("Git", repo.get_scm())
Exemplo n.º 2
0
    def show_workspace(self, name):
        """Show specific workspace."""
        if not self.workspace.exists(name):
            raise ValueError("Workspace `%s` doesn't exists." % name)

        color = Color()
        workspaces = self.workspace.list()

        self.logger.info("<== %s workspace ==>" % color.colored(name, "green"))
        self.logger.info("\tPath: %s" % workspaces[name]["path"])
        self.logger.info("\tNumber of repositories: %s"
                         % color.colored(
                             len(workspaces[name]["repositories"]),
                             "yellow"))

        repo_colored = color.colored("Repositories", "blue")
        path_colored = color.colored("Path", "blue")
        trepositories = PrettyTable(
            [repo_colored, path_colored, color.colored("+", "blue")])
        trepositories.align[repo_colored] = "l"
        trepositories.align[path_colored] = "l"

        for repo_name in workspaces[name]["repositories"]:
            fullname = "%s/%s" % (name, repo_name)
            fullpath = find_path(fullname, self.config)[fullname]
            try:
                repo = Repository(fullpath)
                repo_scm = repo.get_scm()
            except RepositoryAdapterNotFound:
                repo_scm = None
            trepositories.add_row(
                [color.colored(repo_name, "cyan"), fullpath, repo_scm])

        self.logger.info(trepositories)
Exemplo n.º 3
0
    def test_get_svn_scm(self):
        """Test get scm for a repository."""
        self.sandbox.mkdir("svn_repo")
        self.sandbox.mkdir("svn_repo/.svn")

        repo = Repository("%s/svn_repo" % self.sandbox.path)
        self.assertEqual("Svn", repo.get_scm())
Exemplo n.º 4
0
    def test_get_hg_scm(self):
        """Test get scm for a mercurial repository."""
        self.sandbox.mkdir("hg_repo")
        self.sandbox.mkdir("hg_repo/.hg")

        repo = Repository("%s/hg_repo" % self.sandbox.path)
        self.assertEqual("Hg", repo.get_scm())
Exemplo n.º 5
0
    def test_get_bzr_scm(self):
        """Test get scm for a bzr repository."""
        self.sandbox.mkdir("bzr_repo")
        self.sandbox.mkdir("bzr_repo/.bzr")

        repo = Repository("%s/bzr_repo" % self.sandbox.path)
        self.assertEqual("Bzr", repo.get_scm())
Exemplo n.º 6
0
    def test_get_scm_none(self):
        """Test get scm for a repository when adapter is None."""
        self.sandbox.mkdir("git_repo")
        self.sandbox.mkdir("git_repo/.git")

        repo = Repository("%s/git_repo" % self.sandbox.path)
        repo.adapter = None
        self.assertEqual(None, repo.get_scm())
Exemplo n.º 7
0
 def print_update(self, repo_name, repo_path):
     """Print repository update."""
     color = Color()
     self.logger.info(color.colored(
         "=> [%s] %s" % (repo_name, repo_path), "green"))
     try:
         repo = Repository(repo_path)
         repo.update()
     except RepositoryError as e:
         self.logger.error(e)
         pass
     print("\n")
Exemplo n.º 8
0
 def print_status(self, repo_name, repo_path):
     """Print repository status."""
     color = Color()
     try:
         repo = Repository(repo_path)
         self.logger.info(color.colored(
             "=> [%s] %s" % (repo_name, repo_path), "green"))
         repo.status()
         self.logger.info("\n")
     except ValueError as e:
         self.logger.error(e)
         pass