From 7fedd834c9e16453d344c052a390998f534cac7d Mon Sep 17 00:00:00 2001 From: James Patrick Date: Tue, 30 Aug 2022 14:30:22 -0400 Subject: [PATCH] Added script to stash svn commits. SVN shelf does exist but is a bit obtuse to use. --- zsh/environment/host/wok/zshrc | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/zsh/environment/host/wok/zshrc b/zsh/environment/host/wok/zshrc index c7fb31a..1bb463d 100644 --- a/zsh/environment/host/wok/zshrc +++ b/zsh/environment/host/wok/zshrc @@ -11,4 +11,39 @@ switch(){ popd } +svn_stash() { + if [ ! -d .svn ]; then + echo "Not at ROOT of SVN directory." + return + fi + + if [ ! -d .svn/stash ]; then + echo "creating .svn/stash directory" + mkdir -p .svn/stash/ + fi + + if [ -z "$1" ]; then + echo "Missing stash name argument" + return + fi + + stash_file="$PWD/.svn/stash/${@[-1]}" + if [[ "$1" == "pop" ]] ; then + if [ ! -f $stash_file ]; then + echo "Cannot find stash: $stash_file" + return + fi + patch -p0 < $stash_file + elif [[ "$1" == "list" ]] ; then + ls -1 .svn/stash/ + else + if [ -f $stash_file ]; then + echo "stash already exist with that name: $stash_file" + return + fi + echo "stash file can be found at $stash_file" + svn diff > $stash_file && svn revert -R . + fi +} + eval "$(rbenv init -)"