summaryrefslogtreecommitdiff
path: root/gbp/scripts
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-06-02 11:57:34 +0300
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>2014-11-14 14:47:20 +0200
commit355574c5c092c568ce0a2212327b375f22835859 (patch)
tree7855088afc097396fe653fae5bbfd86dde54138d /gbp/scripts
parent3dddcc3929e3d83b247c346ce3e1d126cbf14dca (diff)
downloadgit-buildpackage-355574c5c092c568ce0a2212327b375f22835859.tar.gz
git-buildpackage-355574c5c092c568ce0a2212327b375f22835859.tar.bz2
git-buildpackage-355574c5c092c568ce0a2212327b375f22835859.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. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp/scripts')
-rwxr-xr-xgbp/scripts/buildpackage_rpm.py34
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: