]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: Add only a new changelog entry if really needed.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Fri, 25 Jul 2014 19:55:17 +0000 (21:55 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Fri, 25 Jul 2014 19:55:17 +0000 (21:55 +0200)
debian_build.py

index b34c81b5aad254b5f62934fc405b493bf88c9463..3fb88253b134968ff6fe1b429bb55d2d9699cc60 100755 (executable)
@@ -556,6 +556,7 @@ if __name__ == '__main__':
             cl.parse_changelog(open('debian/changelog'))
             new_version = cl.full_version
             new_tag = new_version.replace('~', '_').replace(':', ',')
+            add_changelog_entry = True
         except Exception as error:
             logger.error('Autoincrement failed. Standard error returned:\n\n%s\n' %
                          error.stderr, exc_info=error)
@@ -564,39 +565,44 @@ if __name__ == '__main__':
     # .. or set approriate versions for our development candidates
     else:
         logger.info('Project is not respected by autoincrement.')
-        cmd = [
-            BIN_DCH,
-            '--newversion',
-            '{version}'.format(version=new_version),
-            '--force-bad-version',
-            '--distribution',
-            '{dist}'.format(dist=new_dist),
-            '--force-distribution',
-            '--preserve',
-            '--no-auto-nmu',
-            '--',
-            'Generated by Jenkins build of commit {commit}'.format(
-                commit=curr_commit_hexsha[0:7],
-            ),
-        ]
+        cl = changelog.Changelog()
+        cl.parse_changelog(open('debian/changelog'))
+        add_changelog_entry = new_dist != cl.distributions or new_version != cl.full_version
+        if add_changelog_entry:
+            cmd = [
+                BIN_DCH,
+                '--newversion',
+                '{version}'.format(version=new_version),
+                '--force-bad-version',
+                '--distribution',
+                '{dist}'.format(dist=new_dist),
+                '--force-distribution',
+                '--preserve',
+                '--no-auto-nmu',
+                '--',
+                'Generated by Jenkins build of commit {commit}'.format(
+                    commit=curr_commit_hexsha[0:7],
+                ),
+            ]
 
-        logger.debug('Executing "{command}" ...'.format(command=' '.join(cmd)))
-        dch = subprocess.Popen(
-            cmd,
-            shell=False,
-            close_fds=True,
-            stdin=subprocess.PIPE,
-            stdout=sys.stdout,
-            stderr=sys.stderr,
-            cwd=os.getcwd(),
-        )
-        dch.stdin.write('\n')
-        ret = dch.wait()
-
-        # we need to commit here else git-buildpackage will use the existing debian/changelog...
-        # TODO: Later we should investigate why "--ignore-new" does not work!
-        gitrepo.git.add('-A')
-        gitrepo.git.commit('-a', '-m', 'add new changelog entry')
+            logger.debug('Executing "{command}" ...'.format(command=' '.join(cmd)))
+            dch = subprocess.Popen(
+                cmd,
+                shell=False,
+                close_fds=True,
+                stdin=subprocess.PIPE,
+                stdout=sys.stdout,
+                stderr=sys.stderr,
+                cwd=os.getcwd(),
+            )
+            dch.stdin.write('\n')
+            ret = dch.wait()
+
+        if add_changelog_entry:
+            # we need to commit here else git-buildpackage will use the existing debian/changelog
+            # TODO: Later we should investigate why "--ignore-new" does not work!
+            gitrepo.git.add('-A')
+            gitrepo.git.commit('-a', '-m', 'add new changelog entry')
 
         if ret:
             raise Exception(