-
Notifications
You must be signed in to change notification settings - Fork 0
feat(installer): use resq hooks install with fallback to dev install-hooks
#8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -49,9 +49,17 @@ elif [ -x "$HOME/.cargo/bin/resq" ]; then | |||||
| fi | ||||||
|
|
||||||
| # ββ Path 1: use resq when present (preferred β offline, no raw fetch) βββββββ | ||||||
| # Prefer the new `hooks install` path; fall back to `dev install-hooks` for | ||||||
| # binaries built before resq-software/crates#60. | ||||||
| if [ -n "$RESQ_BIN" ]; then | ||||||
| printf 'info Installing hooks via %s dev install-hooks\n' "$RESQ_BIN" >&2 | ||||||
| (cd "$TARGET_ROOT" && "$RESQ_BIN" dev install-hooks) | ||||||
| if "$RESQ_BIN" hooks install --help >/dev/null 2>&1; then | ||||||
| install_cmd="hooks install" | ||||||
| else | ||||||
| install_cmd="dev install-hooks" | ||||||
| fi | ||||||
| printf 'info Installing hooks via %s %s\n' "$RESQ_BIN" "$install_cmd" >&2 | ||||||
| # shellcheck disable=SC2086 | ||||||
| (cd "$TARGET_ROOT" && "$RESQ_BIN" $install_cmd) | ||||||
| else | ||||||
| # ββ Path 2: fall back to raw fetch from crates templates ββββββββββββββββ | ||||||
| HOOKS="pre-commit commit-msg prepare-commit-msg pre-push post-checkout post-merge" | ||||||
|
|
@@ -82,7 +90,14 @@ fi | |||||
| if [ -f "$HOOKS_DIR/local-pre-push" ] || [ -n "${RESQ_SKIP_LOCAL_SCAFFOLD:-}" ]; then | ||||||
| exit 0 | ||||||
| fi | ||||||
| if ! "$RESQ_BIN" dev scaffold-local-hook --help >/dev/null 2>&1; then | ||||||
| # Probe for the new `hooks scaffold-local` path first; fall back to the | ||||||
| # legacy `dev scaffold-local-hook` for older binaries. Skip entirely if | ||||||
| # neither is available (very old resq). | ||||||
| if "$RESQ_BIN" hooks scaffold-local --help >/dev/null 2>&1; then | ||||||
| scaffold_cmd="hooks scaffold-local" | ||||||
| elif "$RESQ_BIN" dev scaffold-local-hook --help >/dev/null 2>&1; then | ||||||
| scaffold_cmd="dev scaffold-local-hook" | ||||||
| else | ||||||
| exit 0 | ||||||
| fi | ||||||
|
|
||||||
|
|
@@ -96,7 +111,8 @@ fi | |||||
|
|
||||||
| case "$answer" in | ||||||
| [yY]|[yY][eE][sS]) | ||||||
| (cd "$TARGET_ROOT" && "$RESQ_BIN" dev scaffold-local-hook --kind auto) \ | ||||||
| || printf 'warn scaffold-local-hook failed; run it manually with --kind <name>.\n' >&2 | ||||||
| # shellcheck disable=SC2086 | ||||||
| (cd "$TARGET_ROOT" && "$RESQ_BIN" $scaffold_cmd --kind auto) \ | ||||||
| || printf 'warn scaffold-local failed; run it manually with --kind <name>.\n' >&2 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The warning message hardcodes the new command name
Suggested change
|
||||||
| ;; | ||||||
| esac | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the bash script, this warning message hardcodes
scaffold-local. If the fallback commanddev scaffold-local-hookwas used and failed, the user is directed to run a command their binary likely doesn't support. Using the actual command attempted from$scaffoldArgswould be more accurate.