]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: Only reset the latest git commit if it was added.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 12 Aug 2014 13:57:41 +0000 (15:57 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Tue, 12 Aug 2014 13:57:41 +0000 (15:57 +0200)
debian_build.py

index e8d448c4970e1b5b1d0101914c85dde1d9a4bef8..ef704206f7c90541ee196ac15e5b144c5779c0ff 100755 (executable)
@@ -543,8 +543,10 @@ if __name__ == '__main__':
                             'This is not allowed, failing...')
 
     # .. and update changelog if we trust the package
+    add_changelog_entry = False
     if do_autoincrement:
         logger.info('This is an autoincrementing project.')
+        add_changelog_entry = True
         try:
             logger.debug(subprocess.check_call([BIN_DCH, '-i', 'Released by jenkins.']))
             logger.debug(subprocess.check_call([BIN_GIT_DCH, '-R', '-a', '--spawn-editor=none']))
@@ -566,7 +568,8 @@ if __name__ == '__main__':
         logger.info('Project is not respected by autoincrement.')
         cl = changelog.Changelog()
         cl.parse_changelog(open('debian/changelog'))
-        if new_dist != cl.distributions or new_version != cl.full_version:
+        add_changelog_entry = new_dist != cl.distributions or new_version != cl.full_version
+        if add_changelog_entry:
             cmd = [
                 BIN_DCH,
                 '--newversion',
@@ -653,8 +656,9 @@ if __name__ == '__main__':
     # .. remove last commit (the one where we added the changelog entry)
     # FIXME: when 'merge': reset only on original branch?
     #                      change checkout back to original branch?
-    logger.info('Reset repository to HEAD~1 to revert develop changelog entry.')
-    logger.debug(gitrepo.git.reset('--soft', 'HEAD~1'))
+    if add_changelog_entry:
+        logger.info('Reset repository to HEAD~1 to revert develop changelog entry.')
+        logger.debug(gitrepo.git.reset('--soft', 'HEAD~1'))
 
     # .. and finally handle the result
     if ret: