From 5ab05971fd85dfd9353bdc0218a7c407d9e8c16b Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Mon, 19 May 2014 11:12:36 +0200 Subject: [PATCH] gentoo_build: Do not fail in auto-tagging mode for released commits. --- gentoo_build | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gentoo_build b/gentoo_build index 139959a..1d546d5 100755 --- a/gentoo_build +++ b/gentoo_build @@ -479,6 +479,7 @@ def auto_versioning(logger, repo, autodecrement, autoincrement): 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": @@ -503,7 +504,7 @@ def auto_versioning(logger, repo, autodecrement, autoincrement): 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 @@ -527,18 +528,25 @@ def tag_from_debian_changelog(logger, repo): 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), -- 2.39.5