From: Benjamin Drung Date: Tue, 12 Aug 2014 13:57:41 +0000 (+0200) Subject: debian_build.py: Only reset the latest git commit if it was added. X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=56b0ba2f793030a7af9db670b5767d889de05b73;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: Only reset the latest git commit if it was added. --- diff --git a/debian_build.py b/debian_build.py index e8d448c..ef70420 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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: