# Path: vilya/libs/git.py
# PULL_REF_H = 'refs/pulls/%s/head'
# 
# PULL_REF_M = 'refs/pulls/%s/merge'
# 
# def make_git_env(user=None, is_anonymous=False):
#     env = {}
#     if is_anonymous:
#         env['GIT_AUTHOR_NAME'] = 'anonymous'
#         env['GIT_AUTHOR_EMAIL'] = 'anonymous@douban.com'
#         env['GIT_COMMITTER_NAME'] = 'anonymous'
#         env['GIT_COMMITTER_EMAIL'] = 'anonymous@douban.com'
#     else:
#         env['GIT_AUTHOR_NAME'] = user.name
#         env['GIT_AUTHOR_EMAIL'] = user.email
#         env['GIT_COMMITTER_NAME'] = user.name
#         env['GIT_COMMITTER_EMAIL'] = user.email
#     return env
# 
# Path: vilya/settings.py
# TEMP_PATH = './temp'


import os
import shutil
        import tempfile
from ..libs.git import PULL_REF_H, PULL_REF_M, make_git_env
from ..settings import TEMP_PATH
                                 m=message,
                                 env=env)
            if errcode != 0:
                raise MergeError
            # TODO CODE_REMOTE_USER
            errcode = repo.push('origin', upstream_project_ref)
            if errcode != 0:
                raise PushError
            commit = self.repository.resolve_commit(upstream_project_ref)
        except MergeError:
            pass
        except PushError:
            pass
        finally:
            shutil.rmtree(worktree)
        return commit

    @property
    def can_fastforward(self):
        commits = self.repository.list_commits(self.upstream_commit_hex,
                                               self.origin_commit_hex)
        if not commits:
            return True

    @property
    def can_merge(self):
        r = False
        worktree = self.temp_path
        try:
            user = self.upstream_project.owner

# Path: vilya/libs/git.py
# PULL_REF_H = 'refs/pulls/%s/head'
# 
# PULL_REF_M = 'refs/pulls/%s/merge'
# 
# def make_git_env(user=None, is_anonymous=False):
#     env = {}
#     if is_anonymous:
#         env['GIT_AUTHOR_NAME'] = 'anonymous'
#         env['GIT_AUTHOR_EMAIL'] = 'anonymous@douban.com'
#         env['GIT_COMMITTER_NAME'] = 'anonymous'
#         env['GIT_COMMITTER_EMAIL'] = 'anonymous@douban.com'
#     else:
#         env['GIT_AUTHOR_NAME'] = user.name
#         env['GIT_AUTHOR_EMAIL'] = user.email
#         env['GIT_COMMITTER_NAME'] = user.name
#         env['GIT_COMMITTER_EMAIL'] = user.email
#     return env
# 
# Path: vilya/settings.py
# TEMP_PATH = './temp'


# Path: vilya/pullrequests/repository.py
import os
import shutil
        import tempfile
from ..libs.git import PULL_REF_H, PULL_REF_M, make_git_env
from ..settings import TEMP_PATH

                                 m=message,
                                 env=env)
            if errcode != 0:
                raise MergeError
            # TODO CODE_REMOTE_USER
            errcode = repo.push('origin', upstream_project_ref)
            if errcode != 0:
                raise PushError
            commit = self.repository.resolve_commit(upstream_project_ref)
        except MergeError:
            pass
        except PushError:
            pass
        finally:
            shutil.rmtree(worktree)
        return commit

    @property
    def can_fastforward(self):
        commits = self.repository.list_commits(self.upstream_commit_hex,
                                               self.origin_commit_hex)
        if not commits:
            return True

    @property
    def can_merge(self):
        r = False
        worktree = self.temp_path
        try:
            user = self.upstream_project.owner

            env = make_git_env(user.name, user.email)