.dotfiles/.config/fish/functions/gtest.fish

22 lines
595 B
Fish
Raw Permalink Normal View History

2024-10-21 20:46:27 +03:00
# gtest: test a command against git staged changes.
#
# example usage:
# gtest make test
function gtest -d "test command on staged changes only"
# Stash working dir, keeping index changes.
git stash push -q --keep-index --include-untracked; or return
# Run test command against index changes only.
command $argv
set cmdstatus $status
# Return working dir and index to original state.
# Note: reset + restore is required to prevent merge conflicts
# when popping the stash.
git reset -q
git restore .
git stash pop -q --index; or return $status
return $cmdstatus
end