2021-01-20 02:16:17 +08:00
|
|
|
#RUN: %fish -i %s
|
|
|
|
# Note: ^ this is interactive so we test interactive behavior,
|
|
|
|
# e.g. the fish_git_prompt variable handlers test `status is-interactive`.
|
2021-01-16 20:27:30 +08:00
|
|
|
#REQUIRES: command -v git
|
|
|
|
|
2021-02-06 06:53:32 +08:00
|
|
|
# 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 ' .*' '')
|
2021-07-13 03:37:17 +08:00
|
|
|
set -e $varname
|
2021-02-06 06:53:32 +08:00
|
|
|
end
|
|
|
|
|
2021-07-13 03:37:17 +08:00
|
|
|
set -gx GIT_CONFIG_GLOBAL /dev/null # No ~/.gitconfig. We could also override $HOME.
|
|
|
|
set -gx GIT_CONFIG_NOSYSTEM true # No /etc/gitconfig
|
|
|
|
|
2021-02-06 06:53:32 +08:00
|
|
|
# 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)
|
|
|
|
|
2021-01-16 20:27:30 +08:00
|
|
|
# Do some tests with `git` - completions are interesting,
|
|
|
|
# but prompts would also be possible.
|
|
|
|
|
|
|
|
set -l tmp (mktemp -d)
|
|
|
|
|
|
|
|
cd $tmp
|
|
|
|
git init >/dev/null 2>&1
|
|
|
|
|
|
|
|
# Commands and descriptions
|
|
|
|
# Note: We *can't* list all here because in addition to aliases,
|
|
|
|
# git also uses all commands in $PATH called `git-something` as custom commands,
|
|
|
|
# so this depends on system state!
|
2021-03-04 23:25:41 +08:00
|
|
|
complete -C'git ' | grep '^add'\t
|
2021-01-16 20:27:30 +08:00
|
|
|
# (note: actual tab character in the check here)
|
|
|
|
#CHECK: add Add file contents to the index
|
|
|
|
|
|
|
|
touch foo
|
|
|
|
|
|
|
|
complete -C'git add '
|
|
|
|
#CHECK: foo Untracked file
|
|
|
|
|
2021-07-13 05:41:28 +08:00
|
|
|
git config alias.s status
|
|
|
|
complete 'git s --s'
|
|
|
|
# CHECK --short
|
|
|
|
|
2021-01-16 20:27:30 +08:00
|
|
|
# Note: We can't rely on the initial branch because that might be
|
|
|
|
# "master", or it could be changed to something else in future!
|
|
|
|
git checkout -b newbranch >/dev/null 2>&1
|
|
|
|
fish_git_prompt
|
|
|
|
echo # the git prompt doesn't print a newline
|
2021-04-14 00:57:06 +08:00
|
|
|
#CHECK: (newbranch)
|
2021-01-16 20:27:30 +08:00
|
|
|
|
2021-04-13 21:58:55 +08:00
|
|
|
set -g __fish_git_prompt_show_informative_status 1
|
|
|
|
fish_git_prompt
|
2021-01-16 20:27:30 +08:00
|
|
|
echo
|
2021-01-20 02:16:17 +08:00
|
|
|
#CHECK: (newbranch|…1)
|
2021-04-13 21:58:55 +08:00
|
|
|
set -e __fish_git_prompt_show_informative_status
|
2021-01-20 02:16:17 +08:00
|
|
|
|
|
|
|
# Confirm the mode changes back
|
|
|
|
fish_git_prompt
|
|
|
|
echo
|
2021-04-14 00:57:06 +08:00
|
|
|
#CHECK: (newbranch)
|
2021-04-13 21:58:55 +08:00
|
|
|
|
2021-04-14 00:57:06 +08:00
|
|
|
# (for some reason stagedstate is only shown with showdirtystate?)
|
|
|
|
set -g __fish_git_prompt_showdirtystate 1
|
2021-04-13 21:58:55 +08:00
|
|
|
git add foo
|
|
|
|
fish_git_prompt
|
|
|
|
echo
|
|
|
|
#CHECK: (newbranch +)
|
|
|
|
|
|
|
|
set -g __fish_git_prompt_showuntrackedfiles 1
|
|
|
|
touch bananan
|
|
|
|
fish_git_prompt
|
|
|
|
echo
|
|
|
|
#CHECK: (newbranch +%)
|
|
|
|
|
|
|
|
set -g __fish_git_prompt_status_order untrackedfiles stagedstate
|
|
|
|
fish_git_prompt
|
|
|
|
echo
|
|
|
|
#CHECK: (newbranch %+)
|
|
|
|
|
|
|
|
set -g __fish_git_prompt_status_order untrackedfiles
|
|
|
|
fish_git_prompt
|
|
|
|
echo
|
|
|
|
#CHECK: (newbranch %)
|