Last active
July 28, 2017 15:17
-
-
Save werm098/babd25c69c2f7b963fcc0b7afb975f2e to your computer and use it in GitHub Desktop.
Simple bash functions for working with 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 svnmkbranch() { | |
if [ -z "$1" ]; then | |
echo "Error: Missing new branch name arg" | |
return | |
fi | |
local url=$(svn info | grep "^URL"); url=${url:5} | |
if [[ $url == *"/branches/"* ]]; then | |
local urlStringLength=${#url} | |
local branchName=$(svnbranchname) | |
local repoUrl=${url:0:urlStringLength-(10+${#branchName})} | |
local trunkUrl=$repoUrl"/trunk" | |
local newBranchUrl=$repoUrl"/branches/"$1 | |
svn cp -m "created new branch" $trunkUrl $newBranchUrl | |
svn switch $newBranchUrl | |
else | |
echo "Error: You need to be in the branches directory for this to work" | |
fi | |
} | |
function svnmergebranch() { | |
if [ -z "$1" ]; then | |
echo "Error: Missing branch name to merge" | |
return | |
fi | |
local url=$(svn info | grep "^URL"); url=${url:5} | |
if [[ $url == *"/branches/"* ]]; then | |
local urlStringLength=${#url} | |
local branchName=$(svnbranchname) | |
local repoUrl=${url:0:urlStringLength-(10+${#branchName})} | |
local mergeBranchUrl=$repoUrl"/branches/"$1 | |
svn merge $mergeBranchUrl | |
else | |
echo "Error: You need to be in the branches directory for this to work" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment