gbp-pq-rpm: add 'export-rev' option
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 12 Jan 2012 13:44:43 +0000 (15:44 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Mar 2015 08:07:46 +0000 (10:07 +0200)
This option allows generating patches from any git tree-ish (instead of
the default that is HEAD of patch-queue branch).

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

index 56389348c303aa74dd32dea35484395f02bc6283..c403c77f958f40c074e1c99f0fc32a00c85c8223 100755 (executable)
@@ -209,7 +209,10 @@ def export_patches(repo, options):
         pq_branch = pq_branch_name(current, options)
     spec = parse_spec(options, repo)
     upstream_commit = find_upstream_commit(repo, spec, options.upstream_tag)
-    export_treeish = pq_branch
+
+    export_treeish = options.export_rev if options.export_rev else pq_branch
+    if not repo.has_treeish(export_treeish):
+        raise GbpError('Invalid treeish object %s' % export_treeish)
 
     update_patch_series(repo, spec, upstream_commit, export_treeish, options)
 
@@ -412,6 +415,10 @@ switch         Switch to patch-queue branch and vice versa.""")
     parser.add_config_file_option(option_name="spec-file", dest="spec_file")
     parser.add_config_file_option(option_name="packaging-dir",
             dest="packaging_dir")
+    parser.add_option("--export-rev", dest="export_rev",
+            metavar="TREEISH",
+            help="Export patches from treeish object TREEISH instead of head "
+                 "of patch-queue branch")
     parser.add_config_file_option(option_name="import-files",
             dest="import_files", type="string", action="callback",
             callback=optparse_split_cb)