Repository navigation
fix(hooks): fall back to sha256sum when shasum is not installed #204
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
base: main
Are you sure you want to change the base?
Changes from all commits
8c8c62d
69e4fb8
0381eee
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 |
|---|---|---|
|
|
@@ -112,13 +112,15 @@ SCRIPT | |
|
|
||
| run_generated_fish_gtrconfig_post_cd_hooks() { | ||
| local trust_state="$1" | ||
| local root repo wt xdg init_file | ||
| local without_shasum="${2:-0}" | ||
| local root repo wt xdg init_file fish_path | ||
|
|
||
| root=$(mktemp -d) | ||
| repo="$root/repo" | ||
| wt="$root/wt" | ||
| xdg="$root/xdg" | ||
| init_file="$root/gtr.fish" | ||
| fish_path="$PATH" | ||
|
|
||
| git init --quiet "$repo" | ||
| git -C "$repo" config user.name "Test User" | ||
|
|
@@ -145,7 +147,11 @@ CFG | |
| ) | ||
| fi | ||
|
|
||
| XDG_CONFIG_HOME="$xdg" fish -c ' | ||
| if [ "$without_shasum" -eq 1 ]; then | ||
| fish_path=$(path_without_command "$root/bin" shasum) | ||
| fi | ||
|
|
||
| PATH="$fish_path" XDG_CONFIG_HOME="$xdg" fish -c ' | ||
| source "$argv[1]" | ||
| set -l wt "$argv[2]" | ||
| set -l root "$argv[3]" | ||
|
|
@@ -390,6 +396,33 @@ run_generated_replacement_repo_hooks() ( | |
| [[ "$output" == *"git gtr list --porcelain"* ]] | ||
| } | ||
|
|
||
| @test "generated bash wrapper recognizes trust markers when shasum is not installed" { | ||
| local root repo xdg no_shasum_path | ||
| root=$(mktemp -d) | ||
| repo="$root/repo" | ||
| xdg="$root/xdg" | ||
|
|
||
| git init --quiet "$repo" | ||
| cat > "$repo/.gtrconfig" <<'CFG' | ||
| [hooks] | ||
| postCd = echo hi | ||
| CFG | ||
|
|
||
| ( | ||
| export XDG_CONFIG_HOME="$xdg" | ||
| # shellcheck disable=SC1091 | ||
| . "$PROJECT_ROOT/lib/hooks.sh" | ||
| _hooks_mark_trusted "$repo/.gtrconfig" | ||
| ) | ||
|
|
||
| no_shasum_path=$(path_without_command "$root/bin" shasum) | ||
|
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. Skip this test when On a macOS installation without GNU coreutils, removing Add the
|
||
| run env PATH="$no_shasum_path" bash -c 'eval "$1" && gtr_hooks_are_trusted "$2" "$3" "$(gtr_hooks_read_definitions "$2")"' \ | ||
| _ "$(cmd_init bash)" "$repo/.gtrconfig" "$xdg/gtr/trusted" | ||
| rm -rf "$root" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| } | ||
|
|
||
| @test "zsh output validates trust marker contents" { | ||
| run cmd_init zsh | ||
| [ "$status" -eq 0 ] | ||
|
|
@@ -474,6 +507,18 @@ run_generated_replacement_repo_hooks() ( | |
| [ "$hook_pwd_line" = "$wt_line" ] | ||
| } | ||
|
|
||
| @test "fish generated postCd trusts gtrconfig hooks when shasum is unavailable" { | ||
| require_runtime_shell fish | ||
| command -v sha256sum >/dev/null 2>&1 || skip "sha256sum is not installed" | ||
|
|
||
| run run_generated_fish_gtrconfig_post_cd_hooks trusted 1 | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [[ "$output" == *"RC=0"* ]] | ||
| [[ "$output" == *"HOOK_ORDER=second"* ]] | ||
| [[ "$output" == *"STDERR="* ]] | ||
| } | ||
|
|
||
| # ── new/pr --cd wrapper support ───────────────────────────────────────────── | ||
|
|
||
| @test "bash output intercepts new/pr --cd and strips flag before delegating" { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.