From 8814d1368d6712fd85074d77e33be610f01566c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Fri, 12 Feb 2021 19:52:51 +0200 Subject: [PATCH] Include a commit log summary in the changelog --- docs/dev/README.md | 3 +- xtask/src/release.rs | 69 +++++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/docs/dev/README.md b/docs/dev/README.md index 9b9b18102a3..d6fae52959a 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md @@ -218,8 +218,7 @@ Release steps: * makes a GitHub release * pushes VS Code extension to the marketplace * create new changelog in `rust-analyzer.github.io` - * create `rust-analyzer.github.io/git.log` file with the log of merge commits since last release -2. While the release is in progress, fill-in the changelog using `git.log` +2. While the release is in progress, fill in the changelog 3. Commit & push the changelog 4. Tweet 5. Inside `rust-analyzer`, run `cargo xtask promote` -- this will create a PR to rust-lang/rust updating rust-analyzer's submodule. diff --git a/xtask/src/release.rs b/xtask/src/release.rs index 93079b3690c..63556476ddf 100644 --- a/xtask/src/release.rs +++ b/xtask/src/release.rs @@ -1,3 +1,5 @@ +use std::fmt::Write; + use xshell::{cmd, cp, pushd, read_dir, write_file}; use crate::{codegen, date_iso, is_release_tag, project_root, Mode, Result}; @@ -24,34 +26,6 @@ impl ReleaseCmd { let commit = cmd!("git rev-parse HEAD").read()?; let changelog_n = read_dir(changelog_dir.as_path())?.len(); - let contents = format!( - "\ -= Changelog #{} -:sectanchors: -:page-layout: post - -Commit: commit:{}[] + -Release: release:{}[] - -== Sponsors - -**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or -https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. - -== New Features - -* pr:[] . - -== Fixes - -== Internal Improvements -", - changelog_n, commit, today - ); - - let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); - write_file(&path, &contents)?; - for &adoc in [ "manual.adoc", "generated_assists.adoc", @@ -70,8 +44,43 @@ https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. let prev_tag = tags.lines().filter(|line| is_release_tag(line)).last().unwrap(); let git_log = cmd!("git log {prev_tag}..HEAD --merges --reverse").read()?; - let git_log_dst = website_root.join("git.log"); - write_file(git_log_dst, &git_log)?; + let mut git_log_summary = String::new(); + for line in git_log.lines() { + let line = line.trim_start(); + if let Some(p) = line.find(':') { + if let Ok(pr) = line[..p].parse::() { + writeln!(git_log_summary, "* pr:{}[]{}", pr, &line[p + 1..]).unwrap(); + } + } + } + + let contents = format!( + "\ += Changelog #{} +:sectanchors: +:page-layout: post + +Commit: commit:{}[] + +Release: release:{}[] + +== Sponsors + +**Become a sponsor:** On https://opencollective.com/rust-analyzer/[OpenCollective] or +https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. + +== New Features + +{} + +== Fixes + +== Internal Improvements +", + changelog_n, commit, today, git_log_summary + ); + + let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); + write_file(&path, &contents)?; Ok(()) }