本文整理汇总了Python中git.cmd.Git.symbolic_ref方法的典型用法代码示例。如果您正苦于以下问题:Python Git.symbolic_ref方法的具体用法?Python Git.symbolic_ref怎么用?Python Git.symbolic_ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.cmd.Git
的用法示例。
在下文中一共展示了Git.symbolic_ref方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createRelease
# 需要导入模块: from git.cmd import Git [as 别名]
# 或者: from git.cmd.Git import symbolic_ref [as 别名]
def createRelease(self, name, parent=None):
super(PuppetInstallMethod, self).createRelease(name, parent)
with puppet_lock:
# Move to concrete directory name
orig_name = name
name = name.replace("/", "@")
# Clone repository
cmd = Git(self.__work_path)
if parent:
if isinstance(parent, StringTypes):
parent = parent.replace("/", "@")
else:
parent = parent.name.replace("/", "@")
self.log.debug("cloning new git branch '%s' from '%s'"
% (name, parent))
cmd.clone(self.__repo_path, name, b=parent)
else:
self.log.debug("creating new git branch '%s'" % name)
cmd.clone(self.__repo_path, name)
# Switch branch, add information
cmd = Git(os.path.join(self.__work_path, name))
host = self.env.id
cmd.config("--global", "user.name", "GOsa management agent on %s" % host)
self.log.debug("switching to newly created branch")
cmd.checkout(b=name)
# Remove refs if there's no parent
current_dir = os.path.join(self.__work_path, name)
if not parent:
self.log.debug("no parent set - removing refs")
cmd.symbolic_ref("HEAD", "refs/heads/newbranch")
os.remove(os.path.join(current_dir, ".git", "index"))
files = os.listdir(current_dir)
# Remove all but .git
for f in files:
if f== ".git":
continue
if os.path.isdir(f):
shutil.rmtree(os.path.join(current_dir, f))
else:
os.unlink(os.path.join(current_dir, f))
# Create release info file
self.log.debug("writing release info file in %s" % current_dir)
with open(os.path.join(current_dir, "release.info"), "w") as f:
now = datetime.now()
f.write("Release: %s\n" % orig_name)
f.write("Date: %s\n" % now.strftime("%Y-%m-%d %H:%M:%S"))
self.log.debug("comitting new release")
cmd.add("release.info")
cmd.commit(m="Created release information")
# Push to origin
self.log.debug("pushing change to central repository")
cmd.push("origin", name)
return True