fetch.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:AerisCloud 作者: AerisCloud 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号