aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2022-02-11 11:35:01 +0100
committerGuido Günther <agx@sigxcpu.org>2022-02-11 14:21:14 +0100
commit8db5af7326c581014ca07dcd98beac30f2c90d4f (patch)
treeef6569379798bb2f3cedddd2d7a80e4e078cc438
parentcaf64cb15e794fc7e13974fab19ce932cf6f563c (diff)
pq: Check if repo is clean before importing patches
Closes: #1005321
-rw-r--r--docs/manpages/gbp-pq.xml12
-rwxr-xr-xgbp/scripts/pq.py11
2 files changed, 23 insertions, 0 deletions
diff --git a/docs/manpages/gbp-pq.xml b/docs/manpages/gbp-pq.xml
index b75a669b..27e30916 100644
--- a/docs/manpages/gbp-pq.xml
+++ b/docs/manpages/gbp-pq.xml
@@ -33,6 +33,7 @@
<arg><option>--meta-closes-bugnum=bug-number-format</option></arg>
<arg><option>--pq-from=</option><replaceable>[DEBIAN|TAG]</replaceable></arg>
<arg><option>--upstream-tag=</option><replaceable>tag-format</replaceable></arg>
+ <arg><option>--[no-]ignore-new</option></arg>
<group choice="plain">
<arg><option>drop</option></arg>
<arg><option>export</option></arg>
@@ -279,6 +280,17 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--[no-]ignore-new</option>
+ </term>
+ <listitem>
+ <para>
+ Don't abort if there are uncommitted changes in the source tree or
+ the current branch doesn't match the
+ <replaceable>DEBIAN-BRANCH</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py
index 7ec5e245..f4b699e5 100755
--- a/gbp/scripts/pq.py
+++ b/gbp/scripts/pq.py
@@ -396,6 +396,15 @@ def switch_pq(repo, branch, options):
switch_to_pq_branch(repo, branch)
+def check_clean(repo, options):
+ if not options.ignore_new:
+ (clean, out) = repo.is_clean()
+ if not clean:
+ gbp.log.err("You have uncommitted changes in your source tree:")
+ gbp.log.err(out)
+ raise GbpError("Use --ignore-new to ignore.")
+
+
def usage_msg():
return """%prog [options] action - maintain patches on a patch queue branch
Actions:
@@ -437,6 +446,7 @@ def build_parser(name):
parser.add_config_file_option(option_name="meta-closes-bugnum", dest="meta_closes_bugnum")
parser.add_config_file_option(option_name="pq-from", dest="pq_from", choices=['DEBIAN', 'TAG'])
parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
+ parser.add_boolean_config_file_option(option_name="ignore-new", dest="ignore_new")
return parser
@@ -485,6 +495,7 @@ def main(argv):
if action == "export":
export_patches(repo, current, options)
elif action == "import":
+ check_clean(repo, options)
import_pq(repo, current, options)
elif action == "drop":
drop_pq(repo, current)