check-news: Ensure release date is within three days
authorMichael Hanselmann <hansmi@google.com>
Wed, 20 Feb 2013 12:58:04 +0000 (13:58 +0100)
committerMichael Hanselmann <hansmi@google.com>
Wed, 20 Feb 2013 13:24:46 +0000 (14:24 +0100)
Commit b6ad806f contained a date a month in the future. With this patch
all release dates in NEWS may at most be three days into the future
(assuming the build machine's clock is correct).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

autotools/check-news

index 9a22995..146faf2 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 #
 
-# Copyright (C) 2011, 2012 Google Inc.
+# Copyright (C) 2011, 2012, 2013 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -40,6 +40,9 @@ RELEASED_RE = re.compile(r"^\*\(Released (?P<day>[A-Z][a-z]{2}),"
 UNRELEASED_RE = re.compile(r"^\*\(unreleased\)\*$")
 VERSION_RE = re.compile(r"^Version \d+(\.\d+)+( (beta|rc)\d+)?$")
 
+#: How many days release timestamps may be in the future
+TIMESTAMP_FUTURE_DAYS_MAX = 3
+
 errors = []
 
 
@@ -115,6 +118,13 @@ def main():
       # would return an inconsistent result if the weekday is incorrect.
       parsed_ts = time.mktime(time.strptime(m.group("date"), "%d %b %Y"))
       parsed = datetime.date.fromtimestamp(parsed_ts)
+      today = datetime.date.today()
+
+      if (parsed - datetime.timedelta(TIMESTAMP_FUTURE_DAYS_MAX)) > today:
+        Error("Line %s: %s is more than %s days in the future (today is %s)" %
+              (fileinput.filelineno(), parsed, TIMESTAMP_FUTURE_DAYS_MAX,
+               today))
+
       weekday = parsed.strftime("%a")
 
       # Check weekday