add more import options, #594
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 7 Jan 2013 01:43:51 +0000 (09:43 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Tue, 8 Jan 2013 07:40:44 +0000 (15:40 +0800)
--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
tests/test_import.py
tools/gbs

index ba23589..5e02a41 100644 (file)
@@ -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:
index b998098..58099bb 100644 (file)
@@ -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'])
index 79c87ad..83af6e5 100755 (executable)
--- 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