]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
Fix crash with python-git >= 0.3
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Wed, 5 Mar 2014 12:19:10 +0000 (13:19 +0100)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Wed, 5 Mar 2014 12:19:10 +0000 (13:19 +0100)
The Commit id attribute was renamed to hexsha in python-git >= 0.3

debian_build.py

index 8831f322264ddd7743ef75623de7a3bde0c81153..53d1832fb89fe797eb610adb581722f4fd235c33 100755 (executable)
@@ -206,11 +206,15 @@ if __name__ == '__main__':
             #        compatible
             remote_tag = [tag for tag in gitrepo.tags if tag.name == new_tag]
             if not do_autoincrement and len(remote_tag) > 0:
-                # FIXME: .id attribute but avl. in wheezy based git lib
-                if remote_tag[0].commit.id == curr_commit_id:
+                tagged_commit = remote_tag[0].commit
+                if hasattr(tagged_commit, 'hexsha'):
+                    tagged_commit_hexsha = tagged_commit.hexsha
+                else:
+                    tagged_commit_hexsha = tagged_commit.id
+                if tagged_commit_hexsha == curr_commit_id:
                     message = 'Tag {name} was already created for commit {sha}.'.format(
                         name=remote_tag[0].name,
-                        sha=remote_tag[0].commit.id[0:7],
+                        sha=tagged_commit[0:7],
                     )
                     logger.debug(message)
                     do_tagging = False
@@ -218,7 +222,7 @@ if __name__ == '__main__':
                 else:
                     logger.error('Tag {name} was already created for commit {sha}.'.format(
                         name=remote_tag[0].name,
-                        sha=remote_tag[0].commit.id[0:7],
+                        sha=tagged_commit[0:7],
                     ))
                     exit_error()
             else: