From: Mathias Klette Date: Wed, 16 May 2012 16:09:43 +0000 (+0200) Subject: change git checkout behaviour X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=a380bdd51aca3751e42716774a2862319455ea73;p=profitbricks%2Fjenkins-build-scripts.git change git checkout behaviour --- diff --git a/debian_build.py b/debian_build.py index 7abf12c..205b316 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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')