Skip to content

Instantly share code, notes, and snippets.

@werm098
Last active August 2, 2017 13:03
Show Gist options
  • Save werm098/81d6720218da762b315848be50032854 to your computer and use it in GitHub Desktop.
Save werm098/81d6720218da762b315848be50032854 to your computer and use it in GitHub Desktop.
Simple bash functions to simulate a git stash in SVN
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