本文整理汇总了Python中ellen.repo.Jagare.resolve_commit方法的典型用法代码示例。如果您正苦于以下问题:Python Jagare.resolve_commit方法的具体用法?Python Jagare.resolve_commit怎么用?Python Jagare.resolve_commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ellen.repo.Jagare
的用法示例。
在下文中一共展示了Jagare.resolve_commit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resolve_commit
# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import resolve_commit [as 别名]
def test_resolve_commit(self):
repo = Jagare(self.path)
test_commit_hex1 = 'e9f35005ca7d004d87732598f761b1be3b9d1c61'
test_commit_tree_hex1 = 'be483ca0381e9a61b76fac84863acdd970b9150f'
test_commit_blob_hex1 = '7a8a76c619b95af88fb71e5514509e9ac8da6779'
test_master_commit_hex = '9119237c2d5aa2c4a110296e255c7ec194711066'
# FIXME tag test
assert repo.resolve_commit(test_commit_hex1) == test_commit_hex1
assert repo.resolve_commit(test_commit_tree_hex1) is None
assert repo.resolve_commit(test_commit_blob_hex1) is None
assert repo.resolve_commit('master') == test_master_commit_hex
示例2: Repo
# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import resolve_commit [as 别名]
#.........这里部分代码省略.........
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, *w, **kw):
commits = self.repo.rev_list(*w, **kw)
# TODO: validate commits
return [Commit(self, commit) for commit in commits]
def get_raw_diff(self, ref, from_ref=None, **kw):
''' get Jagare formated diff dict '''
return self.repo.diff(ref, from_ref=from_ref, **kw)
def get_diff(self, ref=None, from_ref=None,
linecomments=[], raw_diff=None, **kw):
''' get ngit wrapped diff object '''
_raw_diff = None
if raw_diff:
_raw_diff = raw_diff
elif ref:
_raw_diff = self.get_raw_diff(ref, from_ref=from_ref, **kw)
if _raw_diff:
return Diff(self, _raw_diff, linecomments)
else:
return None
def get_diff_length(self, ref, from_ref=None, **kw):
_raw_diff = self.get_raw_diff(ref, from_ref=from_ref, **kw)
return len(_raw_diff['patches']) if _raw_diff else 0
def get_last_commit(self, ref, path=None):
if not path:
return self.get_commit(ref)
commit = self.repo.rev_list(ref, path=path, max_count=1)
if not commit:
return None
commit = commit[0]
commit = Commit(self, commit)
return commit
def get_commit(self, ref):
sha = self.repo.resolve_commit(ref)
if not sha:
return None
commit = self.repo.show(sha)
if not commit:
return None
# TODO: validate commit
return Commit(self, commit)
def delete_branch(self, name):
self.repo.delete_branch(name)
def get_path_by_ref(self, ref):
''' get blob or tree '''
path = self.repo.show(ref)
if not path:
return None
if path['type'] == 'tree':
path = Tree(self, path['entries'])
elif path['type'] == 'blob':
path = Blob(self, path)
else:
path = None
return path
def get_path(self, ref, path):
_item = self.repo.show("%s:%s" % (ref, path))
if not _item:
return None
if _item['type'] == 'tree':
item = Tree(self, _item['entries'])
elif _item['type'] == 'blob':
item = Blob(self, _item)
else:
item = None
return item
示例3: Repo
# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import resolve_commit [as 别名]
#.........这里部分代码省略.........
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,
since=since, no_merges=no_merges)
return [Commit(self, commit) for commit in commits]
def get_raw_diff(self, ref, from_ref=None, paths=None, **kw):
''' get Jagare formated diff dict '''
try:
diff = self.repo.diff(ref, from_ref=from_ref, paths=paths, **kw)
except KeyError:
return None
return diff
def get_diff(self, ref=None, from_ref=None,
linecomments=[], raw_diff=None, paths=None, **kw):
''' get ngit wrapped diff object '''
_raw_diff = None
if raw_diff:
_raw_diff = raw_diff
elif ref:
_raw_diff = self.get_raw_diff(ref, from_ref=from_ref,
paths=paths, **kw)
if _raw_diff:
return Diff(self, _raw_diff, linecomments)
else:
return None
def get_diff_length(self, ref, from_ref=None, **kw):
_raw_diff = self.get_raw_diff(ref, from_ref=from_ref, **kw)
return len(_raw_diff['patches']) if _raw_diff else 0
def get_last_commit(self, ref, path=None, no_merges=False):
if not path:
return self.get_commit(ref)
commit = self.repo.rev_list(ref, path=path, max_count=1,
no_merges=no_merges)
if not commit:
return None
commit = commit[0]
commit = Commit(self, commit)
return commit
def get_previours_commit(self, ref, path):
"""previours commit that touch the specified path"""
commits = self.repo.rev_list(ref, path=path, max_count=2,
no_merges=True)
for commit in commits:
if commit['sha'] != self.repo.sha(ref):
return Commit(self, commit)
return None
def get_commit(self, ref):
sha = self.repo.resolve_commit(ref)
if not sha:
return None
commit = self.repo.show(sha)
if not commit:
return None
# TODO: validate commit
return Commit(self, commit)
def delete_branch(self, name):
self.repo.delete_branch(name)
def get_path_by_ref(self, ref):
''' get blob or tree '''
path = self.repo.show(ref)
if not path:
return None
if path['type'] == 'tree':
path = Tree(self, path['entries'])
elif path['type'] == 'blob':
path = Blob(self, path)
else:
path = None
return path
def get_path(self, ref, path):
_item = self.repo.show("%s:%s" % (ref, path))
if not _item:
return None
if _item['type'] == 'tree':
item = Tree(self, _item['entries'])
elif _item['type'] == 'blob':
item = Blob(self, _item)
else:
item = None
return item
def get_last_update_timestamp(self):
commit = self.get_last_commit('HEAD')
if not commit:
return 0
return int(commit.author_timestamp)
示例4: resolve_commit
# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import resolve_commit [as 别名]
def resolve_commit(self, path, ref):
try:
repo = Jagare(path)
return repo.resolve_commit(ref)
except Exception as e:
raise ServiceUnavailable(repr(e))