本文整理汇总了Python中git.cmd.Git.blame方法的典型用法代码示例。如果您正苦于以下问题:Python Git.blame方法的具体用法?Python Git.blame怎么用?Python Git.blame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.cmd.Git
的用法示例。
在下文中一共展示了Git.blame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Repo
# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import blame [as 别名]
#.........这里部分代码省略.........
list(str,...)
Files currently untracked as they have not been staged yet. Paths
are relative to the current working directory of the git command.
:note:
ignored files will not appear here, i.e. files mentioned in .gitignore"""
# make sure we get all files, no only untracked directores
proc = self.git.status(untracked_files=True, as_process=True)
stream = iter(proc.stdout)
untracked_files = list()
for line in stream:
if not line.startswith("# Untracked files:"):
continue
# skip two lines
stream.next()
stream.next()
for untracked_info in stream:
if not untracked_info.startswith("#\t"):
break
untracked_files.append(untracked_info.replace("#\t", "").rstrip())
# END for each utracked info line
# END for each line
return untracked_files
@property
def active_branch(self):
"""The name of the currently active branch.
:return: Head to the active branch"""
return self.head.reference
def blame(self, rev, file):
"""The blame information for the given file at the given revision.
:parm rev: revision specifier, see git-rev-parse for viable options.
:return:
list: [git.Commit, list: [<line>]]
A list of tuples associating a Commit object with a list of lines that
changed within the given commit. The Commit objects will be given in order
of appearance."""
data = self.git.blame(rev, '--', file, p=True)
commits = dict()
blames = list()
info = None
for line in data.splitlines(False):
parts = self.re_whitespace.split(line, 1)
firstpart = parts[0]
if self.re_hexsha_only.search(firstpart):
# handles
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 1 1 7 - indicates blame-data start
# 634396b2f541a9f2d58b00be1a07f0c358b999b3 2 2
digits = parts[-1].split(" ")
if len(digits) == 3:
info = {'id': firstpart}
blames.append([None, []])
# END blame data initialization
else:
m = self.re_author_committer_start.search(firstpart)
if m:
# handles:
# author Tom Preston-Werner
# author-mail <[email protected]>
# author-time 1192271832