def _update_project(project):
with cd(project.folder()):
info('We will update the project %s' %
click.style(project.name(), bold=True))
repo = Repo(project.folder())
remotes = [remote.name for remote in repo.remotes]
updated_from_upstream = False
if 'upstream' not in remotes:
click.secho('warning: your repository has no configured upstream, '
'skipping update', fg='yellow')
else:
out = git('branch', '-a')
remote_branch_name = 'remotes/upstream/' + repo.active_branch.name
rebase = False
for line in out.split('\n'):
if remote_branch_name in line:
rebase = True
break
if rebase:
try:
vgit('pull', '--rebase', 'upstream', repo.active_branch)
except ErrorReturnCode_1:
fatal('error: unable to update the project')
updated_from_upstream = True
if 'origin' in remotes:
vgit('push', 'origin', repo.active_branch)
if 'origin' in remotes and not updated_from_upstream:
vgit('pull', 'origin', repo.active_branch)
success('The project %s has been updated' %
click.style(project.name(), bold=True))
评论列表
文章目录