You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/configuration.md
+32-8Lines changed: 32 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,11 @@ For more details and examples, see [Workspace Mode - File Processing Behavior](w
89
89
90
90
Each hook can set an explicit `priority` (a non-negative integer) that controls when it runs and with which hooks it may execute in parallel.
91
91
92
+
Scope:
93
+
94
+
- `priority`is evaluated **within a single `.pre-commit-config.yaml`** and is compared across **all hooks in that file**, even if they appear under different `repos:` entries.
95
+
- `priority`does **not** coordinate across different `.pre-commit-config.yaml` files. In workspace mode (nested projects), each project’s config file is scheduled independently.
96
+
92
97
Hooks run in ascending priority order: **lower `priority` values run earlier**. Hooks that share the same `priority` value run concurrently, subject to the global concurrency limit (defaults to the number of CPU cores; set `PREK_NO_CONCURRENCY=1` to force concurrency to `1`).
93
98
94
99
When `priority` is omitted, prek automatically assigns the hook a value equal to its index in the configuration file, preserving the original sequential behavior.
@@ -105,24 +110,43 @@ repos:
105
110
entry: python3 -m ruff format
106
111
always_run: true
107
112
priority: 0 # runs first
108
-
- id: lint-py
109
-
name: Python Lint
110
-
language: system
111
-
entry: python3 -m ruff check
112
-
always_run: true
113
-
priority: 10 # runs in parallel with lint-sh
113
+
114
+
# No explicit priority: automatically assigned based on position.
115
+
# In this example it is the next hook in the file, so it gets priority=1.
114
116
- id: lint-sh
115
117
name: Shell Lint
116
118
language: system
117
119
entry: shellcheck
118
120
always_run: true
119
-
priority: 10 # shares group with lint-py
121
+
122
+
# These two hooks are defined under different repos, but share the same
Copy file name to clipboardExpand all lines: docs/proposals/concurrency.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,12 @@ When `priority` is omitted, the scheduler assigns the hook a priority equal to i
26
26
27
27
Execution is driven purely by priority numbers:
28
28
29
+
### Scope
30
+
31
+
`priority`is **global within a single configuration file**. That is, priorities are compared across **all hooks in the same `.pre-commit-config.yaml`**, even if the hooks live under different `repos:` entries.
32
+
33
+
`priority`does **not** apply across *different* `.pre-commit-config.yaml` files (or separate `prek` runs with different configs). Each config file is scheduled independently.
34
+
29
35
1. **Ordering**: Hooks run from the lowest priority value to the highest.
30
36
2. **Concurrency**: Hooks that share the same priority execute concurrently, subject to the global concurrency limit (default: number of CPUs).
31
37
3. **Defaults**: Without explicit priorities, each hook receives a unique priority derived from its position, so execution remains sequential and backwards-compatible.
@@ -46,6 +52,8 @@ The existing `require_serial` configuration key often causes confusion. In this
46
52
47
53
Implicit priorities are always derived from the hook's position in the configuration (0-based), regardless of any explicitly configured priorities on other hooks.
48
54
55
+
Positions are taken from the **fully flattened hook list for the current `.pre-commit-config.yaml`**, in the order hooks appear as `repos:` and `hooks:` are read. In other words, implicit priorities are assigned across the whole file, not per-repo.
56
+
49
57
Example:
50
58
51
59
* Hook at index `0` with no `priority` gets implicit priority `0`.
@@ -86,23 +94,31 @@ repos:
86
94
name: Format Rust
87
95
entry: cargo fmt
88
96
language: system
89
-
priority: 0 # Earliest priority, runs first
97
+
priority: 0 # Runs first
90
98
99
+
# These hooks are in different repos, but share the same priority,
100
+
# so they can run concurrently.
101
+
- repo: local
102
+
hooks:
91
103
- id: ruff
92
104
name: Lint Python
93
105
entry: ruff check
94
106
language: system
95
-
priority: 10 # Same number means concurrent execution
107
+
priority: 10
96
108
109
+
- repo: local
110
+
hooks:
97
111
- id: shellcheck
98
112
name: Lint Shell
99
113
entry: shellcheck
100
114
language: system
101
-
priority: 10 # Runs parallel with ruff
115
+
priority: 10
102
116
117
+
- repo: local
118
+
hooks:
103
119
- id: integration-tests
104
120
name: Integration Tests
105
121
entry: just test
106
122
language: system
107
-
priority: 20 # Starts after the lint group completes
123
+
priority: 20 # Starts after priority=10 group completes
0 commit comments