aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/packages
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-12-20 07:47:35 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-12-20 09:41:18 +0000
commit332b61f416855eb5938a226eed7787473487a268 (patch)
treee9cdb8a7f2dc34218764a3259c9648ece11cbb57 /scripts/packages
parent55c97bcf9b99916a3fe59295be64c4aee860d823 (diff)
Revert "Revert "Fix scripts/packages/convert_changelog to read the changelog correctly""
Roll-forward with fix: the original change did not produced any changelog if this was not a release branch, use a default, empty one in that case. The debian version number will then be LAST_VERSION~HEAD This reverts commit e4cf9aa8b63173326cfe72ba76be4303bc038def. -- Change-Id: I9e19b1132570ea20d90053734418f2703b1a641e Reviewed-on: https://cr.bazel.build/7976 PiperOrigin-RevId: 142525180 MOS_MIGRATED_REVID=142525180
Diffstat (limited to 'scripts/packages')
-rw-r--r--scripts/packages/BUILD4
-rw-r--r--scripts/packages/convert_changelog.py66
2 files changed, 50 insertions, 20 deletions
diff --git a/scripts/packages/BUILD b/scripts/packages/BUILD
index f324e3a3e9..2e5202152f 100644
--- a/scripts/packages/BUILD
+++ b/scripts/packages/BUILD
@@ -187,9 +187,11 @@ genrule(
srcs = [
"convert_changelog.py",
"//:changelog-file",
+ "//:bazel-srcs", # Force a rebuild on source change
],
outs = ["changelog"],
- cmd = "python $(location convert_changelog.py) $(location //:changelog-file) $(location changelog)",
+ cmd = "python $(location convert_changelog.py) bazel-out/volatile-status.txt $(location //:changelog-file) $(location changelog)",
+ stamp = 1,
)
genrule(
diff --git a/scripts/packages/convert_changelog.py b/scripts/packages/convert_changelog.py
index 78edbda914..07ed9d4fa5 100644
--- a/scripts/packages/convert_changelog.py
+++ b/scripts/packages/convert_changelog.py
@@ -18,28 +18,39 @@ from datetime import datetime
import sys
-def main(input_file, output_file):
+def main(input_file, changelog_file, output_file):
changelog_out = open(output_file, "w")
- time_stamp = None
- with open(input_file, "r") as changelog_in:
- for line in changelog_in:
+ changelog = None
+ version = None
+ with open(input_file, "r") as status_file:
+ for line in status_file:
line = line.strip()
- if line.startswith("```") or line.startswith("Baseline"):
- continue
+ if line.startswith("RELEASE_NOTES"):
+ changelog = line[14:].strip().replace("\f", "\n")
+ elif line.startswith("RELEASE_NAME"):
+ version = line[13:].strip()
- if line.startswith("## Release"):
- if time_stamp:
- changelog_out.write(
- "\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" %
- time_stamp)
- parts = line.split(" ")
- version = parts[2]
- time_stamp = datetime.strptime(
- parts[3], "(%Y-%m-%d)").strftime("%a, %d %b %Y %H:%M:%S +0100")
- changelog_out.write("bazel (%s) unstable; urgency=low\n" % version)
+ if changelog:
+ time_stamp = None
+ lines = changelog.split("\n")
+ header = lines[0]
+ lines = lines[4:] # Skip the header
+ if lines[0] == "Cherry picks:":
+ # Skip cherry picks list
+ i = 1
+ while lines[i].strip():
+ i += 1
+ lines = lines[i + 1:]
+
+ # Process header
+ parts = header.split(" ")
+ time_stamp = datetime.strptime(
+ parts[2], "(%Y-%m-%d)").strftime("%a, %d %b %Y %H:%M:%S +0100")
+ changelog_out.write("bazel (%s) unstable; urgency=low\n" % version)
- elif line.startswith("+") or line.startswith("-"):
+ for line in lines:
+ if line.startswith("+") or line.startswith("-"):
parts = line.split(" ")
line = "*" + line[1:]
changelog_out.write(" %s\n" % line)
@@ -54,7 +65,24 @@ def main(input_file, output_file):
changelog_out.write(
"\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" %
time_stamp)
-
+ else:
+ # Develeopment version, generate a changelog from the change log file
+ with open(changelog_file, "r") as changelog_in:
+ for line in changelog_in:
+ line = line.strip()
+ if line.startswith("## Release"):
+ parts = line.split(" ")
+ version = parts[2]
+ time_stamp = datetime.strptime(
+ parts[3], "(%Y-%m-%d)").strftime("%a, %d %b %Y %H:%M:%S +0100")
+ changelog_out.write("bazel (%s~HEAD) unstable; urgency=low\n" %
+ version)
+ changelog_out.write(" Development version\n")
+ changelog_out.write(
+ "\n -- The Bazel Authors <bazel-dev@googlegroups.com> %s\n\n" %
+ time_stamp)
+ # Stop after parsing latest release
+ return
if __name__ == "__main__":
- main(sys.argv[1], sys.argv[2])
+ main(sys.argv[1], sys.argv[2], sys.argv[3])