From 8515181255c532fe25cd1b8b0c59814ea0eb2003 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Mon, 22 Jan 2018 14:28:08 +0200 Subject: import-srpm: support --upstream-vcs-tag cmdline option Similar to what the option does in git-import-orig. Signed-off-by: Markus Lehtonen --- docs/manpages/gbp-import-srpm.xml | 14 ++++++++++++++ gbp/scripts/import_srpm.py | 9 +++++++++ tests/component/rpm/test_import_srpm.py | 16 ++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/docs/manpages/gbp-import-srpm.xml b/docs/manpages/gbp-import-srpm.xml index 4520e039..675ad89f 100644 --- a/docs/manpages/gbp-import-srpm.xml +++ b/docs/manpages/gbp-import-srpm.xml @@ -34,6 +34,7 @@ BRANCH-NAME TAG-FORMAT + TAG-FORMAT @@ -146,6 +147,19 @@ + + =TAG-NAME + + + + Add TAG-FORMAT as an additional parent of the + commit of the upstream tarball. Useful when upstream uses git and you + want to link to its revision history. + TAG-FORMAT can be a pattern similar to + what supports. + + + DIRECTORY diff --git a/gbp/scripts/import_srpm.py b/gbp/scripts/import_srpm.py index ffef4985..eb78d074 100755 --- a/gbp/scripts/import_srpm.py +++ b/gbp/scripts/import_srpm.py @@ -155,6 +155,9 @@ def build_parser(name): dest="packaging_branch") branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch") + branch_group.add_option("--upstream-vcs-tag", dest="vcs_tag", + help="Upstream VCS tag on top of which to import " + "the orig sources") branch_group.add_boolean_config_file_option( option_name="create-missing-branches", dest="create_missing_branches") @@ -387,9 +390,15 @@ def main(argv): upstream_vendor = "Native" if options.native else "Upstream" upstream_version = full_version if options.native else spec.upstreamversion msg = "%s version %s" % (upstream_vendor, upstream_version) + if options.vcs_tag: + vcs_tag = repo.version_to_tag(options.vcs_tag, upstream_str_fields) + parents = [repo.rev_parse("%s^{}" % vcs_tag)] + else: + parents = None upstream_commit = repo.commit_dir(sources.unpacked, "Import %s" % msg, branch, + other_parents=parents, author=author, committer=committer, create_missing_branch=options.create_missing_branches) diff --git a/tests/component/rpm/test_import_srpm.py b/tests/component/rpm/test_import_srpm.py index 15db0cf0..17344b21 100644 --- a/tests/component/rpm/test_import_srpm.py +++ b/tests/component/rpm/test_import_srpm.py @@ -285,6 +285,22 @@ class TestImportPacked(ComponentTestBase): eq_(info['author'].name, info['committer'].name) eq_(info['author'].email, info['committer'].email) + # Create a new commit by committing an empty tree + commit = repo.commit_tree('4b825dc642cb6eb9a060e54bf8d69288fbee4904', + msg="Empty commit", parents=[]) + repo.create_tag('foo/1.0', msg="New tag", commit=commit) + # Just blindly import another package on top of this to test more options + os.chdir('gbp-test2') + srpm = os.path.join(DATA_DIR, 'gbp-test-1.0-1.src.rpm') + eq_(mock_import(['--upstream-vcs-tag=foo/%(version)s', + '--upstream-branch=orig', + '--packaging-branch=pack', + srpm]), 0) + parents = repo.get_commits(until='orig', num=1, options='--format=%P')[0].split() + eq_(len(parents), 2) + ok_(commit in parents) + ok_(repo.rev_parse('orig/2.0^{}') in parents) + class TestImportUnPacked(ComponentTestBase): """Test importing of unpacked source rpms""" -- cgit v1.2.3