From 268076f4fecf90744333c618a9aa1adb3b61062c Mon Sep 17 00:00:00 2001 From: Mathias Klette Date: Wed, 22 May 2013 18:29:52 +0200 Subject: [PATCH] debian_build: python-git needs special treatment Available in wheezy: git.Repo('.').commit().hexsha squeeze: git.Repo('.').commit().id --- debian_build.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/debian_build.py b/debian_build.py index 8391838..13516fb 100755 --- a/debian_build.py +++ b/debian_build.py @@ -131,11 +131,17 @@ if __name__ == '__main__': daily_date = BUILD_START.strftime('%Y%m%d%H%M%S') # .. repository related - 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',) + gitrepo = git.Repo('.') + curr_commit = gitrepo.commit(ENV['GIT_COMMIT']) + # used in python-git 0.3.2~RC1-1 found in wheezy + if hasattr(curr_commit, 'hexsha'): + curr_commit_id = curr_commit.hexsha + # used in python-git 0.1.6-1 found in squeeze + elif hasattr(curr_commit, 'id'): + curr_commit_id = curr_commit.id # .. dput related (some overrides happening below, though) dput_obj = dput.Dput( @@ -174,7 +180,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.hexsha: + if remote_tag[0].commit.id == curr_commit_id: logger.debug('Tag was already created for this commit.') do_tagging = False else: @@ -195,7 +201,7 @@ if __name__ == '__main__': version = curr_version, date = daily_date, build = ENV['BUILD_NUMBER'], - commit = curr_commit[0:7], + commit = curr_commit_id[0:7], ) pb_suite = 'develop-' + ENV['DISTRIBUTION'] # reset actions @@ -213,7 +219,7 @@ if __name__ == '__main__': version = curr_version, date = daily_date, build = ENV['BUILD_NUMBER'], - commit = curr_commit.hexsha[0:7], + commit = curr_commit_id[0:7], ) pb_suite = 'experimental-' + ENV['DISTRIBUTION'] dput_obj.contents.update({ @@ -246,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.hexsha[0:7]) + # version = '%s~develop%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit_id[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.hexsha[0:7]) + # version = '%s~alpha%s+%s+%s' %(version, daily_date, BUILD_NUMBER, curr_commit_id[0:7]) # changelog_distro = 'unstable' logger.debug('Distribution: "%s" => "%s"' %(curr_dist,new_dist)) @@ -336,7 +342,7 @@ if __name__ == '__main__': '--no-auto-nmu', '--', 'Generated by Jenkins build of commit {commit}'.format( - commit = curr_commit.hexsha[0:7] + commit = curr_commit_id[0:7] ), ] @@ -381,7 +387,7 @@ if __name__ == '__main__': dist = ENV['DISTRIBUTION'], arch = 'amd64', pb_suite = pb_suite, - git_commit_id = curr_commit.hexsha[0:7] + git_commit_id = curr_commit_id[0:7] ) ret = gbp.build() -- 2.39.5