[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/01: checks/changelog-file.{desc, pm}: Warn about changelog entries that have incorrectly formatted dates. (Closes: #793406)



This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository lintian.

commit be03f617419839f40583c7db068e36898ed18c81
Author: Chris Lamb <lamby@debian.org>
Date:   Thu Dec 28 11:46:19 2017 +0000

    checks/changelog-file.{desc,pm}: Warn about changelog entries that have incorrectly formatted dates. (Closes: #793406)
---
 checks/changelog-file.desc                         | 17 ++++++++++++++++
 checks/changelog-file.pm                           | 12 ++++++++++-
 data/changelog-file/invalid-dates                  | 23 ++++++++++++++++++++++
 debian/changelog                                   |  4 ++++
 .../debian/debian/changelog.in                     |  8 ++++++++
 .../debian/debian/control.in                       | 16 +++++++++++++++
 t/tests/changelog-file-invalid-date/desc           |  7 +++++++
 t/tests/changelog-file-invalid-date/tags           |  2 ++
 8 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/checks/changelog-file.desc b/checks/changelog-file.desc
index 5d2217c..c31578c 100644
--- a/checks/changelog-file.desc
+++ b/checks/changelog-file.desc
@@ -431,3 +431,20 @@ Info: The previous version of this package had a different version epoch
  This may indicate a mistake in setting the version.
  .
  Lintian looks in this version's changelog entry for the phrase "epoch".
+
+Tag: invalid-date-in-debian-changelog
+Severity: normal
+Certainty: certain
+Info: The date format in the latest changelog entry file appears to be invalid.
+ .
+ Dates should use the following format (compatible and with the same semantics
+ of RFC 2822 and RFC 5322):
+ .
+   day-of-week, dd month yyyy hh:mm:ss +zzzz
+ .
+ To avoid problems like this, consider using a tool like dch(1) or
+ date(1) to generate the date.  Example:
+ .
+   $ date -R -ud '2013-11-05 23:59:59'
+   Tue, 05 Nov 2013 23:59:59 +0000
+Ref: policy 4.4
diff --git a/checks/changelog-file.pm b/checks/changelog-file.pm
index 3abba2d..62838b0 100644
--- a/checks/changelog-file.pm
+++ b/checks/changelog-file.pm
@@ -38,6 +38,8 @@ use Lintian::Data ();
 
 my $BUGS_NUMBER
   = Lintian::Data->new('changelog-file/bugs-number', qr/\s*=\s*/o);
+my $INVALID_DATES
+  = Lintian::Data->new('changelog-file/invalid-dates', qr/\s*=\>\s*/o);
 
 my $SPELLING_ERROR_IN_NEWS
   = spelling_tag_emitter('spelling-error-in-news-debian');
@@ -278,7 +280,15 @@ sub run {
         }
 
         if ($first_timestamp) {
+            my $warned = 0;
             my $dch_date = $entries[0]->Date;
+            foreach my $re ($INVALID_DATES->all()) {
+                if ($dch_date =~ m/($re)/i) {
+                    my $repl = $INVALID_DATES->value($re);
+                    tag 'invalid-date-in-debian-changelog', "($1 -> $repl)";
+                    $warned = 1;
+                }
+            }
             my ($weekday_declared, $date) = split(m/,\s*/, $dch_date, 2);
             $date //= '';
             my ($tz, $weekday_actual);
@@ -287,7 +297,7 @@ sub run {
                 $tz = $1;
                 $weekday_actual = time2str('%a', $first_timestamp, $tz);
             }
-            if ($tz and $weekday_declared ne $weekday_actual) {
+            if (not $warned and $tz and $weekday_declared ne $weekday_actual) {
                 my $real_weekday = time2str('%A', $first_timestamp, $tz);
                 my $short_date = time2str('%Y-%m-%d', $first_timestamp, $tz);
                 tag 'debian-changelog-has-wrong-day-of-week',
diff --git a/data/changelog-file/invalid-dates b/data/changelog-file/invalid-dates
new file mode 100644
index 0000000..793ba4a
--- /dev/null
+++ b/data/changelog-file/invalid-dates
@@ -0,0 +1,23 @@
+# Format is /\bREGEX\b/i => correction
+
+# Days
+Monday          => Mon
+Tues(day)?      => Tue
+Wednesday       => Wed
+Thurs(day)?     => Thu
+Friday          => Fri
+Saturday        => Sat
+Sunday          => Sun
+
+# Months
+January         => Jan
+February        => Feb
+March           => Mar
+April           => Apr
+June            => June
+July            => July
+August          => Aug
+Sept(ember)?    => Sep
+October         => Oct
+November        => Nov
+December        => Dec
diff --git a/debian/changelog b/debian/changelog
index 71bc066..5a7c7e9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,10 @@ lintian (2.5.67) UNRELEASED; urgency=medium
 
   XXX: generate tag summary
 
+  * checks/changelog-file.{desc,pm}:
+    + [CL] Warn about changelog entries that have incorrectly formatted dates.
+      (Closes: #793406)
+
   * data/standards-version/release-dates:
     + [CL] Correct date(1) invocation example in comment.
     + [CL] Add 4.1.3 as a known standards version.
diff --git a/t/tests/changelog-file-invalid-date/debian/debian/changelog.in b/t/tests/changelog-file-invalid-date/debian/debian/changelog.in
new file mode 100644
index 0000000..f2942d6
--- /dev/null
+++ b/t/tests/changelog-file-invalid-date/debian/debian/changelog.in
@@ -0,0 +1,8 @@
+{$source} ({$version}) unstable; urgency=low
+
+  * Lintian Test Suite.
+  * Test: {$testname}
+  * Suppress "should close ITP bug" messages.  (Closes: #123456)
+  * Writes out "Sept" and "Thurs"; should be "Sep" and "Thu".
+
+ -- {$author}  Thurs, 14 Sept 2017 10:47:43 +0000
diff --git a/t/tests/changelog-file-invalid-date/debian/debian/control.in b/t/tests/changelog-file-invalid-date/debian/debian/control.in
new file mode 100644
index 0000000..7f3a036
--- /dev/null
+++ b/t/tests/changelog-file-invalid-date/debian/debian/control.in
@@ -0,0 +1,16 @@
+Source: {$source}
+Priority: optional
+Section: {$section}
+Maintainer: {$author}
+Standards-Version: 4.1.0
+Build-Depends: {$build_depends}
+Rules-Requires-Root: no
+
+Package: {$source}
+Architecture: {$architecture}
+Depends: $\{shlibs:Depends\}, $\{misc:Depends\}
+Description: {$description}
+ This is a test package designed to exercise some feature or tag of
+ Lintian.  It is part of the Lintian test suite and may do very odd
+ things.  It should not be installed like a regular package.  It may
+ be an empty package.
diff --git a/t/tests/changelog-file-invalid-date/desc b/t/tests/changelog-file-invalid-date/desc
new file mode 100644
index 0000000..ae347db
--- /dev/null
+++ b/t/tests/changelog-file-invalid-date/desc
@@ -0,0 +1,7 @@
+Testname: changelog-file-invalid-date
+Version: 1.0
+Description: Test for invalid dates
+Test-For:
+ invalid-date-in-debian-changelog
+Test-Against:
+ debian-changelog-has-wrong-day-of-week
diff --git a/t/tests/changelog-file-invalid-date/tags b/t/tests/changelog-file-invalid-date/tags
new file mode 100644
index 0000000..047b016
--- /dev/null
+++ b/t/tests/changelog-file-invalid-date/tags
@@ -0,0 +1,2 @@
+W: changelog-file-invalid-date: invalid-date-in-debian-changelog (Sept -> Sep)
+W: changelog-file-invalid-date: invalid-date-in-debian-changelog (Thurs -> Thu)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: