Revision d466fd8b autotools/check-news

b/autotools/check-news
32 32
import locale
33 33
import fileinput
34 34
import re
35
import os
35 36

  
36 37

  
37 38
DASHES_RE = re.compile(r"^\s*-+\s*$")
38 39
RELEASED_RE = re.compile(r"^\*\(Released (?P<day>[A-Z][a-z]{2}),"
39 40
                         r" (?P<date>.+)\)\*$")
40 41
UNRELEASED_RE = re.compile(r"^\*\(unreleased\)\*$")
41
VERSION_RE = re.compile(r"^Version \d+(\.\d+)+( (beta|rc)\d+)?$")
42
VERSION_RE = re.compile(r"^Version (\d+(\.\d+)+( (beta|rc)\d+)?)$")
42 43

  
43 44
#: How many days release timestamps may be in the future
44 45
TIMESTAMP_FUTURE_DAYS_MAX = 3
......
73 74
  if curlocale != (None, None):
74 75
    Error("Invalid locale %s" % curlocale)
75 76

  
77
  # Get the release version, but replace "~" with " " as the version
78
  # in the NEWS file uses spaces for beta and rc releases.
79
  release = os.environ.get('RELEASE', "").replace("~", " ")
80

  
76 81
  prevline = None
77 82
  expect_date = False
78 83
  count_empty = 0
84
  allow_unreleased = True
85
  found_versions = set()
79 86

  
80 87
  for line in fileinput.input():
81 88
    line = line.rstrip("\n")
82 89

  
83
    if VERSION_RE.match(line):
90
    version_match = VERSION_RE.match(line)
91
    if version_match:
84 92
      ReqNLines(2, count_empty, fileinput.filelineno(), line)
85

  
86
    if UNRELEASED_RE.match(line) or RELEASED_RE.match(line):
93
      version = version_match.group(1)
94
      if version in found_versions:
95
        Error("Line %s: Duplicate release %s found" %
96
              (fileinput.filelineno(), version))
97
      found_versions.add(version)
98
      if version == release:
99
        allow_unreleased = False
100

  
101
    unreleased_match = UNRELEASED_RE.match(line)
102
    if unreleased_match and not allow_unreleased:
103
      Error("Line %s: Unreleased version after current release %s" %
104
            (fileinput.filelineno(), release))
105

  
106
    if unreleased_match or RELEASED_RE.match(line):
87 107
      ReqNLines(1, count_empty, fileinput.filelineno(), line)
88 108

  
89 109
    if line:

Also available in: Unified diff