本文整理汇总了Python中git.Repo.delete_head方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.delete_head方法的具体用法?Python Repo.delete_head怎么用?Python Repo.delete_head使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.delete_head方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close_working_branch
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_head [as 别名]
def close_working_branch(branch, remote_name):
repo = Repo(get_project_root())
remote = repo.remotes[remote_name]
if repo.is_dirty() == True:
print "The working tree contains uncommitted changes, commit or stash "
print "these and try again."
return 1
print "Summary of actions:"
master = repo.heads.master
master.checkout()
repo.git.merge(branch, '--no-ff')
print ("- Branch " + branch + " was merged into master.")
repo.delete_head(branch, force=True)
print ("- Branch " + branch + " was deleted.")
ret = remote.push(":" + branch)
print ("- Remote branch " + branch + " on " + remote_name + " was deleted.")
remote.push(master)
print ("- Merged changes on master were pushed to " + remote_name + ".")
print "- You are now on branch master."
return 0
示例2: finish_release
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_head [as 别名]
def finish_release(branch):
version = branch.replace("release/", "")
repo = Repo(get_project_root())
remote = repo.remotes["origin"]
if repo.is_dirty() == True:
print "The working tree contains uncommitted changes, commit or stash "
print "these and try again."
return 1
print "Summary of actions:"
stable = repo.heads.stable
stable.checkout()
repo.git.merge(branch, '--no-ff')
print ("- Branch " + branch + " was merged into stable.")
tag = repo.create_tag(version)
print ("- A release tag " + version + " was created.")
remote.push(tag)
print ("- Tag " + version + " was pushed to origin.")
master = repo.heads.master
master.checkout()
repo.git.merge(branch, '--no-ff')
print ("- Branch " + branch + " was merged into master.")
remote.push(master)
print ("- Merged changes on master were pushed to origin.")
remote.push(stable)
print ("- Merged changes on stable were pushed to origin.")
repo.delete_head(branch, force=True)
print ("- Branch " + branch + " was deleted.")
ret = remote.push(":" + branch)
print ("- Remote branch " + branch + " on origin was deleted.")
print "- You are now on branch master."
print ""
return 0
示例3: GitRepoManager
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_head [as 别名]
#.........这里部分代码省略.........
if args:
with open(p, 'a') as wfile:
for ai in args:
wfile.write('{}\n'.format(ai))
self._add_to_repo(p, msg='updated .gitignore')
def get_commit(self, hexsha):
repo = self._repo
return repo.commit(hexsha)
def tag_branch(self, tagname):
repo = self._repo
repo.create_tag(tagname)
def get_current_branch(self):
repo = self._repo
return repo.active_branch.name
def checkout_branch(self, name, inform=True):
repo = self._repo
branch = getattr(repo.heads, name)
try:
branch.checkout()
self.selected_branch = name
self._load_branch_history()
if inform:
self.information_dialog('Repository now on branch "{}"'.format(name))
except BaseException as e:
self.warning_dialog('There was an issue trying to checkout branch "{}"'.format(name))
raise e
def delete_branch(self, name):
self._repo.delete_head(name)
def get_branch(self, name):
return getattr(self._repo.heads, name)
def create_branch(self, name=None, commit='HEAD', inform=True):
repo = self._repo
if name is None:
nb = NewBranchView(branches=repo.branches)
info = nb.edit_traits()
if info.result:
name = nb.name
else:
return
if name not in repo.branches:
branch = repo.create_head(name, commit=commit)
branch.checkout()
if inform:
self.information_dialog('Repository now on branch "{}"'.format(name))
return name
def create_remote(self, url, name='origin', force=False):
repo = self._repo
if repo:
self.debug('setting remote {} {}'.format(name, url))
# only create remote if doesnt exist
if not hasattr(repo.remotes, name):
self.debug('create remote {}'.format(name, url))
repo.create_remote(name, url)
elif force:
repo.delete_remote(name)