Skip to content
Snippets Groups Projects
Commit f4269884 authored by Dan Nicholson's avatar Dan Nicholson
Browse files

Merge pull request #9 from sgnn7/removed_wiki_handling

Added handling of wikis that have been removed
parents 6cf8c53d f2229f8c
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