fix(fish): completions fail to load with fish >= 4.8.0 (#556)
Some checks are pending
ci / build (macos-latest) (push) Waiting to run
ci / build (ubuntu-latest) (push) Waiting to run
ci / commitlint (push) Waiting to run
ci / format (push) Waiting to run
ci / rumdl-check (push) Waiting to run
ci / actionlint (push) Waiting to run

Fish started shipping git completions in the binary with 4.2.0 and deprecated the old completion
files with 4.8.0.

Update forgit’s fish completion loader to support both models:

* prefer `status get-file completions/git.fish` (binary-embedded completions)
* fall back to `$__fish_data_dir/completions/git.fish` (completion files)

Also refactors loading into a helper function to allow early returns and reduce nesting.
This commit is contained in:
sandroid 2026-09-09 18:56:07 +02:00 committed by GitHub
parent a3bfe847cf
commit b2e5b46987
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,8 +20,29 @@ function __fish_forgit_worktrees
git worktree list --porcelain 2>/dev/null | string match -r '^worktree .+' | string replace 'worktree ' ''
end
# Load helper functions in git completion file
not functions -q __fish_git && source $__fish_data_dir/completions/git.fish
# Load git completion functions
function __fish_forgit_load_git_completions
if functions -q __fish_git
return 0
end
# Fish >= 4.2.0 ships git completions in its binary
if set --local git_completions (status get-file completions/git.fish)
printf '%s\n' $git_completions | source
return 0
end
# Older fish versions ship completions in a file
set --local git_completions_file "$__fish_data_dir/completions/git.fish"
if test -f "$git_completions_file"
source "$git_completions_file"
return 0
end
return 1
end
__fish_forgit_load_git_completions || exit
# No file completion by default
complete -c git-forgit -x