def _branch(self): """Clowder branch command private implementation""" local = True remote = False if self.app.pargs.all: local = True remote = True elif self.app.pargs.remote: remote = True if self.app.pargs.projects is None: groups = filter_groups(CLOWDER_CONTROLLER.groups, self.app.pargs.groups) for group in groups: run_group_command(group, self.app.pargs.skip, 'branch', local=local, remote=remote) return projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects) for project in projects: run_project_command(project, self.app.pargs.skip, 'branch', local=local, remote=remote)
def _clean(clowder, group_names, **kwargs): """Discard changes .. py:function:: clean(group_names, args='', recursive=False, project_names=None, skip=[]) :param ClowderController clowder: ClowderController instance :param list[str] group_names: Group names to clean Keyword Args: args (str): Git clean options - ``d`` Remove untracked directories in addition to untracked files - ``f`` Delete directories with .git sub directory or file - ``X`` Remove only files ignored by git - ``x`` Remove all untracked files recursive (bool): Clean submodules recursively project_names (list[str]): Project names to clean skip (list[str]): Project names to skip """ project_names = kwargs.get('project_names', None) skip = kwargs.get('skip', []) args = kwargs.get('args', '') recursive = kwargs.get('recursive', False) if project_names is None: groups = filter_groups(clowder.groups, group_names) for group in groups: run_group_command(group, skip, 'clean', args=args, recursive=recursive) return projects = filter_projects(clowder.groups, project_names=project_names) for project in projects: run_project_command(project, skip, 'clean', args=args, recursive=recursive)
def _clean_all(clowder, group_names, **kwargs): """Discard all changes .. py:function:: clean_all(group_names, project_names=None, skip=[]) :param ClowderController clowder: ClowderController instance :param list[str] group_names: Group names to clean Keyword Args: project_names (list[str]): Project names to clean skip (list[str]): Project names to skip """ project_names = kwargs.get('project_names', None) skip = kwargs.get('skip', []) if project_names is None: groups = filter_groups(clowder.groups, group_names) for group in groups: run_group_command(group, skip, 'clean_all') return projects = filter_projects(clowder.groups, project_names=project_names) for project in projects: run_project_command(project, skip, 'clean_all')
def _diff(self): """Clowder diff command private implementation""" if self.app.pargs.projects is None: groups = filter_groups(CLOWDER_CONTROLLER.groups, self.app.pargs.groups) for group in groups: run_group_command(group, self.app.pargs.skip, 'diff') return projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects) for project in projects: run_project_command(project, self.app.pargs.skip, 'diff')
def herd(clowder, group_names, **kwargs): """Clone projects or update latest from upstream .. py:function:: herd(clowder, group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[], protocol=None) :param ClowderController clowder: ClowderController instance :param list[str] group_names: Group names to herd Keyword Args: branch (str): Branch to attempt to herd tag (str): Tag to attempt to herd depth (int): Git clone depth. 0 indicates full clone, otherwise must be a positive integer protocol (str): Git protocol ('ssh' or 'https') rebase (bool): Whether to use rebase instead of pulling latest changes project_names (list[str]) project_names: Project names to herd skip (list[str]): Project names to skip """ project_names = kwargs.get('project_names', None) skip = kwargs.get('skip', []) branch = kwargs.get('branch', None) tag = kwargs.get('tag', None) depth = kwargs.get('depth', None) rebase = kwargs.get('rebase', False) protocol = kwargs.get('protocol', None) if project_names is None: groups = filter_groups(clowder.groups, group_names) validate_groups(groups) for group in groups: run_group_command(group, skip, 'herd', branch=branch, tag=tag, depth=depth, rebase=rebase, protocol=protocol) return projects = filter_projects(clowder.groups, project_names=project_names) validate_projects(projects) for project in projects: run_project_command(project, skip, 'herd', branch=branch, tag=tag, depth=depth, rebase=rebase, protocol=protocol)
def _start_branches(self, tracking): """clowder start branches command""" if self.app.pargs.projects is None: groups = filter_groups(CLOWDER_CONTROLLER.groups, self.app.pargs.groups) validate_groups(groups) for group in groups: run_group_command(group, self.app.pargs.skip, 'start', self.app.pargs.branch, tracking) return projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects) validate_projects(projects) for project in projects: run_project_command(project, self.app.pargs.skip, 'start', self.app.pargs.branch, tracking)
def _stash(self): """Clowder stash command private implementation""" if not any([g.is_dirty() for g in CLOWDER_CONTROLLER.groups]): print('No changes to stash') return if self.app.pargs.projects is None: groups = filter_groups(CLOWDER_CONTROLLER.groups, self.app.pargs.groups) for group in groups: run_group_command(group, self.app.pargs.skip, 'stash') return projects = filter_projects(CLOWDER_CONTROLLER.groups, project_names=self.app.pargs.projects) for project in projects: run_project_command(project, self.app.pargs.skip, 'stash')
def _prune(clowder, group_names, branch, **kwargs): """Prune branches .. py:function:: prune(group_names, local=False, remote=False, force=False, project_names=None, skip=[]) :param ClowderController clowder: ClowderController instance :param list[str] group_names: Group names to prune branches for :param str branch: Branch to prune Keyword Args: force (bool): Force delete branch local (bool): Delete local branch remote (bool): Delete remote branch project_names (list[str]): Project names to prune skip (list[str]): Project names to skip """ project_names = kwargs.get('project_names', None) skip = kwargs.get('skip', []) force = kwargs.get('force', False) local = kwargs.get('local', False) remote = kwargs.get('remote', False) if project_names is None: groups = filter_groups(clowder.groups, group_names) validate_groups(groups) _prune_groups(groups, branch, skip=skip, force=force, local=local, remote=remote) return projects = filter_projects(clowder.groups, project_names=project_names) validate_projects(projects) _prune_projects(projects, branch, skip=skip, force=force, local=local, remote=remote)
def reset(clowder, group_names, **kwargs): """Reset project branches to upstream or checkout tag/sha as detached HEAD .. py:function:: reset(clowder, group_names, timestamp_project=None, parallel=False, project_names=None, skip=[]) :param ClowderController clowder: ClowderController instance :param list[str] group_names: Group names to reset Keyword Args: timestamp_project (str): Reference project to checkout commit timestamps of other projects relative to parallel (bool): Whether command is being run in parallel, affects output project_names (list[str]): Project names to reset skip (list[str]): Project names to skip """ project_names = kwargs.get('project_names', None) skip = kwargs.get('skip', []) timestamp_project = kwargs.get('timestamp_project', None) parallel = kwargs.get('parallel', False) if parallel: reset_parallel(clowder, group_names, skip=skip, timestamp_project=timestamp_project) if os.name == "posix": return timestamp = None if timestamp_project: timestamp = clowder.get_timestamp(timestamp_project) if project_names is None: groups = filter_groups(clowder.groups, group_names) validate_groups(groups) for group in groups: run_group_command(group, skip, 'reset', timestamp=timestamp) return projects = filter_projects(clowder.groups, project_names=project_names) validate_projects(projects) for project in projects: run_project_command(project, skip, 'reset', timestamp=timestamp)