2020-06-22 00:05:26 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# This script is for mocking fzf for testing,
|
|
|
|
# it will stop fzf for goin into a interactive mode
|
|
|
|
#
|
|
|
|
# usage:
|
|
|
|
# export PATH="${BATS_TEST_DIRNAME}:$PATH"
|
2020-06-23 08:10:47 +00:00
|
|
|
# example:
|
|
|
|
# echo "commitdiff" when attempting to mock a local file search
|
|
|
|
# error code 128
|
2020-06-23 09:33:46 +00:00
|
|
|
# fatal: pathspec '$HOME/modifiedfile' did not match any files
|
2020-06-23 08:10:47 +00:00
|
|
|
# echo "-- modifiedfile" when attempting to mock a local file search
|
|
|
|
# error code 1 or code 128
|
2020-06-23 09:33:46 +00:00
|
|
|
# error: pathspec '$HOME/modifiedfile' did not match any file(s) known to git
|
2020-06-23 08:10:47 +00:00
|
|
|
# echo "--branch" when attempting to mock branch commit
|
|
|
|
# error code 129
|
|
|
|
# error: unknown option `commitshow'
|
|
|
|
# use something like tr "`" "'" to avoid any potential error bats would raise
|
2020-06-22 00:05:26 +00:00
|
|
|
|
2020-06-23 07:27:12 +00:00
|
|
|
if [[ "$*" =~ "--header=select a commit to checkout" ]] && [[ "$*" =~ "show --color" ]]; then
|
2020-06-23 07:05:50 +00:00
|
|
|
echo "--commitshow"
|
2020-06-23 08:10:47 +00:00
|
|
|
elif [[ "$*" =~ '--no-multi --header=select the target commit for HEAD' ]] && [[ "$*" =~ "show --color" ]]; then
|
|
|
|
echo "--commitshow"
|
2020-06-23 07:27:12 +00:00
|
|
|
elif [[ "$*" =~ "--no-multi --header=select a branch to checkout" ]]; then
|
2020-06-23 07:05:50 +00:00
|
|
|
echo "--branch"
|
|
|
|
elif [[ "$*" =~ '--header=select a file to checkout' ]] && [[ "$*" =~ "cat" ]]; then
|
|
|
|
echo "selectgitfile"
|
2020-06-23 08:10:47 +00:00
|
|
|
elif [[ "$*" =~ '--multi --preview ' ]] && [[ "$*" =~ "tree -L 1 -C --dirsfirst {}" ]]; then
|
|
|
|
echo "searchdir"
|
2020-06-23 07:05:50 +00:00
|
|
|
elif [[ "$*" =~ '--header=select the target commit' ]] && [[ "$*" =~ "diff --color" ]]; then
|
|
|
|
echo "commitdiff"
|
2020-06-24 22:37:18 +00:00
|
|
|
elif [[ "$*" =~ "--no-multi --header=select a commit to rename" ]] && [[ "$*" =~ "show --color=always" ]]; then
|
|
|
|
echo "commitdiff"
|
2020-06-23 07:27:12 +00:00
|
|
|
elif [[ "$*" =~ '--multi --preview ' ]] && [[ "$*" =~ "cat {}" ]]; then
|
|
|
|
echo "searchfile"
|
2020-06-23 08:10:47 +00:00
|
|
|
elif [[ "$*" =~ "--header=select a file to checkout version in HEAD" ]] && [[ "$*" =~ "diff HEAD --color=always" ]]; then
|
|
|
|
echo "-- modifiedfile"
|
2020-06-23 07:27:12 +00:00
|
|
|
elif [[ "$*" =~ '--header=select files to stage' ]] && [[ "$*" =~ "diff HEAD --color=always" ]]; then
|
|
|
|
echo "-- modifiedfile"
|
2020-06-23 08:10:47 +00:00
|
|
|
elif [[ "$*" =~ "--header=select files to unstage" ]] && [[ "$*" =~ "diff HEAD --color=always" ]]; then
|
|
|
|
echo "-- modifiedfile"
|
2020-06-24 22:37:18 +00:00
|
|
|
elif [[ "$*" =~ "--header=select tracked files to edit" ]]; then
|
|
|
|
exit
|
2020-06-23 07:05:50 +00:00
|
|
|
fi
|