def print_status(self, fetch=False):
        """Print clowder repo status"""

        repo_path = os.path.join(self.root_directory, '.clowder')
        if not ProjectRepo.existing_git_repository(repo_path):
            output = colored('.clowder', 'green')
            print(output)
            return

        if not is_offline() and fetch:
            print(' - Fetch upstream changes for clowder repo')
            repo = ProjectRepo(self.clowder_path, self.remote, self.default_ref)
            repo.fetch(self.remote)

        project_output = ProjectRepo.format_project_string(repo_path, '.clowder')
        current_ref_output = ProjectRepo.format_project_ref_string(repo_path)

        clowder_symlink = os.path.join(self.root_directory, 'clowder.yaml')
        if not os.path.islink(clowder_symlink):
            print(project_output + ' ' + current_ref_output)
            return

        real_path = os.path.realpath(clowder_symlink)
        symlink_output = fmt.path('clowder.yaml')
        clowder_path = fmt.remove_prefix(real_path + '/', self.root_directory)
        path_output = fmt.path(clowder_path[1:-1])
        print(project_output + ' ' + current_ref_output)
        print(symlink_output + ' -> ' + path_output + '\n')
Exemple #2
0
    def fetch_all(self):
        """Fetch upstream changes if project exists on disk"""

        repo = ProjectRepo(self.full_path(), self.remote, self.ref)
        if self.fork is None:
            repo.fetch(self.remote, depth=self.depth)
            return

        repo.fetch(self.fork.remote_name)
        repo.fetch(self.remote)
Exemple #3
0
    def branch(self, local=False, remote=False):
        """Print branches for project"""

        if not os.path.isdir(self.full_path()):
            print(colored(" - Project is missing\n", 'red'))
            return

        repo = ProjectRepo(self.full_path(), self._remote, self._ref)
        if not is_offline():
            if remote:
                if self.fork is None:
                    repo.fetch(self._remote, depth=self._depth)
                else:
                    repo.fetch(self.fork.remote_name)
                    repo.fetch(self._remote)

        repo.print_branches(local=local, remote=remote)
Exemple #4
0
    def branch(self, local=False, remote=False):
        """Print branches for project

        .. py:function:: branch(local=False, remote=False)

        :param Optional[bool] local: Print local branches
        :param Optional[bool] remote: Print remote branches
        """

        repo = ProjectRepo(self.full_path(), self.remote, self.ref)
        if not is_offline() and remote:
            if self.fork is None:
                repo.fetch(self.remote, depth=self.depth)
            else:
                repo.fetch(self.fork.remote_name)
                repo.fetch(self.remote)

        repo.print_branches(local=local, remote=remote)