本文整理汇总了Python中git.Repo.init_bare方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.init_bare方法的具体用法?Python Repo.init_bare怎么用?Python Repo.init_bare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.init_bare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: puppetInitialize
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import init_bare [as 别名]
def puppetInitialize(self, purge=False):
""" (Re-) initialize client side puppet data stores """
ssh_path = self.__base_dir + "/.ssh"
git_path = self.__base_dir + "/data.git"
# Eventually purge old data
if purge:
self.log.info("puring git and ssh infrastructure")
if os.path.exists(ssh_path):
rmtree(ssh_path)
if os.path.exists(git_path):
rmtree(git_path)
# Clean __target_dir without removing it
if os.path.exists(self.__target_dir):
for root, dirs, files in os.walk(self.__target_dir):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
rmtree(os.path.join(root, d))
self.log.info("initializing git and ssh infrastructure")
# Create .ssh container if it does not exist
if not os.path.exists(ssh_path):
self.log.debug("creating %s" % ssh_path)
os.mkdir(ssh_path, 0770)
# Create target directory
if not os.path.exists(self.__target_dir):
self.log.debug("creating %s" % self.__target_dir)
os.mkdir(self.__target_dir, 0770)
# Create git container if it does not exist
if not os.path.exists(git_path):
# Initialize a bare git repository
self.log.debug("creating bare git repository at '%s'" % git_path)
Repo.init_bare(git_path) #@UndefinedVariable
os.chmod(git_path, 0770)
# Create post-update hook
self.log.debug("installing post-update hook")
with open(git_path + "/hooks/post-update", "w") as f:
f.write("#!/bin/sh\ngit archive --format=tar HEAD | (cd %s && tar xf -)\ndbus-send --system --type=method_call --dest=org.clacks /org/clacks/puppet org.clacks.dbus_run_puppet" % self.__target_dir)
os.chmod(git_path + "/hooks/post-update", 0755)