[2019-05-11 15:56] Jelmer Vernooij <jel...@jelmer.uk>
> Thanks! Makes sense.
>
> Any chance you could add a test case for this under
> tests/patch-file-present-but-not-mentioned-in-series/?

Sure.

From 6e795731f4ae266954acf9de70ace6f0ea4e944c Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <kact...@debian.org>
Date: Sat, 11 May 2019 14:46:44 +0000
Subject: [PATCH] New fixer: patch-file-present-but-not-mentioned-in-series.sh

Make sure that debian/patches contain only patches, mentioned in series
file.
---
 fixers/index.desc                                      |  3 +++
 .../patch-file-present-but-not-mentioned-in-series.sh  | 10 ++++++++++
 .../have-patches/in/debian/patches/one                 |  0
 .../have-patches/in/debian/patches/series              |  2 ++
 .../have-patches/in/debian/patches/three               |  0
 .../have-patches/in/debian/patches/two                 |  0
 .../have-patches/message                               |  2 ++
 .../have-patches/out/debian/patches/one                |  0
 .../have-patches/out/debian/patches/series             |  2 ++
 .../have-patches/out/debian/patches/two                |  0
 .../no-patches/in/debian/control                       |  0
 .../no-patches/out                                     |  1 +
 12 files changed, 20 insertions(+)
 create mode 100755 fixers/patch-file-present-but-not-mentioned-in-series.sh
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/one
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/series
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/three
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/two
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/message
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/one
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/series
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/two
 create mode 100644 
tests/patch-file-present-but-not-mentioned-in-series/no-patches/in/debian/control
 create mode 120000 
tests/patch-file-present-but-not-mentioned-in-series/no-patches/out

diff --git a/fixers/index.desc b/fixers/index.desc
index 735179f..058889c 100644
--- a/fixers/index.desc
+++ b/fixers/index.desc
@@ -120,6 +120,9 @@ Lintian-Tags:
   package-uses-deprecated-debhelper-compat-version,
   package-uses-old-debhelper-compat-version
 
+Fix-Script: patch-file-present-but-not-mentioned-in-series.sh
+Lintian-Tags: patch-file-present-but-not-mentioned-in-series
+
 Fix-Script: possible-missing-colon-in-closes.sh
 Lintian-Tags: possible-missing-colon-in-closes
 
diff --git a/fixers/patch-file-present-but-not-mentioned-in-series.sh 
b/fixers/patch-file-present-but-not-mentioned-in-series.sh
new file mode 100755
index 0000000..66ff555
--- /dev/null
+++ b/fixers/patch-file-present-but-not-mentioned-in-series.sh
@@ -0,0 +1,10 @@
+#!/bin/sh -eu
+test -r debian/patches/series || exit 0
+cd debian/patches
+
+for f in * ; do
+       test "${f}" != series || continue
+       grep -q -- "${f}" series || rm "${f}"
+done
+echo "Remove patches missing from debian/patches/series."
+echo "Fixed-Lintian-Tags: patch-file-present-but-not-mentioned-in-series"
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/one
 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/one
new file mode 100644
index 0000000..e69de29
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/series
 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/series
new file mode 100644
index 0000000..814f4a4
--- /dev/null
+++ 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/series
@@ -0,0 +1,2 @@
+one
+two
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/three
 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/three
new file mode 100644
index 0000000..e69de29
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/two
 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/in/debian/patches/two
new file mode 100644
index 0000000..e69de29
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/message 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/message
new file mode 100644
index 0000000..2281c60
--- /dev/null
+++ b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/message
@@ -0,0 +1,2 @@
+Remove patches missing from debian/patches/series.
+Fixed-Lintian-Tags: patch-file-present-but-not-mentioned-in-series
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/one
 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/one
new file mode 100644
index 0000000..e69de29
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/series
 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/series
new file mode 100644
index 0000000..814f4a4
--- /dev/null
+++ 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/series
@@ -0,0 +1,2 @@
+one
+two
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/two
 
b/tests/patch-file-present-but-not-mentioned-in-series/have-patches/out/debian/patches/two
new file mode 100644
index 0000000..e69de29
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/no-patches/in/debian/control
 
b/tests/patch-file-present-but-not-mentioned-in-series/no-patches/in/debian/control
new file mode 100644
index 0000000..e69de29
diff --git 
a/tests/patch-file-present-but-not-mentioned-in-series/no-patches/out 
b/tests/patch-file-present-but-not-mentioned-in-series/no-patches/out
new file mode 120000
index 0000000..f087d89
--- /dev/null
+++ b/tests/patch-file-present-but-not-mentioned-in-series/no-patches/out
@@ -0,0 +1 @@
+in
\ No newline at end of file
-- 
        Note, that I send and fetch email in batch, once every 24 hours.
                 If matter is urgent, try https://t.me/kaction
                                                                             --

Reply via email to