Skip to content

Instantly share code, notes, and snippets.

@ddbeck
Created May 20, 2016 14:32
Show Gist options
  • Save ddbeck/29bb1ea4b42de3841428abc5f0dcc563 to your computer and use it in GitHub Desktop.
Save ddbeck/29bb1ea4b42de3841428abc5f0dcc563 to your computer and use it in GitHub Desktop.
# modify your .gitconfig to include these in the alias section
[alias]
svnci = !$HOME/bin/git-svn-safe.sh dcommit
svnre = !$HOME/bin/git-svn-safe.sh rebase
svnsync = !git svnre && git svnci
#!/usr/bin/env bash
# this file goes in #$HOME/bin/ or someplace convenient like that
branch=$(git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3)
if [[ $branch = "master" ]]; then
output=$(git svn "$@" 2>&1 | tee /dev/tty)
# provide a summary of revisions committed
count=$(echo -e "$output" | grep -c "^Committed")
if [[ $count > 0 ]]; then
echo -e "\nLog of $count commits:"
git svn log --reverse --oneline -n"$count" | \
sed -E 's/^(r[0-9]+) [|]/\1:/'
fi
else
echo Avoid runing git svn "$@" on a branch other than master.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment