# 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

    @property
    def merge_base_hex(self):
        upstream = self.upstream_commit_hex
        origin = self.origin_commit_hex
        commit = None
        if upstream and origin:
            commit = self.repository.resolve_merge_base(upstream, origin)
        if not commit:
            return upstream
        return commit.hex

    @property
    def temp_path(self):
        if hasattr(self, "_temp_path"):
            return self._temp_path

        temp_pull_path = os.path.join(TEMP_PATH, "pull")
        if not os.path.exists(temp_pull_path):
            os.makedirs(temp_pull_path)
        worktree = tempfile.mkdtemp(dir=temp_pull_path)
        self._temp_path = worktree
        return worktree

    @property
    def commits(self):
        return self.repository.list_commits(self.origin_commit_hex,
                                            self.upstream_commit_hex)

    @property

# 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


    @property
    def merge_base_hex(self):
        upstream = self.upstream_commit_hex
        origin = self.origin_commit_hex
        commit = None
        if upstream and origin:
            commit = self.repository.resolve_merge_base(upstream, origin)
        if not commit:
            return upstream
        return commit.hex

    @property
    def temp_path(self):
        if hasattr(self, "_temp_path"):
            return self._temp_path

        temp_pull_path = os.path.join(TEMP_PATH, "pull")
        if not os.path.exists(temp_pull_path):
            os.makedirs(temp_pull_path)
        worktree = tempfile.mkdtemp(dir=temp_pull_path)
        self._temp_path = worktree
        return worktree

    @property
    def commits(self):
        return self.repository.list_commits(self.origin_commit_hex,
                                            self.upstream_commit_hex)

    @property

    def files(self):