Beispiel #1
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)
Beispiel #2
0
 def test_find_path_workspace(self):
     """Test find_path for workspace."""
     res = find_path("yoda", self.config)
     self.assertEqual(4, len(res))
     self.assertIn("yoda/yoda", res)
     self.assertIn("yoda/other", res)
     self.assertIn("yoda/1337", res)
     self.assertIn("sliim/yoda", res)
Beispiel #3
0
    def execute(self, args):
        path_list = find_path(args.name, self.config, True)

        if len(path_list) == 0:
            self.logger.error("No matches for `%s`" % args.name)
            return False

        for name, path in path_list.items():
            return self.__jump(path)
Beispiel #4
0
    def print_workspace(self, name):
        """Print workspace update."""
        path_list = find_path(name, self.config)

        if len(path_list) == 0:
            self.logger.error("No matches for `%s`" % name)
            return False

        for name, path in path_list.items():
            self.print_update(name, path)
Beispiel #5
0
 def test_find_path_no_matches(self):
     """Test find_path when no matches found."""
     self.assertEqual({}, find_path("foo/bar", self.config))
Beispiel #6
0
 def test_find_path_workspace_and_repository(self):
     """Test find_path for workspace/repository."""
     res = find_path("yoda/1337", self.config)
     self.assertEqual(1, len(res))
     self.assertIn("yoda/1337", res)
Beispiel #7
0
 def test_find_path_repository(self):
     """Test find_path for repository."""
     res = find_path("other", self.config)
     self.assertEqual(1, len(res))
     self.assertIn("yoda/other", res)
Beispiel #8
0
 def test_find_path_workspace_only(self):
     """Test find_path for workspace only."""
     res = find_path("sliim", self.config, True)
     self.assertEqual(1, len(res))
     self.assertIn("sliim", res)
Beispiel #9
0
 def test_find_path_no_workspace(self):
     """Test find_path when no workspace registered."""
     self.config = Config(self.sandbox.path + "/fake-config")
     self.assertEqual({}, find_path(
         "yoda/yoda", self.config))