Extract changelog text into the annotation

This commit is contained in:
Gwilym Kuiper 2022-10-02 18:19:14 +01:00
parent 030d43d68c
commit 7a55f50adf
2 changed files with 12 additions and 11 deletions

View file

@ -72,7 +72,7 @@ release +args: (_run-tool "release" args)
_run-tool +tool: _run-tool +tool:
(cd tools && cargo build) (cd tools && cargo build)
tools/target/debug/tools {{tool}} "$CARGO_TARGET_DIR/debug/tools" {{tool}}
_build-rom folder name: _build-rom folder name:
#!/usr/bin/env bash #!/usr/bin/env bash

View file

@ -69,16 +69,16 @@ pub fn release(matches: &clap::ArgMatches) -> Result<(), Error> {
.success()); .success());
} }
// assert!(Command::new("just") assert!(Command::new("just")
// .arg("ci") .arg("ci")
// .current_dir(&root_directory) .current_dir(&root_directory)
// .status() .status()
// .map_err(|_| Error::JustCiFailed)? .map_err(|_| Error::JustCiFailed)?
// .success()); .success());
let changelog_text = update_changelog(&root_directory, version)?; let changelog_text = update_changelog(&root_directory, version)?;
println!("Content of changelog:\n\n{changelog_text}"); println!("Content of changelog:\n{changelog_text}");
if !dry_run { if !dry_run {
execute_git_command( execute_git_command(
@ -92,7 +92,7 @@ pub fn release(matches: &clap::ArgMatches) -> Result<(), Error> {
"-a", "-a",
&version.to_string(), &version.to_string(),
"-m", "-m",
&format!("v{version}"), &format!("#v{version}\n{changelog_text}"),
], ],
)?; )?;
} }
@ -184,9 +184,10 @@ fn update_changelog(root_directory: &Path, new_version: &Version) -> Result<Stri
.find(UNRELEASED_HEADER) .find(UNRELEASED_HEADER)
.ok_or(Error::FailedToParseChangelog)? .ok_or(Error::FailedToParseChangelog)?
+ UNRELEASED_HEADER.len(); + UNRELEASED_HEADER.len();
let unreleased_bit_end = changelog_content let unreleased_bit_end = changelog_content[unreleased_bit_start..]
.find("\n## [") // the start of the next entry .find("\n## [") // the start of the next entry
.ok_or(Error::FailedToParseChangelog)?; .ok_or(Error::FailedToParseChangelog)?
+ unreleased_bit_start;
let change_content = changelog_content[unreleased_bit_start..unreleased_bit_end].to_owned(); let change_content = changelog_content[unreleased_bit_start..unreleased_bit_end].to_owned();