From: Mathias Klette Date: Wed, 22 May 2013 09:13:48 +0000 (+0200) Subject: use a real git.Repo().commit() object X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=e9eed39d24a6fb1e9fbce164d608912892b305a9;p=profitbricks%2Fjenkins-build-scripts.git use a real git.Repo().commit() object as preparation for vdc-bundles-integration scheme: requirements define to evaluate commit message for different triggers: * [merge]: integrate all commits of currently committing branch into 'integration'-branch by using 'rebase' * [no-test]: package build should not run any tests according to documentation, http://goo.gl/kS1rB, * [no-test] will be ignored if [merge] is also given in the commit message * [no-test] will be ignored for 'integration' branch at all - it must run the full set of tests! we can access the commit message like this: >>> curr_commit.message <<< u'test commit\n' --- diff --git a/debian_build.py b/debian_build.py index 05822df..bd4aa57 100755 --- a/debian_build.py +++ b/debian_build.py @@ -131,8 +131,8 @@ if __name__ == '__main__': daily_date = BUILD_START.strftime('%Y%m%d%H%M%S') # .. repository related - curr_commit = ENV['GIT_COMMIT'] gitrepo = git.Repo('.') + curr_commit = gitrepo.commit(ENV['GIT_COMMIT']) 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',) @@ -174,7 +174,7 @@ if __name__ == '__main__': # except, the existing tag uses the same commit as we were triggered with remote_tag = [tag for tag in gitrepo.tags if tag.name == new_tag] if len(remote_tag) > 0: - if remote_tag[0].commit.id == curr_commit: + if remote_tag[0].commit.id == curr_commit.hexsha: logger.debug('Tag was already created for this commit.') do_tagging = False else: @@ -213,7 +213,7 @@ if __name__ == '__main__': version = curr_version, date = daily_date, build = ENV['BUILD_NUMBER'], - commit = curr_commit[0:7], + commit = curr_commit.hexsha[0:7], ) pb_suite = 'experimental-' + ENV['DISTRIBUTION'] dput_obj.contents.update({ @@ -252,12 +252,12 @@ if __name__ == '__main__': #FIXME: get rid of jenkins parameter, instead use git remote #if GIT_REPO_PATH.startswith('/srv/git/dev/'): # if ENV['GIT_BRANCH_NAME'] == 'pre-staging': - # version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit[0:7]) + # version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit.hexsha[0:7]) # changelog_distro = 'pre-staging' # else: # # use shorter date because we can # daily_date = datetime.datetime.now().strftime('%Y%m%d') - # version = '%s~alpha%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit[0:7]) + # version = '%s~alpha%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit.hexsha[0:7]) # changelog_distro = 'unstable' logger.debug('Distribution: "%s" => "%s"' %(curr_dist,new_dist)) @@ -342,7 +342,7 @@ if __name__ == '__main__': '--no-auto-nmu', '--', 'Generated by Jenkins build of commit {commit}'.format( - commit = curr_commit[0:7] + commit = curr_commit.hexsha[0:7] ), ] @@ -387,7 +387,7 @@ if __name__ == '__main__': dist = ENV['DISTRIBUTION'], arch = 'amd64', pb_suite = pb_suite, - git_commit_id = curr_commit[0:7] + git_commit_id = curr_commit.hexsha[0:7] ) ret = gbp.build()