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: Include a commit log summary in the changelog --- xtask/src/release.rs | 55 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'xtask/src') diff --git a/xtask/src/release.rs b/xtask/src/release.rs index 93079b369..63556476d 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,6 +26,34 @@ impl ReleaseCmd { let commit = cmd!("git rev-parse HEAD").read()?; let changelog_n = read_dir(changelog_dir.as_path())?.len(); + for &adoc in [ + "manual.adoc", + "generated_assists.adoc", + "generated_config.adoc", + "generated_diagnostic.adoc", + "generated_features.adoc", + ] + .iter() + { + let src = project_root().join("./docs/user/").join(adoc); + let dst = website_root.join(adoc); + cp(src, dst)?; + } + + let tags = cmd!("git tag --list").read()?; + 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 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 #{} @@ -40,39 +70,18 @@ https://github.com/sponsors/rust-analyzer[GitHub Sponsors]. == New Features -* pr:[] . +{} == Fixes == Internal Improvements ", - changelog_n, commit, today + changelog_n, commit, today, git_log_summary ); let path = changelog_dir.join(format!("{}-changelog-{}.adoc", today, changelog_n)); write_file(&path, &contents)?; - for &adoc in [ - "manual.adoc", - "generated_assists.adoc", - "generated_config.adoc", - "generated_diagnostic.adoc", - "generated_features.adoc", - ] - .iter() - { - let src = project_root().join("./docs/user/").join(adoc); - let dst = website_root.join(adoc); - cp(src, dst)?; - } - - let tags = cmd!("git tag --list").read()?; - 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)?; - Ok(()) } } -- cgit v1.2.3