From a380bdd51aca3751e42716774a2862319455ea73 Mon Sep 17 00:00:00 2001 From: Mathias Klette Date: Wed, 16 May 2012 18:09:43 +0200 Subject: [PATCH] change git checkout behaviour --- debian_build.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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') -- 2.39.5