Skip to content
Snippets Groups Projects
Commit f2229f8c authored by Srdjan Grubor's avatar Srdjan Grubor
Browse files

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
parent 6cf8c53d
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ GIT_CLONE_CMD = 'git clone %s %s %s' ...@@ -22,6 +22,7 @@ GIT_CLONE_CMD = 'git clone %s %s %s'
GIT_CLONE_API_URL = 'https://%s@github.com/%s' GIT_CLONE_API_URL = 'https://%s@github.com/%s'
GIT_SHA_CMD = 'git rev-parse --short %s' GIT_SHA_CMD = 'git rev-parse --short %s'
GIT_FETCH_CMD = 'git fetch' GIT_FETCH_CMD = 'git fetch'
GIT_CHECK_REMOTE_CMD = 'git ls-remote'
USER_DETAILS_PATH = '/users/%s' USER_DETAILS_PATH = '/users/%s'
...@@ -166,10 +167,22 @@ class CodeRepo(object): ...@@ -166,10 +167,22 @@ class CodeRepo(object):
print("- " + get_color_str(branch, Color.GREEN) + " @ " \ print("- " + get_color_str(branch, Color.GREEN) + " @ " \
+ self.get_sha_str(branch, directory) + ' ..'), + self.get_sha_str(branch, directory) + ' ..'),
def update(self): def update(self, fatal_remote_errors = True):
if self.try_clone(False): if self.try_clone(False):
return 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) self.print_start_sha(self.default_branch, self.target_directory)
system_exec(GIT_FETCH_CMD, self.target_directory, False) system_exec(GIT_FETCH_CMD, self.target_directory, False)
print self.get_sha_str(self.default_branch, self.target_directory) print self.get_sha_str(self.default_branch, self.target_directory)
...@@ -200,6 +213,9 @@ class WikiRepo(CodeRepo): ...@@ -200,6 +213,9 @@ class WikiRepo(CodeRepo):
# GitRepo clone code, but allow it to fail. # GitRepo clone code, but allow it to fail.
return CodeRepo.try_clone(self, True) return CodeRepo.try_clone(self, True)
def update(self):
super(WikiRepo, self).update(fatal_remote_errors = False)
class JsonRepo(object): class JsonRepo(object):
def __init__(self, gh_repo, api_url, config, content=None): def __init__(self, gh_repo, api_url, config, content=None):
self.config = config self.config = config
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment