Added exception handler for git repo init

This commit is contained in:
Cowyn Li 2013-12-04 17:36:46 +08:00
parent 00faa5f002
commit ff1d58f342
2 changed files with 16 additions and 2 deletions

View File

@ -127,7 +127,14 @@ def init():
rp_ = os.path.join(bp_, repo_hash)
if not os.path.isdir(rp_):
os.makedirs(rp_)
repo = git.Repo.init(rp_)
try:
repo = git.Repo.init(rp_)
except Exception as e:
log.error('GitPython exception caught while initializing the repo '
'for gitfs: {0}. Maybe git is not available.'.format(e))
return repos
if not repo.remotes:
try:
repo.create_remote('origin', opt)

View File

@ -111,7 +111,14 @@ def init(branch, repo_location):
if not os.path.isdir(rp_):
os.makedirs(rp_)
repo = git.Repo.init(rp_)
try:
repo = git.Repo.init(rp_)
except Exception as e:
log.error('GitPython exception caught while initializing the repo for '
'git_pillar: {0}. Maybe git is not available.'.format(e))
return None
if not repo.remotes:
try:
repo.create_remote('origin', repo_location)