Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1753 +/- ##
==========================================
+ Coverage 91.68% 91.76% +0.07%
==========================================
Files 98 98
Lines 19597 19641 +44
==========================================
+ Hits 17968 18024 +56
+ Misses 1629 1617 -12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates prek install (and template-dir installation) so that global output-control flags (--quiet, --verbose, --no-progress) are embedded into the generated git hook scripts, ensuring subsequent hook executions run with the same verbosity/progress behavior.
Changes:
- Thread
quiet,verbose, andno_progressfrom CLI globals intocli::install/init_template_dir. - Extend the hook script template to include rendered global args before
hook-impl. - Add integration tests asserting the generated hook script includes the expected global flags.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
crates/prek/tests/install.rs |
Adds snapshot tests covering hook script generation for -q, -qq, -v, and --no-progress. |
crates/prek/src/main.rs |
Passes global flags through to install and init_template_dir code paths. |
crates/prek/src/cli/install.rs |
Renders global args into the generated hook script and updates install/init-template-dir plumbing. |
Comments suppressed due to low confidence (1)
crates/prek/src/cli/install.rs:360
- The hook script template changed (it now includes
[PREK_GLOBAL_ARGS]in theexecline), but the embedded# ID: .../CURRENT_HASHwas not updated. The comment below says to use a different hash for each script change; keeping the old hash makes it impossible to distinguish scripts generated before/after this change and diverges from the stated convention. Suggestion: generate a new hash/ID for this template update and add the previous hash toPRIOR_HASHESso older scripts are still recognized byis_our_script.
static HOOK_TMPL: &str = r#"#!/bin/sh
# File generated by prek: https://github.com/j178/prek
# ID: 182c10f181da4464a3eec51b83331688
HERE="$(cd "$(dirname "$0")" && pwd)"
PREK=[PREK_PATH]
# Check if the full path to prek is executable, otherwise fallback to PATH
if [ ! -x "$PREK" ]; then
PREK="prek"
fi
exec "$PREK" [PREK_GLOBAL_ARGS]hook-impl --hook-dir "$HERE" --script-version [CUR_SCRIPT_VERSION] [PREK_ARGS] -- "$@"
"#;
static PRIOR_HASHES: &[&str] = &[];
// Use a different hash for each change to the script.
// Use a different hash from `pre-commit` since our script is different.
static CURRENT_HASH: &str = "182c10f181da4464a3eec51b83331688";
📦 Cargo Bloat ComparisonBinary size change: +0.00% (24.8 MiB → 24.8 MiB) Expand for cargo-bloat outputHead Branch ResultsBase Branch Results |
…l` into generated hook scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1676