Fix git test when run from git

Prior to this change, the checks/git.fish test would fail if run from a
git interactive rebase (such as via `git rebase -i --exec 'ninja test'`),
because git itself would inject stuff into the environment. Teach the git
test how to clean up its environment first before running.
This commit is contained in:
ridiculousfish 2021-02-05 14:53:32 -08:00
parent b5305ce3d3
commit f0d07f9b1c

View File

@ -3,6 +3,15 @@
# e.g. the fish_git_prompt variable handlers test `status is-interactive`.
#REQUIRES: command -v git
# Tests run from git (e.g. git rebase --exec 'ninja test'...) inherit a weird git environment.
# Ensure that no git environment variables are inherited.
for varname in (set -x | string match 'GIT_*' | string replace -r ' .*' '')
set -e $varname
end
# Also ensure that git-core is not in $PATH, as this adds weird git commands like `git-add--interactive`.
set PATH (string match --invert '*git-core*' -- $PATH)
# Do some tests with `git` - completions are interesting,
# but prompts would also be possible.