]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
gentoo_build: Do not fail in auto-tagging mode for released commits.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Mon, 19 May 2014 09:12:36 +0000 (11:12 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Mon, 19 May 2014 09:12:36 +0000 (11:12 +0200)
gentoo_build

index 139959a5763b42a4d48aa7e3955dbef27f996a10..1d546d58fac1ea7914c7c64745123f633a93f58e 100755 (executable)
@@ -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),