本文整理汇总了Python中git.cmd.Git.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Git.execute方法的具体用法?Python Git.execute怎么用?Python Git.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.cmd.Git
的用法示例。
在下文中一共展示了Git.execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: command
# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import execute [as 别名]
def command(self, command):
"""
Runs the Git command in self.repo
"""
args = split(command)
cmd = Git(self.repodir)
cmd.execute(args)
示例2: get_days_since_last_update
# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import execute [as 别名]
def get_days_since_last_update(path):
"""
:return: The days since the last update of any of the files in path. If the
path points to a filename, the last update of that filename is
returned.
"""
git = Git(".")
cmd_str = "git log -1 --format=%%cd %s" % path
cmd = shlex.split(cmd_str)
try:
date_str = git.execute(command=cmd, with_extended_output=False)
except GitCommandError:
raise ValueError('"%s" is not in tracked by this repository.' % path)
# The date_str is in the following format: Sat Jun 21 10:20:31 2014 -0300
# We need to parse it, and then do some date math to return the result
#
# We ignore the UTC offset because it was "hard to parse" and we don't care
last_commit_time = datetime.strptime(date_str[:-6], "%a %b %d %H:%M:%S %Y")
last_commit_date = last_commit_time.date()
today_date = date.today()
time_delta = today_date - last_commit_date
return time_delta.days
示例3: update_repo
# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import execute [as 别名]
def update_repo(project, mirror_dir, gerrit_url):
"""Utility function to mirror git repo
Arguments:
:arg str project: Git project to mirror
:arg str mirror_dir: Path to directory containing repos.
:arg str gerrit_url: URL to the Gerrit server. Used for cloning repos.
"""
log.debug("Updating repo for {0}".format(project))
project_dir = os.path.join(mirror_dir, '{0}.git'.format(project))
if os.path.exists(project_dir):
args = ['git', 'fetch']
else:
os.makedirs(project_dir)
args = ['git', 'clone', '--mirror',
'{0}/{1}'.format(gerrit_url, project), '.']
project_repo = Git(project_dir)
project_repo.execute(args)