Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions tools/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Package>,
Expand Down Expand Up @@ -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<Item = &Package> {
self.packages.iter().filter(|package| {
Expand Down
2 changes: 1 addition & 1 deletion tools/xtask/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
40 changes: 16 additions & 24 deletions tools/xtask/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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}");
}
}
}