本文整理汇总了Python中ellen.repo.Jagare.diff方法的典型用法代码示例。如果您正苦于以下问题:Python Jagare.diff方法的具体用法?Python Jagare.diff怎么用?Python Jagare.diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ellen.repo.Jagare
的用法示例。
在下文中一共展示了Jagare.diff方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: diff
# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import diff [as 别名]
def diff(self, path, ref, from_ref, ignore_space, flags,
context_lines, paths, rename_detection):
try:
repo = Jagare(path)
diff_dict = repo.diff(ref, from_ref=from_ref,
ignore_space=ignore_space, flags=flags,
context_lines=context_lines, paths=paths,
rename_detection=rename_detection)
return DiffConverter(**diff_dict).convert()
except Exception as e:
raise ServiceUnavailable(repr(e))
示例2: Repo
# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import diff [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 is_empty(self):
return self.repo.empty
@property
def default_branch(self):
branch = None
head = self.repo.head
if head:
branch = head.name.rpartition('/')[-1]
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):
self.repo.clone(path,
bare=bare, branch=branch,
mirror=mirror, env=env)
def archive(self, name):
content = self.repo.archive(name)
outbuffer = StringIO()
zipfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=outbuffer)
zipfile.writelines(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, *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
#.........这里部分代码省略.........
示例3: Repo
# 需要导入模块: from ellen.repo import Jagare [as 别名]
# 或者: from ellen.repo.Jagare import diff [as 别名]
#.........这里部分代码省略.........
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,
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