version = changelog.full_version
# Replace valid Debian version chars that are invalid for git tagging
new_tag = version.replace('~', '_').replace(':', ',')
- tag_head_commit(logger, new_tag)
+ resolve_existing_msg = (" Have you forgotten to create a new Debian "
+ "changelog entry?")
+ tag_head_commit(logger, new_tag, resolve_existing_msg)
return new_tag
-def tag_head_commit(logger, new_tag):
+def tag_head_commit(logger, new_tag, resolve_existing_msg=""):
"""Tags the head commit with the given tag name."""
repo = git.Repo('.')
current_commit = repo.commit(repo.active_branch)
sys.exit(1)
remote_tag = [t for t in repo.tags if t.name == new_tag]
if len(remote_tag) > 0:
- msg = 'Tag {tag} was already created for commit {commit}.'
- logger.error(msg.format(tag=new_tag,
- commit=remote_tag[0].commit.hexsha[0:7]))
+ msg = ('Tag {tag} was already created for commit '
+ '{commit}.'.format(tag=new_tag,
+ commit=remote_tag[0].commit.hexsha[0:7]))
+ logger.error(msg + resolve_existing_msg)
sys.exit(1)
logger.info("Tagging commit {commit} with {tag}"
"...".format(commit=current_commit.hexsha[0:7], tag=new_tag))