]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
change git checkout behaviour
authorMathias Klette <mathias.klette@profitbricks.com>
Wed, 16 May 2012 16:09:43 +0000 (18:09 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Wed, 16 May 2012 16:09:43 +0000 (18:09 +0200)
debian_build.py

index 7abf12c2751419cf99fffeaaa67c52f7dd29672d..205b316e7c0ac67f261377495521d62339c4b77e 100755 (executable)
@@ -253,19 +253,23 @@ if __name__ == '__main__':
     repo = git.repo.Repo()
 
     # reset local repository first
-    logger.debug('Reset and clean repository to HEAD first.')
-    gitcmd = git.Git('.')
-    logger.debug('%s' %(gitcmd.reset('--hard','HEAD')))
-    logger.debug('%s' %(gitcmd.clean('-fdx')))
-
-    #if GIT_BRANCH_NAME != 'master':
     localname = GIT_BRANCH_NAME
     remotename = os.path.join('origin', GIT_BRANCH_NAME)
-    if not git_helper.git_new_branch_from(localname,remotename):
-        raise Exception('Checkout of %s was not successfull.' %( remotename ))
+    try:
+        logger.debug('Reset and clean repository first:')
+        gitcmd = git.Git('.')
+        logger.debug('%s' %(gitcmd.reset('--hard','HEAD')))
+        logger.debug('%s' %(gitcmd.clean('-fdx')))
+        logger.debug('%s' %(gitcmd.checkout('-b %s' %(localname),'%s' %(remotename))))
+    except Exception, exception:
+        raise Exception('Failure while managing Git clone:\n%s' %(exception))
     else:
         logger.debug('Status is now:\n%s' %( gitcmd.status() ))
 
+    ## #if GIT_BRANCH_NAME != 'master':
+    ## if not git_helper.git_new_branch_from(localname,remotename):
+    ##     raise Exception('Checkout of %s was not successfull.' %( remotename ))
+
     # we need to make sure our jenkins config is used, so let's delete any
     # other config available in repository that might be prefered
     #cleanup_files = ('.gbp.conf', 'debian/gbp.conf', '.git/gbp.conf')