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


Python Git.status方法代码示例

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


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

示例1: gitPush

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import status [as 别名]
    def gitPush(self, path, comment=None):
            # Announce changes to git
            cmd = Git(path)
            changed = False
            for line in cmd.status("--porcelain").splitlines():
                changed = True
                line = line.lstrip()
                self.log.info("staging changes for %s" % line.split(" ", 1)[1:])

                mode, file_path = line.split(" ", 1)
                file_path = os.path.join(*file_path.split("/")[0:])

                # Remove data?
                if mode == "D":
                    cmd.rm("-r", file_path)

                # Add data...
                else:
                    cmd.add(file_path)

            # No need to deal...
            if not changed:
                return False

            # Commit changes
            if not comment:
                comment = "Change made with no comment"

            self.log.info("committing changes for module %s" % path)
            cmd.commit("-m", comment)
            cmd.push("origin")

            return True
开发者ID:lhm-limux,项目名称:gosa,代码行数:35,代码来源:methods.py

示例2: Repo

# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import status [as 别名]

#.........这里部分代码省略.........
		else:
			return list()

	def _set_alternates(self, alts):
		"""Sets the alternates

		:parm alts:
			is the array of string paths representing the alternates at which 
			git should look for objects, i.e. /home/user/repo/.git/objects

		:raise NoSuchPathError:
		:note:
			The method does not check for the existance of the paths in alts
			as the caller is responsible."""
		alternates_path = join(self.git_dir, 'objects', 'info', 'alternates') 
		if not alts:
			if isfile(alternates_path):
				os.remove(alternates_path)
		else:
			try:
				f = open(alternates_path, 'w')
				f.write("\n".join(alts))
			finally:
				f.close()
			# END file handling 
		# END alts handling

	alternates = property(_get_alternates, _set_alternates, doc="Retrieve a list of alternates paths or set a list paths to be used as alternates")

	def is_dirty(self, index=True, working_tree=True, untracked_files=False):
		"""
		:return:
			``True``, the repository is considered dirty. By default it will react
			like a git-status without untracked files, hence it is dirty if the 
			index or the working copy have changes."""
		if self._bare:
			# Bare repositories with no associated working directory are
			# always consired to be clean.
			return False
		
		# start from the one which is fastest to evaluate
		default_args = ('--abbrev=40', '--full-index', '--raw')
		if index: 
			# diff index against HEAD
			if isfile(self.index.path) and self.head.is_valid() and \
				len(self.git.diff('HEAD', '--cached', *default_args)):
				return True
		# END index handling
		if working_tree:
			# diff index against working tree
			if len(self.git.diff(*default_args)):
				return True
		# END working tree handling
		if untracked_files:
			if len(self.untracked_files):
				return True
		# END untracked files
		return False
		
	@property
	def untracked_files(self):
		"""
		:return:
			list(str,...)
			
			Files currently untracked as they have not been staged yet. Paths 
开发者ID:2flcastro,项目名称:ka-lite,代码行数:70,代码来源:base.py


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