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


Python Git.blame方法代码示例

本文整理汇总了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
开发者ID:2flcastro,项目名称:ka-lite,代码行数:70,代码来源:base.py


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