From 7f3e51c9789fa575d28cea5ab13ba17a371aead8 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Wed, 8 Feb 2012 16:25:01 +0100 Subject: [PATCH] no duplicate build log output --- debian_build.py | 56 +++++++++++++++++++++++++---------------------- lib/git_helper.py | 22 ++++++++++++++++--- 2 files changed, 49 insertions(+), 29 deletions(-) diff --git a/debian_build.py b/debian_build.py index fd32029..66b97bd 100755 --- a/debian_build.py +++ b/debian_build.py @@ -80,7 +80,7 @@ DPUT_OPTIONS_DEV = { 'allow_unsigned_uploads': 1, 'post_upload_command': 'ssh reprepro@alexandria.profitbricks.localdomain /srv/dev-repository/bin/pb_processincoming', } -DPUT_CF = os.path.join(GIT_TARGET_WORKSPACE, 'dput.cf') +DPUT_CF = os.path.join(CWD, '..', 'dput.cf') NO_UPLOAD = os.environ.get('NO_UPLOAD') @@ -234,16 +234,16 @@ if __name__ == '__main__': ) ) ) - logging.getLogger('lib.git_helper').setLevel(logging.DEBUG) + #logging.getLogger('lib.git_helper').setLevel(logging.DEBUG) options, args = getopts() - if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR): - logger.info('git clone was successfull') - else: - logger_loud_error('git clone was not successfull') - exit_error() + #if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR): + # logger.info('git clone was successfull') + #else: + # logger_loud_error('git clone was not successfull') + # exit_error() - atexit.register(remove_git_target_workspace) - os.chdir(GIT_TARGET_DIR) + #atexit.register(remove_git_target_workspace) + #os.chdir(GIT_TARGET_DIR) # FIXME: this is just needed for gbp and can go away eventually if GIT_BRANCH_NAME: @@ -259,8 +259,8 @@ if __name__ == '__main__': repo = git.repo.Repo() - if GIT_BRANCH_NAME != 'master': - git_helper.git_new_branch_from( + #if GIT_BRANCH_NAME != 'master': + git_helper.git_new_branch_from( GIT_BRANCH_NAME, os.path.join('origin', GIT_BRANCH_NAME) ) @@ -269,16 +269,16 @@ if __name__ == '__main__': # treeish refspec when a name was given (i.e. tag names, branch names, # etc.) # TODO: upgrade git-buildpackage - GIT_UPSTREAM_BRANCH = git_helper.git_get_treeish( - os.path.join('origin', GIT_UPSTREAM_BRANCH) - ) + #GIT_UPSTREAM_BRANCH = git_helper.git_get_treeish( + # os.path.join('origin', GIT_UPSTREAM_BRANCH) + #) # now checkout the requested branch - if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH): - logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH) - else: - logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH) - exit_error() + #if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH): + # logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH) + #else: + # logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH) + # exit_error() # we need to make sure our jenkins config is used, so let's delete any # other config available in repository that might be prefered @@ -435,6 +435,10 @@ if __name__ == '__main__': logger.info('used to start git-buildpackage here...') ret = gbp.build() + # remove last commit (the one where we added the changelog entry) + cmd = ['/usr/bin/git', 'reset', '--soft', 'HEAD~1'] + subprocess.check_call(cmd) + # now handle gpb result if ret: logger_loud_error( 'git-buildpackage returned non-zero. exitcode was: %s' % ret @@ -444,12 +448,12 @@ if __name__ == '__main__': logger.debug('git-buildpackage executed successfully') # if not ret: build_log=os.path.join('../build-area/result/', '%s_%s_amd64.build' % (pkg_name, version)) - try: - fh = open(build_log, 'r') - logger.debug('Output of the deb build: %s' % (fh.read())) - fh.close() - except: - pass +# try: +# fh = open(build_log, 'r') +# logger.debug('Output of the deb build: %s' % (fh.read())) +# fh.close() +# except: +# pass # exit_error() # else: try: @@ -457,7 +461,7 @@ if __name__ == '__main__': # strip epoch if ":" in version: version = version.split(":", 1)[1] - changes_file = os.path.join(GIT_TARGET_WORKSPACE, 'build-area/result/', '%s_%s_amd64.changes' % (pkg_name, version)) + changes_file = os.path.join(CWD, '../build-area/result/', '%s_%s_amd64.changes' % (pkg_name, version)) # display changes file fh = open(changes_file, 'r') logger.info('%s' % (fh.read())) diff --git a/lib/git_helper.py b/lib/git_helper.py index f6020b5..48fa7c9 100644 --- a/lib/git_helper.py +++ b/lib/git_helper.py @@ -71,10 +71,26 @@ def git_clone_remote_repository(url, destination): return True def git_new_branch_from(branch_name, from_branch): + if git_repo_has_branch(branch_name): + cmd = [GIT, 'branch', '-D', branch_name] + + cmdobj = subprocess.Popen( + cmd, + shell=False, + close_fds=True, + stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + env={'':''}, + cwd=os.getcwd() + ) + + # this should not happen, we just deleted it if git_repo_has_branch(branch_name): raise BranchExistError(branch_name) -# if not git_repo_has_branch(from_branch): -# raise BranchNotExistError(from_branch) + + #if not git_repo_has_branch(from_branch): + # raise BranchNotExistError(from_branch) + cmd = [GIT, 'checkout', '-b', branch_name, from_branch] cmdobj = subprocess.Popen( @@ -117,9 +133,9 @@ def git_checkout_branch(branch_name): # and there is proper error handling below anyway... #if not git_repo_has_branch(branch_name): #raise BranchNotExistError(branch_name) - cmd = [GIT, 'checkout', branch_name] + cmdobj = subprocess.Popen( cmd, shell=False, -- 2.39.5