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>
Fri, 14 Nov 2014 12:45:07 +0000 (14:45 +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 294eb926a931bef59bd98f10717bb21636a40665..55093969fb897a1029e42d1231d406240e6f497d 100644 (file)
@@ -611,6 +611,7 @@ class GbpOptionParserRpm(GbpOptionParser):
             'rpmbuild-buildrootdir'     : 'BUILDROOT',
             'patch-export'              : 'False',
             'patch-export-compress'     : '0',
+            'patch-export-ignore-path'  : '',
             'patch-export-squash-until' : '',
             'merge'                     : 'False',
             'pristine-tarball-name'     : 'auto',
@@ -651,6 +652,9 @@ class GbpOptionParserRpm(GbpOptionParser):
                 "Compress (auto-generated) patches larger than given number of "
                 "bytes, 0 never compresses, default is "
                 "'%(patch-export-compress)s'",
+            'patch-export-ignore-path':
+                "Exclude changes to path(s) matching regex, default is "
+                "'%(patch-export-ignore-path)s'",
             'patch-export-squash-until':
                 "Squash commits (from upstream) until given tree-ish into one "
                 "big diff, format is '<commit_ish>[:<filename_base>]'. "
index 44e01efa0e0b3241e5ac36e76d0382f4a3b4ea1e..aeb7759f31bfaba8ecb94f058d5bd51dac6c21a9 100755 (executable)
@@ -391,6 +391,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 9c1493bf13e7ab3b13ab3dcdfb3dc2210a90d295..ee932540f0df9edbebd9205788ee911251c0f8d8 100755 (executable)
@@ -101,7 +101,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
@@ -112,7 +113,8 @@ def generate_patches(repo, start, squash, end, outdir, options):
         cmds = parse_gbp_commands(info, 'gbp-rpm', ('ignore'), None)[0]
         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:
@@ -121,7 +123,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)
 
@@ -419,6 +422,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)