diff --git a/tools/xtask/src/main.rs b/tools/xtask/src/main.rs index b81a664b6..29e18dcbc 100644 --- a/tools/xtask/src/main.rs +++ b/tools/xtask/src/main.rs @@ -64,6 +64,7 @@ fn main() -> Result<()> { /// The checkout `cargo xtask` runs in, which may be one of several worktrees. struct Workspace { + /// The checkout's top directory, which commands run from and paths are relative to. root: PathBuf, /// The workspace's crates, as `cargo metadata` describes them. packages: Vec, @@ -107,10 +108,6 @@ impl Workspace { Ok(Self { root, packages }) } - fn root(&self) -> &Path { - &self.root - } - /// The crates published to crates.io: every one without `publish = false`. fn published(&self) -> impl Iterator { self.packages.iter().filter(|package| { diff --git a/tools/xtask/src/publish.rs b/tools/xtask/src/publish.rs index 814f78fa0..4fd081f25 100644 --- a/tools/xtask/src/publish.rs +++ b/tools/xtask/src/publish.rs @@ -100,7 +100,7 @@ impl Publish<'_> { let package = self.workspace.npm_package(None)?; let mut npm = self.workspace.command("npm"); npm.arg("publish") - .current_dir(self.workspace.root().join(NPM_PACKAGE)); + .current_dir(self.workspace.root.join(NPM_PACKAGE)); if self.dry_run { npm.arg("--dry-run"); } else { diff --git a/tools/xtask/src/release.rs b/tools/xtask/src/release.rs index 611230946..f84ad1458 100644 --- a/tools/xtask/src/release.rs +++ b/tools/xtask/src/release.rs @@ -37,7 +37,7 @@ impl<'a> Release<'a> { let tag = self.tag(); let notes = self .workspace - .root() + .root .join(format!("target/release-notes-{tag}.md")); // `target` may not exist yet when `CARGO_TARGET_DIR` puts builds elsewhere. if let Some(directory) = notes.parent() { @@ -291,32 +291,24 @@ mod tests { /// Titles go in their type's section without the type, led by their scope. #[test] fn titles_are_grouped_by_type() { - let line = |subject| { - let (section, line) = Section::of(subject); - (section.title(), line) - }; - assert_eq!( - line("feat(sdk): cookie keys accept hex (#502)"), + for (subject, title, line) in [ ( + "feat(sdk): cookie keys accept hex (#502)", "Features", - "**sdk:** cookie keys accept hex (#502)".to_owned() - ) - ); - assert_eq!(line("fix: a fix (#1)"), ("Fixes", "a fix (#1)".to_owned())); - assert_eq!( - line("refactor(auth)!: drop the v1 routes (#2)"), + "**sdk:** cookie keys accept hex (#502)", + ), + ("fix: a fix (#1)", "Fixes", "a fix (#1)"), ( + "refactor(auth)!: drop the v1 routes (#2)", "Breaking changes", - "**auth:** drop the v1 routes (#2)".to_owned() - ) - ); - assert_eq!( - line("add AGENTS.md"), - ("Other changes", "add AGENTS.md".to_owned()) - ); - assert_eq!( - line("Merge: things"), - ("Other changes", "Merge: things".to_owned()) - ); + "**auth:** drop the v1 routes (#2)", + ), + ("add AGENTS.md", "Other changes", "add AGENTS.md"), + ("Merge: things", "Other changes", "Merge: things"), + ] { + let (section, written) = Section::of(subject); + let grouped = (section.title(), written.as_str()); + assert_eq!(grouped, (title, line), "{subject}"); + } } }