Revert "Fix scripts/packages/convert_changelog to read the changelog correctly"
This reverts commit 9012bf1676bd6426229625e2567bfa399f89dabe.
Fixes #2260.
--
Change-Id: Ia08dd65d55274acdd15993cfde4eab225fb01df0
Reviewed-on: https://cr.bazel.build/8012
PiperOrigin-RevId: 142294105
MOS_MIGRATED_REVID=142294105
diff --git a/scripts/packages/BUILD b/scripts/packages/BUILD
index 42d3adf..f324e3a 100644
--- a/scripts/packages/BUILD
+++ b/scripts/packages/BUILD
@@ -186,11 +186,10 @@
name = "generate-changelog-file",
srcs = [
"convert_changelog.py",
- "//:bazel-srcs", # Force a rebuild on source change
+ "//:changelog-file",
],
outs = ["changelog"],
- cmd = "python $(location convert_changelog.py) bazel-out/volatile-status.txt $(location changelog)",
- stamp = 1,
+ cmd = "python $(location convert_changelog.py) $(location //:changelog-file) $(location changelog)",
)
genrule(
diff --git a/scripts/packages/convert_changelog.py b/scripts/packages/convert_changelog.py
index 4868b40..78edbda 100644
--- a/scripts/packages/convert_changelog.py
+++ b/scripts/packages/convert_changelog.py
@@ -20,37 +20,26 @@
def main(input_file, output_file):
changelog_out = open(output_file, "w")
- changelog = None
- version = None
+ time_stamp = None
with open(input_file, "r") as changelog_in:
for line in changelog_in:
line = line.strip()
- if line.startswith("RELEASE_NOTES"):
- changelog = line[14:].strip().replace("\f", "\n")
- elif line.startswith("RELEASE_NAME"):
- version = line[13:].strip()
+ if line.startswith("```") or line.startswith("Baseline"):
+ continue
- 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:]
+ 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)
- # 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)
-
- for line in lines:
- if line.startswith("+") or line.startswith("-"):
+ elif line.startswith("+") or line.startswith("-"):
parts = line.split(" ")
line = "*" + line[1:]
changelog_out.write(" %s\n" % line)