当前位置: 首页>>代码示例>>Python>>正文


Python Jagare.sha方法代码示例

本文整理汇总了Python中ellen.repo.Jagare.sha方法的典型用法代码示例。如果您正苦于以下问题:Python Jagare.sha方法的具体用法?Python Jagare.sha怎么用?Python Jagare.sha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ellen.repo.Jagare的用法示例。


在下文中一共展示了Jagare.sha方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _merge

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import sha [as 别名]
    def _merge(self, no_ff):
        repo = Jagare(self.path)
        BR = 'br_test_merge'
        path = self.get_temp_path()

        # repo has work-tree
        repo.clone(path, branch=BARE_REPO_OTHER_BRANCH)
        repo = Jagare(os.path.join(path, '.git'))

        ret = repo.create_branch(BR, BARE_REPO_OTHER_BRANCH)
        assert ret
        sha1 = repo.sha(BARE_REPO_OTHER_BRANCH)

        commit_something(path, branch=BR)
        repo.update_head(BARE_REPO_OTHER_BRANCH)
        ret = repo.merge(BR, no_ff=no_ff)
        sha2 = repo.sha(BARE_REPO_OTHER_BRANCH)

        assert sha1 != sha2
        assert repo.sha(sha1) == sha1
开发者ID:CMGS,项目名称:ellen,代码行数:22,代码来源:test_merge.py

示例2: test_merge_flow

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import sha [as 别名]
    def test_merge_flow(self):
        repo = Jagare(self.path)
        BR = 'br_test_merge'
        sha1 = repo.sha(BARE_REPO_OTHER_BRANCH)

        from_repo_path = self.get_temp_path()
        from_repo = repo.clone(from_repo_path, branch=BARE_REPO_OTHER_BRANCH,
                               bare=True)
        ret = from_repo.create_branch(BR, BARE_REPO_OTHER_BRANCH)
        assert ret
        commit_something(from_repo_path, branch=BR)

        tmpdir = self.get_temp_path()

        # different repo
        sha = repo.merge_flow('lh', '[email protected]',
                              'test_header', 'test_body', tmpdir,
                              from_repo_path, BR, BARE_REPO_OTHER_BRANCH,
                              remote_name='hub/xxxproject', no_ff=True)
        assert sha

        sha2 = repo.sha(BARE_REPO_OTHER_BRANCH)

        assert sha1 != sha2
        assert repo.sha(sha1) == sha1

        # same repo
        tmpdir2 = self.get_temp_path()
        from_sha1 = from_repo.sha(BARE_REPO_OTHER_BRANCH)
        assert from_sha1 == sha1
        sha = from_repo.merge_flow('lh', '[email protected]',
                                   'test_header', 'test_body', tmpdir2,
                                   from_repo_path, BR, BARE_REPO_OTHER_BRANCH,
                                   no_ff=True)
        assert sha
        from_sha2 = from_repo.sha(BARE_REPO_OTHER_BRANCH)
        assert from_sha1 != from_sha2
        assert from_repo.sha(from_sha1) == from_sha1
开发者ID:tclh123,项目名称:ellen,代码行数:40,代码来源:test_merge.py

示例3: ProjectRepo

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import sha [as 别名]
class ProjectRepo(Repo):
    provided_features = ['project', 'fulltext', 'moreline',
                         'side_by_side', 'patch_actions']

    def __init__(self, project, pull=None):
        self.type = "project"
        self.pull = pull
        self.project = project
        self.project_name = project.name
        self.name = project.name
        self.path = project.repo_path
        self.repo = Jagare(self.path)

    # TODO: url
    @property
    def api_url(self):
        return ''

    @property
    def context_url(self):
        return 'moreline'

    @property
    def fulltext_url(self):
        return 'fulltext'

    @property
    def branches(self):
        return self.repo.branches

    @property
    def tags(self):
        return self.repo.tags

    def get_tree(self, ref, path=None, recursive=False):
        tree = self.repo.ls_tree(ref, path=path, recursive=recursive)
        if not tree:
            return None
        return Tree(self, tree)

    def get_file_by_ref(self, ref):
        blob = self.repo.show(ref)
        if not blob:
            return None
        return blob['data']

    def get_contexts(self, ref, path, line_start, line_end):
        def fix_line_index(index, max_i, min_i=0):
            i = index - 1
            i = max(i, min_i)
            i = min(i, max_i)
            return i
        lines = self.get_file_by_lines(ref, path)
        if not lines:
            return None
        n = len(lines)
        start = fix_line_index(line_start, n)
        end = fix_line_index(line_end, n)
        return lines[start:end]

    def blame_file(self, *w, **kw):
        blame = self.repo.blame(*w, **kw)
        return blame

    def get_renamed_files(self, ref, path=None):
        return self.repo.detect_renamed(ref)

    def commit_file(self, *w, **kw):
        return self.repo.commit_file(*w, **kw)

    def get_temp_branch(self):
        commit = self.get_commit('HEAD')
        return 'patch_tmp' + time.strftime('%Y%m%d%H%M%S-') + commit.sha[10]

    def get_patch_file(self, ref, from_ref=None):
        return self.repo.format_patch(ref, from_ref)

    def get_diff_file(self, ref, from_ref=None):
        _raw_diff = self.get_raw_diff(ref, from_ref)
        if not _raw_diff:
            return ''
        return _raw_diff['diff'].patch

    def get_last_update_timestamp(self):
        commit = self.get_last_commit('HEAD')
        if not commit:
            return 0
        return int(commit.author_timestamp)

    @classmethod
    def init(cls, path, work_path=None, bare=True):
        return Jagare.init(path, work_path=work_path, bare=bare)

    @classmethod
    def mirror(cls, url, path, env=None):
        Jagare.mirror(url, path, env=env)

    def add_remote(self, name, url):
        return self.repo.add_remote(name, url)

#.........这里部分代码省略.........
开发者ID:4T-Shirt,项目名称:code,代码行数:103,代码来源:repo.py

示例4: test_create

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import sha [as 别名]
 def test_create(self):
     repo = Jagare(self.path)
     repo.create_branch('br_test', 'master')
     assert repo.sha('br_test') == repo.sha('master')
开发者ID:CMGS,项目名称:ellen,代码行数:6,代码来源:test_branch.py

示例5: Repo

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import sha [as 别名]
class Repo(object):
    provided_features = []

    def __init__(self, path):
        self.type = "repo"
        self.path = path
        self.repo = Jagare(self.path)

    def provide(self, name):
        '''检查是否提供某功能,即是否提供某接口'''
        return name in self.provided_features

    @property
    def empty(self):
        return self.is_empty

    @property
    def is_empty(self):
        return self.repo.empty

    @property
    def default_branch(self):
        branch = ''
        head = self.repo.head
        if head:
            branch = head.name[REFS_HEADS_PREFIX_LENGTH:]
        return branch

    def update_default_branch(self, name):
        branches = self.repo.branches
        if name not in branches:
            return None
        self.repo.update_head(name)

    def clone(self, path, bare=None, branch=None,
              mirror=None, env=None, shared=None):
        self.repo.clone(path,
                        bare=bare, branch=branch,
                        mirror=mirror, env=env)
        # shared=shared) why?

    def archive(self, name, ref='master', ext='tar.gz'):
        content = self.repo.archive(name, ref=ref)
        if ext == 'tar':
            return content
        outbuffer = StringIO()
        zipfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=outbuffer)
        zipfile.write(content)
        zipfile.close()
        out = outbuffer.getvalue()
        return out

    def get_submodule(self, ref, path):
        path = path.strip()
        gitmodules = self.repo.show("%s:%s" % (ref, '.gitmodules'))
        if not gitmodules:
            return None
        submodules_lines = gitmodules["data"].split('\n')
        modules_str = '\n'.join([line.strip() for line in submodules_lines])
        config = ConfigParser.RawConfigParser()
        config.readfp(StringIO(modules_str))
        for section in config.sections():
            if config.has_option(section, 'path') and config.get(
                    section, 'path') == path:
                url = config.get(section, 'url')
                return Submodule(url, path)
        return None

    def get_file(self, ref, path):
        blob = self.repo.show("%s:%s" % (ref, path))
        if not blob:
            return None
        if blob['type'] != 'blob':
            return None
        # TODO: validate blob
        return Blob(self, blob)

    def get_file_by_lines(self, ref, path):
        blob = self.get_file(ref, path)
        # TODO: blob.size < xxx
        if not blob or blob.binary:
            return None
        if not blob.data:
            return []
        src = blob.data
        return src.splitlines()

    def get_file_n_lines(self, ref, path):
        lines = self.get_file_by_lines(ref, path)
        if lines:
            return len(lines)
        return 0

    def get_commits(self, to_ref, from_ref=None, path=None, skip=0,
                    max_count=0, author=None, query=None, first_parent=None,
                    since=0, no_merges=None):
        commits = self.repo.rev_list(to_ref=to_ref, from_ref=from_ref,
                                     path=path, skip=skip,
                                     max_count=max_count, author=author,
                                     query=query, first_parent=first_parent,
#.........这里部分代码省略.........
开发者ID:000fan000,项目名称:code,代码行数:103,代码来源:repo.py

示例6: ProjectRepo

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import sha [as 别名]
class ProjectRepo(Repo):
    provided_features = ["project", "fulltext", "moreline", "side_by_side", "patch_actions"]

    def __init__(self, project, pull=None):
        self.type = "project"
        self.pull = pull
        self.project = project
        self.project_name = project.name
        self.name = project.name
        self.path = project.repo_path
        self.repo = Jagare(self.path)

    # TODO: url
    @property
    def api_url(self):
        return ""

    @property
    def context_url(self):
        return "moreline"

    @property
    def fulltext_url(self):
        return "fulltext"

    @property
    def branches(self):
        return self.repo.branches

    @property
    def tags(self):
        return self.repo.tags

    def get_tree(self, ref, path=None, recursive=False, with_commit=False, recursive_with_tree_node=False):
        tree = self.repo.ls_tree(ref, path=path, recursive=recursive, with_commit=with_commit)
        # recursive_with_tree_node=recursive_with_tree_node)
        if not tree:
            return None
        return Tree(self, tree)

    def get_file_by_ref(self, ref):
        blob = self.repo.show(ref)
        if not blob:
            return None
        return blob["data"]

    def get_contexts(self, ref, path, line_start, line_end):
        def fix_line_index(index, max_i, min_i=0):
            i = index - 1
            i = max(i, min_i)
            i = min(i, max_i)
            return i

        lines = self.get_file_by_lines(ref, path)
        if not lines:
            return None
        n = len(lines)
        start = fix_line_index(line_start, n)
        end = fix_line_index(line_end, n)
        return lines[start:end]

    def blame_file(self, *w, **kw):
        blame = self.repo.blame(*w, **kw)
        if not blame:
            return None
        return Blame(self, blame)

    def get_renamed_files(self, ref, path=None):
        return self.repo.detect_renamed(ref)

    def commit_file(self, *w, **kw):
        return self.repo.commit_file(*w, **kw)

    def get_temp_branch(self):
        commit = self.get_commit("HEAD")
        return "patch_tmp" + time.strftime("%Y%m%d%H%M%S-") + commit.sha[10]

    def get_patch_file(self, ref, from_ref=None):
        return self.repo.format_patch(ref, from_ref)

    def get_diff_file(self, ref, from_ref=None):
        _raw_diff = self.get_raw_diff(ref, from_ref)
        if not _raw_diff:
            return ""
        patch = _raw_diff["diff"].patch
        if not patch:
            return ""
        return patch

    @classmethod
    def init(cls, path, work_path=None, bare=True):
        return Jagare.init(path, work_path=work_path, bare=bare)

    @classmethod
    def mirror(cls, url, path, env=None):
        Jagare.mirror(url, path, env=env)

    def add_remote(self, name, url):
        return self.repo.add_remote(name, url)

#.........这里部分代码省略.........
开发者ID:mozillazg,项目名称:code,代码行数:103,代码来源:repo.py

示例7: sha

# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import sha [as 别名]
 def sha(self, path, revision):
     try:
         repo = Jagare(path)
         return repo.sha(revision)
     except Exception as e:
         raise ServiceUnavailable(repr(e))
开发者ID:tclh123,项目名称:jagare-rpc,代码行数:8,代码来源:jagare_handler.py


注:本文中的ellen.repo.Jagare.sha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。