summaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2016-06-28 16:53:18 +0200
committerGuido Günther <agx@sigxcpu.org>2016-06-28 17:07:43 +0200
commitdb077c97e9b42abf34d9b4e492383dc43a5e03d3 (patch)
tree4c379a935bda12303a2f681a79ad3e72241c1a17 /gbp
parent2e530138857c2a9e4d743461a38dff438d0b67c6 (diff)
import_orig: Simplify vcs_tag_parent
by moving it to a import orig specific repository class
Diffstat (limited to 'gbp')
-rw-r--r--gbp/scripts/import_orig.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py
index c17dca26..6bcde54e 100644
--- a/gbp/scripts/import_orig.py
+++ b/gbp/scripts/import_orig.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 :
#
-# (C) 2006, 2007, 2009, 2011, 2015 Guido Guenther <agx@sigxcpu.org>
+# (C) 2006, 2007, 2009, 2011, 2015, 2016 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -36,6 +36,19 @@ from gbp.scripts.common.import_orig import (orig_needs_repack, cleanup_tmp_tree,
repack_source, is_link_target, download_orig)
+class ImportOrigDebianGitRepository(DebianGitRepository):
+ """
+ Like a DebianGitRepository but can also perform rollbacks and knows
+ about some of the inner workings upstream vcs_tag, …
+ """
+ def vcs_tag_parent(self, vcs_tag_format, version):
+ """If linking to the upstream VCS get the commit id"""
+ if vcs_tag_format:
+ return [self.rev_parse("%s^{}" % self.version_to_tag(vcs_tag_format, version))],
+ else:
+ return None
+
+
def prepare_pristine_tar(archive, pkg, version):
"""
Prepare the upstream source for pristine tar import.
@@ -350,11 +363,11 @@ def main(argv):
try:
try:
- repo = DebianGitRepository('.')
+ repo = ImportOrigDebianGitRepository('.')
except GitRepositoryError:
raise GbpError("%s is not a git repository" % (os.path.abspath('.')))
- # an empty repo has now branches:
+ # an empty repo has no branches:
initial_branch = repo.get_branch()
is_empty = False if initial_branch else True
@@ -415,16 +428,10 @@ def main(argv):
import_branch = [ options.upstream_branch, None ][is_empty]
msg = upstream_import_commit_msg(options, version)
-
- if options.vcs_tag:
- parents = [repo.rev_parse("%s^{}" % repo.version_to_tag(options.vcs_tag, version))]
- else:
- parents = None
-
commit = repo.commit_dir(source.unpacked,
msg=msg,
branch=import_branch,
- other_parents=parents,
+ other_parents=repo.vcs_tag_parent(options.vcs_tag, version),
)
if options.pristine_tar: