diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-06-02 11:57:34 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-06-05 16:16:00 +0300 |
commit | d673c34ada960fbe47014d1795772378e3f6f2df (patch) | |
tree | 8cabcb78c1c229f3ffc8efa2c117c0305295101e | |
parent | 9fa2dab904a0242c11e5f12069b923b1281b2264 (diff) | |
download | git-buildpackage-d673c34ada960fbe47014d1795772378e3f6f2df.tar.gz git-buildpackage-d673c34ada960fbe47014d1795772378e3f6f2df.tar.bz2 git-buildpackage-d673c34ada960fbe47014d1795772378e3f6f2df.zip |
buildpackage-rpm: new 'commitish' keyword for spec vcs tag
Add a new keyword '%(commitish)s' that can be used in the
--git-spec-vcs-tag option. This will be translated to the sha1 of the
commitish (i.e. tag or commit). That is, if you export a tag you will
get the sha1 of the tag object - not resolving to a commit object unlike
'%(commit)s' does.
Change-Id: Ia764e15ac0dc090dde9f8e709f31f66e62120abb
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rwxr-xr-x | gbp/scripts/buildpackage_rpm.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py index 1ada6381..b28ee8ca 100755 --- a/gbp/scripts/buildpackage_rpm.py +++ b/gbp/scripts/buildpackage_rpm.py @@ -203,6 +203,23 @@ def get_current_branch(repo): return branch +def get_vcs_info(repo, treeish): + """Get the info for spec vcs tag""" + info = {} + try: + info['tagname'] = repo.describe(treeish, longfmt=True, always=True, + abbrev=40) + info['commit'] = repo.rev_parse('%s^0' % treeish) + info['commitish'] = repo.rev_parse('%s' % treeish) + except GitRepositoryError: + # If tree is not commit-ish, expect it to be from current HEAD + info['tagname'] = repo.describe('HEAD', longfmt=True, always=True, + abbrev=40) + '-dirty' + info['commit'] = repo.rev_parse('HEAD') + '-dirty' + info['commitish'] = info['commit'] + return info + + def guess_export_params(repo, options): """Get commit and tree from where to export packaging and patches""" tree = None @@ -650,8 +667,7 @@ def main(argv): repo.delete_tag(tag) create_packaging_tag(repo, tag, commit=tree, version=spec.version, options=options) - tree_name = tag - commit_sha1 = repo.rev_parse('%s^0' % tag) + vcs_info = get_vcs_info(repo, tag) if options.posttag: sha = repo.rev_parse("%s^{}" % tag) Command(options.posttag, shell=True, @@ -659,19 +675,9 @@ def main(argv): 'GBP_BRANCH': branch, 'GBP_SHA1': sha})() else: - try: - tree_name = repo.describe(tree, longfmt=True, always=True, - abbrev=40) - commit_sha1 = repo.rev_parse('%s^0' % tree) - except GitRepositoryError: - # If tree is not commit-ish, expect it to be from current HEAD - tree_name = repo.describe('HEAD', longfmt=True, always=True, - abbrev=40) + '-dirty' - commit_sha1 = repo.rev_parse('HEAD') + '-dirty' + vcs_info = get_vcs_info(repo, tree) # Put 'VCS:' tag to .spec - spec.set_tag('VCS', None, - options.spec_vcs_tag % {'tagname': tree_name, - 'commit': commit_sha1}) + spec.set_tag('VCS', None, options.spec_vcs_tag % vcs_info) spec.write_spec_file() except CommandExecFailed: |