Introduce support for alpha versions
authorMichele Tartara <mtartara@google.com>
Thu, 13 Jun 2013 11:00:12 +0000 (11:00 +0000)
committerMichele Tartara <mtartara@google.com>
Fri, 14 Jun 2013 12:04:33 +0000 (14:04 +0200)
An alpha version can be used to name a release while a previous one is still
being developed.

E.g. 2.9.0~alpha1 can be out while 2.8.0~rc1 is being worked on.

When a version is marked as alpha, it is allowed to have unreleased versions
before it in the NEWS file, in order to simplify merges of the NEWS file itself
between the two development branches.

Partially fixes Issue 448.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

autotools/check-news

index 0cd0739..1405b58 100755 (executable)
@@ -39,7 +39,7 @@ DASHES_RE = re.compile(r"^\s*-+\s*$")
 RELEASED_RE = re.compile(r"^\*\(Released (?P<day>[A-Z][a-z]{2}),"
                          r" (?P<date>.+)\)\*$")
 UNRELEASED_RE = re.compile(r"^\*\(unreleased\)\*$")
-VERSION_RE = re.compile(r"^Version (\d+(\.\d+)+( (beta|rc)\d+)?)$")
+VERSION_RE = re.compile(r"^Version (\d+(\.\d+)+( (alpha|beta|rc)\d+)?)$")
 
 #: How many days release timestamps may be in the future
 TIMESTAMP_FUTURE_DAYS_MAX = 3
@@ -68,6 +68,21 @@ def ReqNLines(req, count_empty, lineno, line):
           (lineno, line, req, count_empty))
 
 
+def IsAlphaVersion(version):
+  return "alpha" in version
+
+
+def UpdateAllowUnreleased(allow_unreleased, version_match, release):
+  if not allow_unreleased:
+    return False
+  if IsAlphaVersion(release):
+    return True
+  version = version_match.group(1)
+  if version == release:
+    return False
+  return True
+
+
 def main():
   # Ensure "C" locale is used
   curlocale = locale.getlocale()
@@ -95,8 +110,8 @@ def main():
         Error("Line %s: Duplicate release %s found" %
               (fileinput.filelineno(), version))
       found_versions.add(version)
-      if version == release:
-        allow_unreleased = False
+      allow_unreleased = UpdateAllowUnreleased(allow_unreleased, version_match,
+                                               release)
 
     unreleased_match = UNRELEASED_RE.match(line)
     if unreleased_match and not allow_unreleased: