def herd(self): """Clone project or update latest from upstream""" self._print_status() if not os.path.isdir(os.path.join(self.full_path(), '.git')): git_clone_url_at_path(self.url, self.full_path(), self.ref, self.remote_name) else: ref_type = git_ref_type(self.ref) if ref_type is 'branch': git_create_remote(self.full_path(), self.remote_name, self.url) git_fetch(self.full_path()) git_checkout_ref(self.full_path(), self.ref, self.remote_name) branch = git_truncate_ref(self.ref) git_pull_remote_branch(self.full_path(), self.remote_name, branch) elif ref_type is 'tag' or ref_type is 'sha': git_create_remote(self.full_path(), self.remote_name, self.url) git_fetch(self.full_path()) git_checkout_ref(self.full_path(), self.ref, self.remote_name) else: print('Unknown ref ' + self.ref)
def print_status(self): """Print clowder repo status""" repo_path = os.path.join(self.root_directory, '.clowder') # FIXME: Probably should remove this as it assumes .clowder repo which isn't git directory if not os.path.isdir(os.path.join(repo_path, '.git')): output = colored('.clowder', 'green') print(output) return print(' - Fetching upstream changes for clowder repo', end="", flush=True) timer = RepeatedTimer(1, _print_progress) git_fetch(self.clowder_path) timer.stop() print("\n") project_output = format_project_string(repo_path, '.clowder') current_ref_output = format_ref_string(repo_path) clowder_symlink = os.path.join(self.root_directory, 'clowder.yaml') if os.path.islink(clowder_symlink): real_path = os.path.realpath(clowder_symlink) clowder_path = remove_prefix(real_path + '/', self.root_directory) path_output = colored(clowder_path[1:-1], 'cyan') print(project_output + ' ' + current_ref_output + ' ~~> ' + path_output) else: print(project_output + ' ' + current_ref_output)
def fetch(self): """Silently fetch upstream changes if project exists on disk""" if self.exists(): git_fetch(self.full_path())