From e486f29b3e3832034da652c4e7e60250cfe83b9e Mon Sep 17 00:00:00 2001 From: Mathias Klette Date: Tue, 28 May 2013 16:40:22 +0200 Subject: [PATCH] debian_build: extend gitrepo object with a dict of all remotes this dict is then used to verify whether any package shall have auto-increment enabled. --- debian_build.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/debian_build.py b/debian_build.py index 1a5b33d..bb34769 100755 --- a/debian_build.py +++ b/debian_build.py @@ -119,10 +119,9 @@ if __name__ == '__main__': daily_date = BUILD_START.strftime('%Y%m%d%H%M%S') # .. repository related + gitrepo = git.Repo('.') local_branch = re.match('^(origin/)?(.*)', ENV['GIT_BRANCH']).groups()[1] remote_branch = os.path.join('origin', local_branch) - reports_file = os.path.join(ENV['WORKSPACE'], '../build-area/result/reports.tgz',) - gitrepo = git.Repo('.') curr_commit = gitrepo.commit(ENV['GIT_COMMIT']) # collect all 'trigger' expressions found in the commit message, i.e. # <<< "[merge][no-test][provisioning] my commit message" @@ -134,6 +133,15 @@ if __name__ == '__main__': # id attribute used in python-git 0.1.6-1 found in squeeze elif hasattr(curr_commit, 'id'): curr_commit_id = curr_commit.id + # 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() + type = type.strip('()') + if not gitrepo.remotes.has_key(name): + gitrepo.remotes.update({name: {type: url}}) + else: + gitrepo.remotes[name].update({type: url}) # Act II: make decissions # compatibility until call_jenkins was replaced @@ -150,7 +158,7 @@ if __name__ == '__main__': if re.match(STABLE_BRANCHES_RE, ENV['GIT_BRANCH']): if re.match('^(ps_|dev_).*$', ENV['JOB_NAME']): logger.error('Use the appropriate job to build for branch "{branch}"!'.format( - branch=ENV['GIT_BRANCH'], + branch=local_branch, )) exit_error() new_dist = 'stable' @@ -161,8 +169,7 @@ if __name__ == '__main__': # replace valid debian version chars that are invalid for git tagging new_tag = curr_version.replace('~', '_').replace(':', ',') # .. only take care of changelog automation if we want it to - # FIXME: this must be reponame in ... - if ENV['GIT_BRANCH'] in AUTO_CHANGELOG_REPONAMES: + if gitrepo.remotes['origin']['fetch'].split('/')[-1] in AUTO_CHANGELOG_REPONAMES: do_autoincrement = True # reset actions if curr_dist == 'squeeze': @@ -185,7 +192,7 @@ if __name__ == '__main__': elif re.match(UNSTABLE_BRANCHES_RE, ENV['GIT_BRANCH']): if not re.match('^ps_.*$', ENV['JOB_NAME']): logger.error('Use the appropriate job to build for branch "{branch}"!'.format( - branch=ENV['GIT_BRANCH'], + branch=local_branch, )) exit_error() new_dist = 'unstable' @@ -205,7 +212,7 @@ if __name__ == '__main__': elif re.match(EXPERIMENTAL_BRANCHES_RE, ENV['GIT_BRANCH']): if not re.match('^dev_.*$', ENV['JOB_NAME']): logger.error('Use the appropriate job to build for branch "{branch}"!'.format( - branch=ENV['GIT_BRANCH'], + branch=local_branch, )) exit_error() @@ -221,7 +228,7 @@ if __name__ == '__main__': else: logger.error('Don\'t know how to handle branch "{branch}".'.format( - branch=ENV['GIT_BRANCH'], + branch=local_branch, )) exit_error() @@ -454,6 +461,10 @@ if __name__ == '__main__': figlet('Reports skipped') else: try: + reports_file = os.path.join( + ENV['WORKSPACE'], + '../build-area/result/reports.tgz', + ) if os.path.exists(reports_file): for cmd in (['/bin/tar', 'xzvf', reports_file, '-C', ENV['WORKSPACE']], ['/usr/bin/sudo', '/bin/rm', '-v', reports_file]): -- 2.39.5