Last active
August 2, 2017 13:03
-
-
Save werm098/81d6720218da762b315848be50032854 to your computer and use it in GitHub Desktop.
Simple bash functions to simulate a git stash in SVN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function svnbranchname() { | |
svn info | grep "^Relative URL" | grep -oE "[^/]+$" | |
} | |
function svnstash() { | |
local branchName=$(svnbranchname) | |
if [ -n "$branchName" ]; then | |
if [ ! -d "../$branchName" ]; then | |
cp -Rv . ../$branchName | |
svn revert -R . | |
else | |
echo "Error: stash already exists for this branch!" | |
fi | |
else | |
echo "Error: SVN branch not found" | |
fi | |
} | |
function svnstashpop() { | |
local branchName=$(svnbranchname) | |
local stashTrashDir="stash_trash" | |
if [ -n "$branchName" ]; then | |
if [ ! -d "../$stashTrashDir" ]; then | |
cd .. | |
mv working/ $stashTrashDir/ | |
mv $branchName/ working/ | |
cd working | |
echo "SVN pop of $branchName was successful" | |
else | |
echo "Error: previous stash pop needs to be cleaned up first ($stashTrashDir)" | |
fi | |
else | |
echo "Error: SVN branch not found" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment