From f0d07f9b1c13719890170de8c1b8dadef53eb6fd Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Fri, 5 Feb 2021 14:53:32 -0800 Subject: [PATCH] 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. --- tests/checks/git.fish | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/checks/git.fish b/tests/checks/git.fish index 6cebc2c4f..5ffcc9bad 100644 --- a/tests/checks/git.fish +++ b/tests/checks/git.fish @@ -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.