# 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
    def origin_commit_hex(self):
        hex = None
        try:
            reference = self.pull_origin_reference
            commit = self.repository.resolve_commit(reference)
            hex = commit.hex
        except:
            pass

        if hex:
            return hex
        repo = self.origin_repository
        if not repo:
            return hex

        try:
            reference = self.pullrequest.origin_project_ref
            commit = repo.resolve_commit(reference)
            hex = commit.hex
        except:
            pass

        return hex

    @property
    def upstream_commit_hex(self):
        hex = None
        try:
            reference = self.pull_upstream_reference
            commit = self.repository.resolve_commit(reference)

# 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

    def origin_commit_hex(self):
        hex = None
        try:
            reference = self.pull_origin_reference
            commit = self.repository.resolve_commit(reference)
            hex = commit.hex
        except:
            pass

        if hex:
            return hex
        repo = self.origin_repository
        if not repo:
            return hex

        try:
            reference = self.pullrequest.origin_project_ref
            commit = repo.resolve_commit(reference)
            hex = commit.hex
        except:
            pass

        return hex

    @property
    def upstream_commit_hex(self):
        hex = None
        try:
            reference = self.pull_upstream_reference
            commit = self.repository.resolve_commit(reference)

            hex = commit.hex