rpm: implement file path filters in patch export
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Sep 2012 14:21:09 +0000 (17:21 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 7 Jan 2014 14:21:29 +0000 (16:21 +0200)
Implements a filter option allows one to filter out changes to certain
files/paths in the patch-generation. A commit is totally ignored if all
files would be filtered out. The path filter is given as a Python
regexp.

This option is useful for example in filtering out the changes to
packaging files when maintaining packaging and sources in the same
branch.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/config.py
gbp/scripts/buildpackage_rpm.py
gbp/scripts/pq_rpm.py

index c313dc319beaa4d14afa31a486afdf1dfd736f4f..28a7c44e31d8a18132803688efb65e379bfb5213 100644 (file)
@@ -550,6 +550,7 @@ class GbpOptionParserRpm(GbpOptionParser):
                        'rpmbuild-srpmdir'       : 'SRPMS',
                        'rpmbuild-buildrootdir'  : 'BUILDROOT',
                        'patch-export'           : 'False',
+                       'patch-export-ignore-path'   : '',
                        'patch-export-compress'  : '0',
                        'patch-export-squash-until'  : '',
                        'pristine-tarball-name'  : 'auto',
@@ -573,6 +574,9 @@ class GbpOptionParserRpm(GbpOptionParser):
                         "build with untracked files in the source tree, default is '%(ignore-untracked)s'",
                    'patch-export':
                         "Create patches between upstream and export-treeish, default is '%(patch-export)s'",
+                   'patch-export-ignore-path':
+                        ("Exclude changes to path(s) matching regex, default "
+                        "is '%(patch-export-ignore-path)s'"),
                    'patch-export-compress':
                         "Compress (auto-generated) patches larger than given number of bytes, 0 never compresses, default is '%(patch-export-compress)s'",
                    'patch-export-squash-until':
index e88424e4690a8eaf8e1f6bff4f9502247bd31ba4..e7e1759f3b4f5d816050a3b076fb1c9f5408e277 100755 (executable)
@@ -383,6 +383,8 @@ def parse_args(argv, prefix):
     export_group.add_option("--git-export-only", action="store_true", dest="export_only", default=False,
                       help="only export packaging files, don't build")
     export_group.add_boolean_config_file_option("patch-export", dest="patch_export")
+    export_group.add_config_file_option("patch-export-ignore-path",
+                                        dest="patch_export_ignore_path")
     export_group.add_config_file_option("patch-export-compress", dest="patch_export_compress")
     export_group.add_config_file_option("patch-export-squash-until", dest="patch_export_squash_until")
     export_group.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers")
index d2faca96771911f8eb009bec3b676aee089ab6f2..621052ec1cc398d6b54f8abe374c9bf9efc3fba5 100755 (executable)
@@ -100,7 +100,8 @@ def generate_patches(repo, start, squash, end, outdir, options):
             gbp.log.info("Squashing commits %s..%s into one monolithic diff" %
                          (start_sha1, squash_sha1))
             patch_fn = format_diff(outdir, squash[1], repo,
-                                   start_sha1, squash_sha1)
+                                   start_sha1, squash_sha1,
+                                   options.patch_export_ignore_path)
             if patch_fn:
                 patches.append(patch_fn)
                 start = squash_sha1
@@ -111,7 +112,8 @@ def generate_patches(repo, start, squash, end, outdir, options):
         cmds = parse_gbp_commands(info, 'gbp-rpm', ('ignore'), None)
         if not 'ignore' in cmds:
             patch_fn = format_patch(outdir, repo, info, patches,
-                                    options.patch_numbers)
+                                    options.patch_numbers,
+                                    options.patch_export_ignore_path)
             if patch_fn:
                 commands[os.path.basename(patch_fn)] = cmds
         else:
@@ -120,7 +122,8 @@ def generate_patches(repo, start, squash, end, outdir, options):
     # Generate diff to the tree-ish object
     if end_commit != end:
         gbp.log.info("Generating diff file %s..%s" % (end_commit, end))
-        patch_fn = format_diff(outdir, None, repo, end_commit, end)
+        patch_fn = format_diff(outdir, None, repo, end_commit, end,
+                               options.patch_export_ignore_path)
         if patch_fn:
             patches.append(patch_fn)
 
@@ -413,6 +416,7 @@ def main(argv):
     parser.add_config_file_option("patch-export-compress",
                                   dest="patch_export_compress")
     parser.add_config_file_option("patch-export-squash-until", dest="patch_export_squash_until")
+    parser.add_config_file_option("patch-export-ignore-path", dest="patch_export_ignore_path")
 
     (options, args) = parser.parse_args(argv)
     gbp.log.setup(options.color, options.verbose)