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

[lintian] 01/01: c/changelog-file: Check weekday is consistent with the dch date



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

nthykier pushed a commit to branch master
in repository lintian.

commit 644900984bad8390ede9968f44537dd37353aad3
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Sep 12 16:51:12 2013 +0200

    c/changelog-file: Check weekday is consistent with the dch date
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/changelog-file.desc                         |   12 +++++++++++
 checks/changelog-file.pm                           |   22 ++++++++++++++++++--
 debian/changelog                                   |    6 +++++-
 .../debian/debian/changelog.in                     |    6 ++++--
 t/tests/changelog-file-wrong-weekday/desc          |    5 +++++
 t/tests/changelog-file-wrong-weekday/tags          |    1 +
 .../debian/debian/changelog.in                     |    2 +-
 .../debian/debian/changelog.in                     |    2 +-
 testset/tags.foo++                                 |    1 +
 9 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/checks/changelog-file.desc b/checks/changelog-file.desc
index a6269be..5cfd484 100644
--- a/checks/changelog-file.desc
+++ b/checks/changelog-file.desc
@@ -356,3 +356,15 @@ Info: The Debian portion of the package version contains a reference to a
  version number and may cause annoying version sequencing issues if the
  package doesn't change before the next release cycle starts.
 Ref: devref 5.13.3
+
+Tag: debian-changelog-has-wrong-weekday
+Severity: normal
+Certainty: certain
+Info: The date in the changelog entry is not consistent with the actual
+ weekday.  Either the date is wrong or the weekday is wrong.
+ .
+ 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
diff --git a/checks/changelog-file.pm b/checks/changelog-file.pm
index e3f2f12..e4f97af 100644
--- a/checks/changelog-file.pm
+++ b/checks/changelog-file.pm
@@ -23,6 +23,7 @@ use strict;
 use warnings;
 use autodie;
 
+use Date::Format qw(time2str);
 use Encode qw(decode);
 use List::Util qw(first);
 use List::MoreUtils qw(any);
@@ -31,7 +32,7 @@ use Parse::DebianChangelog;
 use Lintian::Check qw(check_spelling);
 use Lintian::Relation::Version qw(versions_gt);
 use Lintian::Tags qw(tag);
-use Lintian::Util qw(file_is_encoded_in_non_utf8);
+use Lintian::Util qw(file_is_encoded_in_non_utf8 strip);
 
 sub run {
     my ($pkg, undef, $info, undef, $group) = @_;
@@ -262,6 +263,7 @@ sub run {
     my @entries = $changelog->data;
     if (@entries) {
         my %versions;
+        my $first_timestamp = $entries[0]->Timestamp;
         for my $entry (@entries) {
             if ($entry->Maintainer) {
                 if ($entry->Maintainer =~ /<([^>\@]+\@[^>.]*)>/) {
@@ -272,8 +274,24 @@ sub run {
             $versions{$entry->Version} = 1 if defined $entry->Version;
         }
 
+        if ($first_timestamp) {
+            my $dch_date = $entries[0]->Date;
+            my ($weekday_declared, $date) = split(m/,\s*/, $dch_date, 2);
+            my ($tz, $weekday_actual);
+
+            if ($date =~ m/[ ]+ ([^ ]+)\Z/xsm) {
+                $tz = $1;
+                $weekday_actual = time2str('%a', $first_timestamp, $tz);
+            }
+            if ($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-weekday',
+                  "$short_date is a $real_weekday";
+            }
+        }
+
         if (@entries > 1) {
-            my $first_timestamp = $entries[0]->Timestamp;
             my $second_timestamp = $entries[1]->Timestamp;
 
             if ($first_timestamp && $second_timestamp) {
diff --git a/debian/changelog b/debian/changelog
index 86365e9..837919c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,10 @@ lintian (2.5.18) UNRELEASED; urgency=low
 
   XXX: generate tag summary with private/generate-tag-summary
 
+  * checks/changelog.{desc,pm}:
+    + [NT] Check that the weekday of the latest changelog entry
+      is consistent with the date.  Thanks to Raphael Champeimont
+      for the report.  (Closes: #703407)
   * checks/cruft.{desc,pm}:
     + [BR] Fix false-postive for license-problem-gfdl-invariants.
       (Closes: #721252)
@@ -96,7 +100,7 @@ lintian (2.5.18) UNRELEASED; urgency=low
   * vendors/ubuntu/main/data/{common,fields}/*:
     + [NT] Retire now redundant files.
 
- -- Niels Thykier <niels@thykier.net>  Mon, 26 Aug 2013 08:19:50 +0200
+ -- Niels Thykier <niels@thykier.net>  Tue, 26 Aug 2013 08:19:50 +0200
 
 lintian (2.5.17) unstable; urgency=low
 
diff --git a/t/tests/standards-version-timewarp/debian/debian/changelog.in b/t/tests/changelog-file-wrong-weekday/debian/debian/changelog.in
similarity index 58%
copy from t/tests/standards-version-timewarp/debian/debian/changelog.in
copy to t/tests/changelog-file-wrong-weekday/debian/debian/changelog.in
index 6fc94c5..a409cb0 100644
--- a/t/tests/standards-version-timewarp/debian/debian/changelog.in
+++ b/t/tests/changelog-file-wrong-weekday/debian/debian/changelog.in
@@ -2,7 +2,9 @@
 
   * Lintian Test Suite.
   * Test: {$testname}
-
   * Suppress "should close ITP bug" messages.  (Closes: #123456)
 
- -- {$author}  Fri, 15 Mar 2001 07:00:00 +0000
+  * A bit of wishful thinking that the date below was a Friday.
+
+ -- {$author}  Fri, 12 Sep 2013 14:45:00 +0000
+
diff --git a/t/tests/changelog-file-wrong-weekday/desc b/t/tests/changelog-file-wrong-weekday/desc
new file mode 100644
index 0000000..74987ad
--- /dev/null
+++ b/t/tests/changelog-file-wrong-weekday/desc
@@ -0,0 +1,5 @@
+Testname: changelog-file-wrong-weekday
+Sequence: 6000
+Version: 1.0
+Description: Test for wrong weekday in changelog date
+Test-For: debian-changelog-has-wrong-weekday
diff --git a/t/tests/changelog-file-wrong-weekday/tags b/t/tests/changelog-file-wrong-weekday/tags
new file mode 100644
index 0000000..fd033e0
--- /dev/null
+++ b/t/tests/changelog-file-wrong-weekday/tags
@@ -0,0 +1 @@
+W: changelog-file-wrong-weekday: debian-changelog-has-wrong-weekday 2013-09-12 is a Thursday
diff --git a/t/tests/standards-version-timewarp-unrel/debian/debian/changelog.in b/t/tests/standards-version-timewarp-unrel/debian/debian/changelog.in
index 57fa089..c325fd0 100644
--- a/t/tests/standards-version-timewarp-unrel/debian/debian/changelog.in
+++ b/t/tests/standards-version-timewarp-unrel/debian/debian/changelog.in
@@ -5,4 +5,4 @@
 
   * Suppress "should close ITP bug" messages.  (Closes: #123456)
 
- -- {$author}  Fri, 15 Mar 2001 07:00:00 +0000
+ -- {$author}  Thu, 15 Mar 2001 07:00:00 +0000
diff --git a/t/tests/standards-version-timewarp/debian/debian/changelog.in b/t/tests/standards-version-timewarp/debian/debian/changelog.in
index 6fc94c5..0b9d414 100644
--- a/t/tests/standards-version-timewarp/debian/debian/changelog.in
+++ b/t/tests/standards-version-timewarp/debian/debian/changelog.in
@@ -5,4 +5,4 @@
 
   * Suppress "should close ITP bug" messages.  (Closes: #123456)
 
- -- {$author}  Fri, 15 Mar 2001 07:00:00 +0000
+ -- {$author}  Thu, 15 Mar 2001 07:00:00 +0000
diff --git a/testset/tags.foo++ b/testset/tags.foo++
index d7ceb84..2710500 100644
--- a/testset/tags.foo++
+++ b/testset/tags.foo++
@@ -22,5 +22,6 @@ W: foo++ source: debian-watch-file-unknown-version 0
 W: foo++ source: dm-upload-allowed-is-obsolete
 W: foo++ source: uploader-address-looks-weird Jeroen van Wolffelaar<jeroen@localhost.localdomain>
 W: foo++-helper: empty-binary-package
+W: foo++: debian-changelog-has-wrong-weekday 2003-04-14 is a Monday
 W: foo++: latest-debian-changelog-entry-without-new-date
 W: foo++: readme-debian-contains-invalid-email-address foo@unknown

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


Reply to: