diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2018-01-22 14:28:08 +0200 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2018-01-22 14:56:17 +0200 |
commit | 8515181255c532fe25cd1b8b0c59814ea0eb2003 (patch) | |
tree | f9ab9c4c8375ace172e21231d0aa6e84b3e5c1db | |
parent | 972db70347d5fa37f9af74babf8021a41cb7d219 (diff) |
import-srpm: support --upstream-vcs-tag cmdline option
Similar to what the option does in git-import-orig.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | docs/manpages/gbp-import-srpm.xml | 14 | ||||
-rwxr-xr-x | gbp/scripts/import_srpm.py | 9 | ||||
-rw-r--r-- | tests/component/rpm/test_import_srpm.py | 16 |
3 files changed, 39 insertions, 0 deletions
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 @@ <arg><option>--[no-]sign-tags</option></arg> <arg><option>--upstream-branch=</option><replaceable>BRANCH-NAME</replaceable></arg> <arg><option>--upstream-tag=</option><replaceable>TAG-FORMAT</replaceable></arg> + <arg><option>--upstream-vcs-tag=</option><replaceable>TAG-FORMAT</replaceable></arg> <arg><option>--native</option></arg> <arg><option>--repo-user=</option><option>[GIT|DEBIAN]</option></arg> <arg><option>--repo-email=</option><option>[GIT|DEBIAN]</option></arg> @@ -147,6 +148,19 @@ </listitem> </varlistentry> <varlistentry> + <term><option>--upstream-vcs-tag</option>=<replaceable>TAG-NAME</replaceable> + </term> + <listitem> + <para> + Add <replaceable>TAG-FORMAT</replaceable> 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. + <replaceable>TAG-FORMAT</replaceable> can be a pattern similar to + what <option>--upstream-tag</option> supports. + </para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--git-packaging-dir=</option><replaceable>DIRECTORY</replaceable> </term> <listitem> 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""" |