本文整理汇总了Python中pygit2.Repository.create_branch方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.create_branch方法的具体用法?Python Repository.create_branch怎么用?Python Repository.create_branch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygit2.Repository
的用法示例。
在下文中一共展示了Repository.create_branch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Repo
# 需要导入模块: from pygit2 import Repository [as 别名]
# 或者: from pygit2.Repository import create_branch [as 别名]
class Repo(object):
def __init__(self, path="", branch="develop"):
self.path = path if path else os.getcwd()
# Retrieve the repo if its already defined
try:
self.repo = Repository(self.path)
# This is a little hacky, but we need a git command interface to do
# certain things
self.pygitrepo = git.Repo(self.repo.path)
self.git = self.pygitrepo.git
self.currentBranch = self.repo.lookup_branch(self.repo.head.shorthand)
self._user = self.repo.default_signature
except KeyError:
self.repo = None
self.currentBranch = None
self._user = None
# TODO Handle this another way
self.branch = branch
@property
def user(self):
if not self._user and self.repo:
self._user = self.repo.default_signature
return self._user
def clone(self, repourl):
self.repo = clone_repository(
repourl,
self.path,
checkout_branch=self.branch
)
def checkoutBranch(self, name):
# TODO check if a branch of this name exists
developBranch = self.repo.lookup_branch("develop")
self.repo.checkout(developBranch)
self.currentBranch = self.repo.create_branch(
name,
self.repo.head.get_object()
)
self.repo.checkout(self.currentBranch)
def merge(self, branch, delete=False, push=False):
pass
def release(self):
# Checkout the release branch
# Need some way to control versioning
# Internal versioning
pass