From f2229f8cd6a4ba323bbe4e7e6b333e9562e16140 Mon Sep 17 00:00:00 2001 From: Srdjan Grubor <sgnn7@sgnn7.org> Date: Mon, 2 Jun 2014 13:19:23 -0500 Subject: [PATCH] Added handling of wikis that have been removed Previously the wikis that we have on disk were attempted to be fetched regardless of if the wiki was avaliable or not so now we do an explicit check to ensure that in the case of a deleted wiki, we do not break the whole process. Edit: Same fetch check has been added to source repos as well --- update_repos | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/update_repos b/update_repos index 01edc32..27c9261 100755 --- a/update_repos +++ b/update_repos @@ -22,6 +22,7 @@ GIT_CLONE_CMD = 'git clone %s %s %s' GIT_CLONE_API_URL = 'https://%s@github.com/%s' GIT_SHA_CMD = 'git rev-parse --short %s' GIT_FETCH_CMD = 'git fetch' +GIT_CHECK_REMOTE_CMD = 'git ls-remote' USER_DETAILS_PATH = '/users/%s' @@ -166,10 +167,22 @@ class CodeRepo(object): print("- " + get_color_str(branch, Color.GREEN) + " @ " \ + self.get_sha_str(branch, directory) + ' ..'), - def update(self): + def update(self, fatal_remote_errors = True): if self.try_clone(False): return + # Check if the remote is still there before fetching + return_code = system_exec(GIT_CHECK_REMOTE_CMD, self.target_directory, show_output=False, ignore_error=True).return_code + if return_code != 0: + # Is it fatal? + if fatal_remote_errors: + error_message = get_color_str("ERROR: Repo for %s seems to have been deleted. Skipping update." % self.full_name, Color.RED) + print error_message + raise Exception(error_message) + else: + print get_color_str("WARNING: Repo for %s seems to have been deleted. Skipping update." % self.full_name, Color.GREEN) + return + self.print_start_sha(self.default_branch, self.target_directory) system_exec(GIT_FETCH_CMD, self.target_directory, False) print self.get_sha_str(self.default_branch, self.target_directory) @@ -200,6 +213,9 @@ class WikiRepo(CodeRepo): # GitRepo clone code, but allow it to fail. return CodeRepo.try_clone(self, True) + def update(self): + super(WikiRepo, self).update(fatal_remote_errors = False) + class JsonRepo(object): def __init__(self, gh_repo, api_url, config, content=None): self.config = config -- GitLab