]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build: some reorganization
authorMathias Klette <mathias.klette@profitbricks.com>
Wed, 5 Jun 2013 18:07:51 +0000 (20:07 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Wed, 5 Jun 2013 18:07:51 +0000 (20:07 +0200)
debian_build.py

index d5238e5a5ab03223974919c5c69ea88d0d48104f..4a10e0d068022496d288053dddbbe398ff2248dc 100755 (executable)
@@ -112,16 +112,9 @@ if __name__ == '__main__':
     do_tagging = False
     do_uploads = True
 
-    cl = changelog.Changelog()
-    cl.parse_changelog(open('debian/changelog'))
-    curr_name = cl.package
-    curr_version = cl.full_version
-    curr_dist = cl.distributions
-    daily_date = BUILD_START.strftime('%Y%m%d%H%M%S')
-
     # .. repository related
     gitrepo = git.Repo('.')
-    # this should be part of 'git' lib, but it isn't right now
+    #    this should be part of 'git' lib, but it isn't right now
     gitrepo.remotes = {}
     for remote in gitrepo.git.remote('-v').split('\n'):
         name, url, type = remote.split()
@@ -130,29 +123,39 @@ if __name__ == '__main__':
             gitrepo.remotes.update({name: {type: url}})
         else:
             gitrepo.remotes[name].update({type: url})
-    # this would also be helpful, but is not yet included in git lib
+    #    this would also be helpful, but is not yet included in git lib
     gitrepo.name = gitrepo.remotes['origin']['fetch'].split('/')[-1]
-    # some local variables
+
+    # .. some local variables
+    daily_date = BUILD_START.strftime('%Y%m%d%H%M%S')
     local_branch = re.match('^(origin/)?(.*)', ENV['GIT_BRANCH']).groups()[1]
     remote_branch = os.path.join('origin', local_branch)
-    curr_commit = gitrepo.commit(remote_branch)
-    # id attribute used in python-git 0.3.2~RC1-1 found in wheezy
-    if hasattr(curr_commit, 'hexsha'):
-        curr_commit_id = curr_commit.hexsha
-    # id attribute used in python-git 0.1.6-1 found in squeeze
-    elif hasattr(curr_commit, 'id'):
-        curr_commit_id = curr_commit.id
+
+    try:
+        curr_commit = gitrepo.commit(remote_branch)
+        # id attribute used in python-git 0.3.2~RC1-1 found in wheezy
+        if hasattr(curr_commit, 'hexsha'):
+            curr_commit_id = curr_commit.hexsha
+        # id attribute used in python-git 0.1.6-1 found in squeeze
+        elif hasattr(curr_commit, 'id'):
+            curr_commit_id = curr_commit.id
+    except Exception as error:
+        logger.error('Failed to find commit for {input}'.format(
+            input=remote_branch,
+            ), 
+            exc_info=error
+        )
+
+    # .. content related
+    cl = changelog.Changelog()
+    cl.parse_changelog(open('debian/changelog'))
+    curr_name = cl.package
+    curr_version = cl.full_version
+    curr_dist = cl.distributions
 
 
     # Act II: make decissions
     # compatibility until call_jenkins was replaced
-    if ENV['GIT_BRANCH'] not in [branch.name for branch in gitrepo.branches]:
-        logger.error('No branch {branch} found in {name}'.format(
-            branch=ENV['GIT_BRANCH'],
-            name=gitrepo.name,
-        ))
-        exit_error()
-
     if curr_dist not in ('squeeze', 'wheezy'):
         logger.warn('Compatibility Mode: Change distribution {old} => {new}.'.format(
             old=curr_dist,