From db1f45ae6f38dffdd110d62121199aac732873b1 Mon Sep 17 00:00:00 2001 From: Zhang Qiang Date: Mon, 7 Jan 2013 09:43:51 +0800 Subject: [PATCH] add more import options, #594 --filters for filtering out e.g. scm directories only for srpms and spec file options: --allow-same-version for re-importing the same version --native option for telling that "we're" the upstream --no-patch-import to prevent trying of importing patches only for upstream tar ball options: --upstream-vcs-tag: setting a upstream git tag as the parent. Change-Id: Ib90a0520e027f3e7df777e870e1172beb9e6e9d7 --- gitbuildsys/cmd_import.py | 10 ++++++++++ tests/test_import.py | 2 +- tools/gbs | 22 +++++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/gitbuildsys/cmd_import.py b/gitbuildsys/cmd_import.py index ba23589..5e02a41 100644 --- a/gitbuildsys/cmd_import.py +++ b/gitbuildsys/cmd_import.py @@ -53,8 +53,16 @@ def main(args): params.append("--verbose") if not args.no_pristine_tar and os.path.exists("/usr/bin/pristine-tar"): params.append("--pristine-tar") + if args.filter: + params += [('--filter=%s' % f) for f in args.filter] if path.endswith('.src.rpm') or path.endswith('.spec'): + if args.allow_same_version: + params.append("--allow-same-version") + if args.native: + params.append("--native") + if args.no_patch_import: + params.append("--no-patch-import") ret = gbp_import_srpm(params) if ret == 2: log.warning("Importing of patches into packaging branch failed! " @@ -64,6 +72,8 @@ def main(args): elif ret: raise GbsError("Failed to import %s" % path) else: + if args.upstream_vcs_tag: + params.append('--upstream-vcs-tag=%s' % args.upstream_vcs_tag) if args.merge: params.append('--merge') else: diff --git a/tests/test_import.py b/tests/test_import.py index b998098..58099bb 100644 --- a/tests/test_import.py +++ b/tests/test_import.py @@ -125,7 +125,7 @@ class TestImport(unittest.TestCase): @with_data("ail-0.2.29-2.3.src.rpm") def test_specify_upstream(self, srcrpm): """Test --upstream command line option.""" - eq_(GBS(argv=["gbs", "import", "--upstream=upstream", + eq_(GBS(argv=["gbs", "import", "--upstream-branch=upstream", srcrpm]), None) repo = GitRepository("./ail") eq_(repo.get_local_branches(), ['master', 'pristine-tar', 'upstream']) diff --git a/tools/gbs b/tools/gbs index 79c87ad..83af6e5 100755 --- a/tools/gbs +++ b/tools/gbs @@ -43,10 +43,8 @@ def import_parser(parser): parser.add_argument('--author-name', help='author name of git commit') parser.add_argument('--author-email', help='author email of git commit') - parser.add_argument('--upstream_branch', default='upstream', + parser.add_argument('--upstream-branch', default='upstream', help='specify upstream branch for new package version') - parser.add_argument('--merge', action='store_true', - help='merge new upstream branch to master') parser.add_argument('--packaging-dir', help='directory containing packaging files') parser.add_argument('--no-pristine-tar', action='store_true', @@ -54,6 +52,24 @@ def import_parser(parser): 'pristine-tar only support import *tar.{gz,bz2,xz} ' 'sources, this option can be specified to import ' 'other format sources') + parser.add_argument('--filter', action="append", + help='files to filter out during import(can be given ' + 'multiple times)') + group = parser.add_argument_group('only for importing srpms and spec file ' + 'options') + group.add_argument('--allow-same-version', action='store_true', + help='allow to import already imported version') + group.add_argument('--native', action='store_true', + help='this is a dist native package, no separate ' + 'upstream') + group.add_argument('--no-patch-import', action='store_true', + help='don\'t import patches automatically') + group = parser.add_argument_group('only for importing upstream tar ball ' + 'options') + group.add_argument('--merge', action='store_true', + help='merge new upstream branch to master') + group.add_argument('--upstream-vcs-tag', + help='upstream VCS tag add to the merge commit') parser.set_defaults(alias="im") return parser -- 2.7.4