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


Python Git.diff方法代码示例

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


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

示例1: Repo

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import diff [as 别名]
class Repo(object):
	"""Represents a git repository and allows you to query references, 
	gather commit information, generate diffs, create and clone repositories query
	the log.
	
	The following attributes are worth using:
	
	'working_dir' is the working directory of the git command, wich is the working tree 
	directory if available or the .git directory in case of bare repositories
	
	'working_tree_dir' is the working tree directory, but will raise AssertionError
	if we are a bare repository.
	
	'git_dir' is the .git repository directoy, which is always set."""
	DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
	__slots__ = ( "working_dir", "_working_tree_dir", "git_dir", "_bare", "git", "odb" )
	
	# precompiled regex
	re_whitespace = re.compile(r'\s+')
	re_hexsha_only = re.compile('^[0-9A-Fa-f]{40}$')
	re_hexsha_shortened = re.compile('^[0-9A-Fa-f]{4,40}$')
	re_author_committer_start = re.compile(r'^(author|committer)')
	re_tab_full_line = re.compile(r'^\t(.*)$')
	
	# invariants
	# represents the configuration level of a configuration file
	config_level = ("system", "global", "repository")

	def __init__(self, path=None, odbt = DefaultDBType):
		"""Create a new Repo instance

		:param path: is the path to either the root git directory or the bare git repo::

			repo = Repo("/Users/mtrier/Development/git-python")
			repo = Repo("/Users/mtrier/Development/git-python.git")
			repo = Repo("~/Development/git-python.git")
			repo = Repo("$REPOSITORIES/Development/git-python.git")
		
		:param odbt: Object DataBase type - a type which is constructed by providing 
			the directory containing the database objects, i.e. .git/objects. It will
			be used to access all object data
		:raise InvalidGitRepositoryError:
		:raise NoSuchPathError:
		:return: git.Repo """
		epath = os.path.abspath(os.path.expandvars(os.path.expanduser(path or os.getcwd())))

		if not os.path.exists(epath):
			raise NoSuchPathError(epath)

		self.working_dir = None
		self._working_tree_dir = None
		self.git_dir = None
		curpath = epath
		
		# walk up the path to find the .git dir
		while curpath:
			if is_git_dir(curpath):
				self.git_dir = curpath
				self._working_tree_dir = os.path.dirname(curpath)
				break
			gitpath = join(curpath, '.git')
			if is_git_dir(gitpath):
				self.git_dir = gitpath
				self._working_tree_dir = curpath
				break
			curpath, dummy = os.path.split(curpath)
			if not dummy:
				break
		# END while curpath
		
		if self.git_dir is None:
		   raise InvalidGitRepositoryError(epath)

		self._bare = False
		try:
			self._bare = self.config_reader("repository").getboolean('core','bare') 
		except Exception:
			# lets not assume the option exists, although it should
			pass

		# adjust the wd in case we are actually bare - we didn't know that 
		# in the first place
		if self._bare:
			self._working_tree_dir = None
		# END working dir handling
		
		self.working_dir = self._working_tree_dir or self.git_dir
		self.git = Git(self.working_dir)
		
		# special handling, in special times
		args = [join(self.git_dir, 'objects')]
		if issubclass(odbt, GitCmdObjectDB):
			args.append(self.git)
		self.odb = odbt(*args)

	def __eq__(self, rhs):
		if isinstance(rhs, Repo):
			return self.git_dir == rhs.git_dir
		return False
		
#.........这里部分代码省略.........
开发者ID:2flcastro,项目名称:ka-lite,代码行数:103,代码来源:base.py


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