tmpdir = tempfile.mkdtemp(prefix=script_name+".")
try:
# Checkout release repository
- branch = options.release_branch
- if branch is None:
- branch = repo.active_branch.name
+ branch = get_release_repo_branch(logger, options, repo)
logger.info("Check out {branch} branch of {repo} to "
"{dir}...".format(repo=release_repo_uri, branch=branch,
dir=tmpdir))
else:
shutil.rmtree(tmpdir)
+def get_release_repo_branch(logger, options, repo):
+ """Return the branch to use for the release repo."""
+ branch = options.release_branch
+ if branch is None:
+ try:
+ branch = repo.active_branch.name
+ except TypeError as error:
+ msg = ("Getting the active branch name failed: {msg}\nPlease "
+ "specify the branch for the release repository one on the "
+ "command line or in the {env} environment variable if you "
+ "are in a detached head.".format(msg=error.message,
+ env=ENV_RELEASE_BRANCH))
+ logger.error(msg)
+ sys.exit(1)
+ return branch
+
def update_manifest(logger, chroot_name, chroot_user, workdir, ebuild_path):
"""Update manifest file in a Gentoo chroot."""
cmd = ["schroot", "-c", chroot_name, "-u", chroot_user,
def tag_head_commit(logger, repo, new_tag, resolve_existing_msg=""):
"""Tags the head commit with the given tag name."""
- current_commit = repo.commit(repo.active_branch)
+ current_commit = repo.head.commit
tags = [t.name for t in repo.tags if t.commit == current_commit]
if len(tags) > 0:
if len(tags) == 1 and tags[0] == new_tag:
The function will fail if the branch head commit is not tagged or has
multiple tags.
"""
- current_commit = repo.commit(repo.active_branch)
+ current_commit = repo.head.commit
tags = [t.name for t in repo.tags if t.commit == current_commit]
if len(tags) == 0:
logger.error('No tag found for commit {commit}.\nHave you tagged your '