本文整理汇总了Python中gbp.deb.git.DebianGitRepository.get_merge_branch方法的典型用法代码示例。如果您正苦于以下问题:Python DebianGitRepository.get_merge_branch方法的具体用法?Python DebianGitRepository.get_merge_branch怎么用?Python DebianGitRepository.get_merge_branch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gbp.deb.git.DebianGitRepository
的用法示例。
在下文中一共展示了DebianGitRepository.get_merge_branch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from gbp.deb.git import DebianGitRepository [as 别名]
# 或者: from gbp.deb.git.DebianGitRepository import get_merge_branch [as 别名]
def main(argv):
retval = 0
current = None
rem_repo = None
(options, args) = parse_args(argv)
if not options:
return ExitCodes.parse_error
gbp.log.setup(options.color, options.verbose, options.color_scheme)
if len(args) == 2:
rem_repo = args[1]
gbp.log.info("Fetching from '%s'" % rem_repo)
else:
gbp.log.info("Fetching from default remote for each branch")
try:
repo = DebianGitRepository(os.path.curdir)
except GitRepositoryError:
gbp.log.err("%s is not a git repository" % (os.path.abspath('.')))
return 1
try:
branches = set()
try:
current = repo.get_branch()
except GitRepositoryError:
# Not being on any branch is o.k. with --ignore-branch
if options.ignore_branch:
current = repo.head
gbp.log.info("Found detached head at '%s'" % current)
else:
raise
(ret, out) = repo.is_clean()
if not ret:
gbp.log.err("You have uncommitted changes in your source tree:")
gbp.log.err(out)
raise GbpError
repo.fetch(rem_repo, depth=options.depth)
repo.fetch(rem_repo, depth=options.depth, tags=True)
fetch_remote = get_remote(repo, current)
for branch in [options.debian_branch, options.upstream_branch]:
if not branch:
continue
if options.track_missing:
track_missing(repo, fetch_remote, branch, options)
if repo.has_branch(branch):
branches.add(branch)
if options.pristine_tar:
branch = repo.pristine_tar_branch
if options.track_missing:
track_missing(repo, fetch_remote, branch, options)
if repo.has_pristine_tar_branch():
branches.add(repo.pristine_tar_branch)
if options.all:
for branch in repo.get_local_branches():
merge_branch = repo.get_merge_branch(branch)
if merge_branch:
rem, rem_br = merge_branch.split('/', 1)
if rem == fetch_remote and branch == rem_br:
branches.add(branch)
for branch in branches:
if not fast_forward_branch(rem_repo, branch, repo, options):
retval = 2
if options.redo_pq:
repo.set_branch(options.debian_branch)
Command("gbp")(["pq", "drop"])
Command("gbp")(["pq", "import"])
repo.set_branch(current)
except KeyboardInterrupt:
retval = 1
gbp.log.err("Interrupted. Aborting.")
except CommandExecFailed:
retval = 1
except (GbpError, GitRepositoryError) as err:
if str(err):
gbp.log.err(err)
retval = 1
return retval