if not os.path.isfile('debian/changelog'):
logger.error("No Debian changelog found. Please add a debian/changelog"
"file or disable the auto-version feature.")
+ sys.exit(1)
changelog_file = open('debian/changelog')
changelog = debian.changelog.Changelog(changelog_file, max_blocks=1)
if changelog.distributions == "UNRELEASED":
new_tag = version_substitution(logger, pattern, repo.head.commit)
logger.info("The pattern '{pattern}' evaluates to the version "
"'{version}'.".format(pattern=pattern, version=new_tag))
- tag_head_commit(logger, repo, new_tag)
+ tag_head_commit(logger, repo, new_tag, changelog.full_version)
return new_tag
return new_tag
-def tag_head_commit(logger, repo, new_tag, resolve_existing_msg=""):
+def tag_head_commit(logger, repo, new_tag, resolve_existing_msg="", debversion=None):
"""Tags the head commit with the given tag name."""
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:
+ if debversion and debversion in tags:
+ msg = ('The head commit {commit} is already tagged: {tags}\n'
+ 'This indicates that this commit was already released and a package built. '
+ 'Therefore doing nothing.')
+ msg = msg.format(commit=format_commit(current_commit),
+ tags=" ".join(tags))
+ logger.info(msg)
+ sys.exit(0)
+ elif len(tags) == 1 and tags[0] == new_tag:
msg = ('The head commit {commit} is already tagged with {tag}.\n'
'Call this script without --tag-from-debian-changelog '
'to release the ebuild file.')
msg = msg.format(commit=format_commit(current_commit), tag=new_tag)
else:
- # TODO: Fix error message when auto-tagging
msg = ('The head commit {commit} is already tagged: {tags}\n'
'The script expects a commit without additional tags.')
msg = msg.format(commit=format_commit(current_commit),