def _print_fork_output(project): """Print fork output if a fork exists :param Project project: Project to print fork status for """ if project.fork: print(' ' + fmt.fork_string(project.name)) print(' ' + fmt.fork_string(project.fork.name))
def _print_parallel_projects_output(projects, skip): """Print output for parallel project command""" for project in projects: if project.name in skip: continue print(project.status()) if project.fork: print(' ' + fmt.fork_string(project.name)) print(' ' + fmt.fork_string(project.fork.name))
def _print_parallel_groups_output(groups, skip): """Print output for parallel group command""" for group in groups: print(fmt.group_name(group.name)) for project in group.projects: if project.name in skip: continue print(project.status()) if project.fork: print(' ' + fmt.fork_string(project.name)) print(' ' + fmt.fork_string(project.fork.name))
def _sync(self, repo, rebase): """Sync fork project with upstream""" self._print(self.fork.status()) repo.configure_remotes(self._remote, self._url, self.fork.remote_name, self.fork.url) self._print(fmt.fork_string(self.name)) repo.herd(self._url, self._remote, rebase=rebase) self._print(fmt.fork_string(self.fork.name)) repo.herd_remote(self.fork.url, self.fork.remote_name) self._print(self.fork.status()) repo.sync(self.fork.remote_name, rebase=rebase)
def _sync_parallel(projects, rebase=False): """Sync projects in parallel""" print(' - Sync forks in parallel\n') for project in projects: print(project.status()) if project.fork: print(' ' + fmt.fork_string(project.name)) print(' ' + fmt.fork_string(project.fork.name)) for project in projects: result = __clowder_pool__.apply_async(sync_project, args=(project, rebase), callback=async_callback) __clowder_results__.append(result) pool_handler(len(projects))
def _herd_tag(self, repo, tag, depth, rebase): """Clone project or update latest from upstream""" if self.fork is None: repo.herd_tag(self._url, tag, depth=depth, rebase=rebase) return self._print(self.fork.status()) repo.configure_remotes(self._remote, self._url, self.fork.remote_name, self.fork.url) self._print(fmt.fork_string(self.name)) repo.herd_tag(self._url, tag, rebase=rebase) self._print(fmt.fork_string(self.fork.name)) repo.herd_remote(self.fork.url, self.fork.remote_name)
def _run_herd_command(self, command, repo, protocol, *args, **kwargs): """Run herd command :param str command: Repo path :param ProjectRepo repo: ProjectRepo or ProjectRepoRecursive instance :param str protocol: Git protocol ('ssh' or 'https') Other Parameters: branch (str): Branch to attempt to herd tag (str): Tag to attempt to herd Keyword Args: depth (int): Git clone depth. 0 indicates full clone, otherwise must be a positive integer rebase (bool): Whether to use rebase instead of pulling latest changes fork_remote (str): Fork remote name """ if self.fork is None: getattr(repo, command)(self._url(protocol), *args, **kwargs) return self._print(self.fork.status()) repo.configure_remotes(self.remote, self._url(protocol), self.fork.remote_name, self.fork.url(protocol)) self._print(fmt.fork_string(self.name)) kwargs['depth'] = 0 getattr(repo, command)(self._url(protocol), *args, **kwargs) self._print(fmt.fork_string(self.fork.name)) frame = inspect.currentframe() vals = inspect.getargvalues(frame) branch_arg = [ a for a in vals.args if vals.locals[a] if vals.locals[a] == 'branch' ] branch = branch_arg[0] if branch_arg else None repo.herd_remote(self.fork.url(protocol), self.fork.remote_name, branch=branch)
def _reset(self, repo, timestamp=None): """Clone project or update latest from upstream""" if self.fork is None: if timestamp: repo.reset_timestamp(timestamp, self._timestamp_author, self._ref) return repo.reset(depth=self._depth) return self._print(self.fork.status()) repo.configure_remotes(self._remote, self._url, self.fork.remote_name, self.fork.url) self._print(fmt.fork_string(self.name)) if timestamp: repo.reset_timestamp(timestamp, self._timestamp_author, self._ref) return repo.reset()
def reset(self, timestamp=None, parallel=False): """Reset project branch to upstream or checkout tag/sha as detached HEAD .. py:function:: reset(timestamp=None, parallel=False) :param Optional[str] timestamp: Reset to commit at timestamp, or closest previous commit :param Optional[bool] parallel: Whether command is being run in parallel, affects output """ self._print_output = not parallel repo = self._repo(self.full_path(), self.remote, self.ref, self.recursive, parallel=parallel) if self.fork is None: if timestamp: repo.reset_timestamp(timestamp, self._timestamp_author, self.ref) return repo.reset(depth=self.depth) return self._print(self.fork.status()) repo.configure_remotes(self.remote, self._url(), self.fork.remote_name, self.fork.url(self._protocol)) self._print(fmt.fork_string(self.name)) if timestamp: repo.reset_timestamp(timestamp, self._timestamp_author, self.ref) return repo.reset()