Skip to content

Commit 7cd6ba4

Browse files
j178Copilot
andauthored
Run same-depth projects concurrently (#2110)
Closes #673 --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent bbb3810 commit 7cd6ba4

56 files changed

Lines changed: 2037 additions & 1217 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ clap = { version = "4.6.0", features = [
3737
"wrap_help",
3838
] }
3939
clap_complete = { version = "4.6.0", features = ["unstable-dynamic"] }
40+
console = { version = "0.16", default-features = false, features = ["std"] }
4041
ctrlc = { version = "3.4.5" }
4142
dunce = { version = "1.0.5" }
4243
etcetera = { version = "0.11.0" }

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ while also providing some additional long-requested features.
3636
- A single binary with no dependencies, does not require Python or any other runtime.
3737
- [Faster](https://prek.j178.dev/benchmark/) than `pre-commit` and more efficient in disk space usage.
3838
- Fully compatible with the original pre-commit configurations and hooks.
39-
- Built-in support for monorepos (i.e. [workspace mode](https://prek.j178.dev/workspace/)).
39+
- Built-in support for monorepos (i.e. [workspace mode](https://prek.j178.dev/workspace/)), including concurrent execution for independent same-depth projects.
4040
- Integration with [`uv`](https://github.com/astral-sh/uv) for managing Python virtual environments and dependencies.
4141
- Improved toolchain installations for Python, Node.js, Bun, Go, Rust and Ruby, shared between hooks.
4242
- [Built-in](https://prek.j178.dev/builtin/) Rust-native implementation of some common hooks.
@@ -355,7 +355,7 @@ prek self update
355355

356356
- It is [multiple times faster](https://prek.j178.dev/benchmark/) than `pre-commit` while also using less disk space.
357357
- Hook environments and toolchains are shared across hooks instead of being duplicated per repository, which reduces both install time and cache size.
358-
- Repositories are fetched in parallel, hook environments are prepared in parallel when their dependencies do not overlap, and hooks can run concurrently by [`priority`](https://prek.j178.dev/reference/configuration/#priority).
358+
- Repositories are fetched in parallel, hook environments are prepared in parallel when their dependencies do not overlap, hooks can run concurrently by [`priority`](https://prek.j178.dev/reference/configuration/#priority), and independent workspace projects at the same directory depth can run concurrently.
359359
- It uses [`uv`](https://github.com/astral-sh/uv) for creating Python virtualenvs and installing dependencies, which is known for its speed and efficiency.
360360
- It implements some common hooks in Rust as [builtins](https://prek.j178.dev/builtin/), which are faster than their Python counterparts.
361361
- It supports `repo: builtin` for offline, zero-setup hooks, which is not available in `pre-commit`.
@@ -366,6 +366,7 @@ prek self update
366366
- `prek` automatically installs the toolchains it needs for supported languages, so you spend less time managing Python versions, Node runtimes, Ruby installs, and similar setup.
367367
- It supports native [`prek.toml`](https://prek.j178.dev/configuration/) in addition to pre-commit YAML, and [`prek util yaml-to-toml`](https://prek.j178.dev/reference/cli/#prek-util-yaml-to-toml) helps migrate existing configs.
368368
- Built-in support for [workspaces](https://prek.j178.dev/workspace/) means monorepos can keep separate configs per project and still run everything from one command.
369+
- Workspace mode schedules independent same-depth projects concurrently while preserving parent/child ordering, which helps large monorepos finish faster without mixing project file scopes.
369370
- [`prek install`](https://prek.j178.dev/reference/cli/#prek-install) and [`prek uninstall`](https://prek.j178.dev/reference/cli/#prek-uninstall) honor repo-local and worktree-local `core.hooksPath`.
370371
- [`prek run`](https://prek.j178.dev/reference/cli/#prek-run) supports selecting or skipping multiple projects or hooks in workspace mode, instead of only accepting a single optional hook id, and adds quality-of-life improvements such as `--dry-run`, `--directory`, `--last-commit`, and `--no-fail-fast`.
371372
- [`prek list`](https://prek.j178.dev/reference/cli/#prek-list), [`prek util identify`](https://prek.j178.dev/reference/cli/#prek-util-identify), and [`prek util list-builtins`](https://prek.j178.dev/reference/cli/#prek-util-list-builtins) make it easier to inspect configured hooks, debug file matching, and discover builtins.

crates/prek/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ bstr = { workspace = true }
3838
cargo_metadata = { workspace = true }
3939
clap = { workspace = true }
4040
clap_complete = { workspace = true }
41+
console = { workspace = true }
4142
ctrlc = { workspace = true }
4243
dunce = { workspace = true }
4344
etcetera = { workspace = true }

crates/prek/src/cli/cache_gc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ fn sweep_tool_bucket_versions(
507507
let item = if collect_names {
508508
Some(RemovalItem::new(
509509
format!("{bucket}/{version_name}"),
510-
path.to_string_lossy().to_string(),
510+
path.to_string_lossy().into_owned(),
511511
))
512512
} else {
513513
None
@@ -584,7 +584,7 @@ fn sweep_dir_by_name(
584584
.then(|| read_hook_marker(&path))
585585
.flatten();
586586

587-
let mut item = RemovalItem::new(name.to_string(), path.to_string_lossy().to_string());
587+
let mut item = RemovalItem::new(name.to_string(), path.to_string_lossy().into_owned());
588588

589589
if let Some(label) = label_for_entry(kind, repo_marker.as_ref(), hook_marker.as_ref()) {
590590
item.label = label;
@@ -673,7 +673,7 @@ fn sweep_stale_patch_files(root: &Path, dry_run: bool, collect_names: bool) -> R
673673

674674
let entry_bytes = metadata.len();
675675
let item = collect_names
676-
.then(|| RemovalItem::new(name.to_string(), path.to_string_lossy().to_string()));
676+
.then(|| RemovalItem::new(name.to_string(), path.to_string_lossy().into_owned()));
677677

678678
if dry_run {
679679
removal.count += 1;

crates/prek/src/cli/completion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ fn list_subdirs(
201201
continue;
202202
}
203203
if let Some(first) = rel.components().next() {
204-
let name = first.as_os_str().to_string_lossy().to_string();
204+
let name = first.as_os_str().to_string_lossy().into_owned();
205205
first_components.insert(name);
206206
}
207207
}
@@ -249,7 +249,7 @@ fn list_direct_project_colons(
249249
continue;
250250
}
251251
if let Some(first) = rel.components().next() {
252-
let name = first.as_os_str().to_string_lossy().to_string();
252+
let name = first.as_os_str().to_string_lossy().into_owned();
253253
// Only keep if this immediate child is a project root
254254
let child_abs = base.join(&name);
255255
if proj_paths.contains(&child_abs) {

0 commit comments

Comments
 (0)