I quickly demoed my git svn setup at the conference. Here's the bash
function I was using. Not special nor really needed, but it just
remembers a few commands I often write in a row.
function gvn {
if [ "$USER" == "" ]; then
echo "USER variable must be set for local branch naming"
return
fi
if [ ! -f .git/config ]; then
echo "Unable to find a .git/config"
return
fi
url=`/bin/cat .git/config |/usr/bin/perl -ne '$inRemote = 1 if
/^\s*\[svn-remote/; if ($inRemote and /^\s*url\s*=\s*(.+)\s*$/) { my $url = $1;
$url =~ s/^\s*//; $url =~ s/\s*$//; print $url; }'`
if [ "$url" == "" ]; then
echo "No url in .git/config"
return
fi
if [ "$1" == "newbranch" ]; then
if [ "$2" == "" -o "$3" == "" ]; then
echo "$0 newbranch requires two arguments, <oldbranch>
<newbranchname>"
return 1
fi
message="Created branch, $3"
if [ "$4" != "" ]; then
message="${message}: $4"
firan
if [ "$2" == "trunk" ]; then
svn cp $url/trunk $url/branches/$3 -m"$message"
else
svn cp $url/branches/$2 $url/branches/$3 -m"$message"
fi
if [ $? != 0 ]; then
echo "Failure in creating branch on remote server; git
operations to follow would be screwed up."
return 1
fi
git svn fetch
git checkout -b ${USER}/$3 svn/$3
git reset --hard svn/$3
elif [ "$1" == "pristinebranch" ]; then
git svn fetch
git checkout ${USER}/$2
git reset --hard svn/$2
elif [ "$1" == "trunkmerger" ]; then
if [ "$2" == "" ]; then
echo "$0 trunkmerger requires argument, <branch_from_name>"
return 1
elif [ "$2" == "trunk" -o "$2" == "svn/trunk" ]; then
echo "$0 trunkmerger takes a branch into trunk; give the branch
for merger not trunk itself."
return 1
fi
set -x
git checkout ${USER}/$2
git svn rebase
git checkout ${USER}/trunk
git svn rebase
git reset --hard svn/trunk
shift 2
git merge --no-ff svn/$2 $*
set +x
else
echo "$0: unknown option \"$1\""
return 1
fi
}
function _complete_gvn ()
{
local IFS=$'\t\n'
if [ $COMP_CWORD -eq 1 ]; then
args=`/bin/echo -e "pristinebranch\nnewbranch\ntrunkmerger"`
COMPREPLY=()
COMPREPLY=($(compgen -W "$args" -X"*~" "$2") )
elif [ $COMP_CWORD -eq 2 ]; then
if [ "${COMP_WORDS[1]}" == "trunkmerger" ]; then
branches=`__git_refs |/bin/fgrep -v svn/tags|/bin/fgrep svn |
/bin/fgrep -v svn/trunk| /usr/bin/perl -pe 's%^svn/%%;'`
__gitcomp "$branches"
elif [ "${COMP_WORDS[1]}" == "pristinebranch" ]; then
branches=`__git_refs |/bin/fgrep svn | /usr/bin/perl -pe
's%^svn/%%;'`
__gitcomp "$branches"
elif [ "${COMP_WORDS[1]}" == "newbranch" ]; then
branches=`__git_refs |/bin/fgrep svn | /usr/bin/perl -pe
's%^svn/%%;'`
__gitcomp "$branches"
else [ "${COMP_WORDS[1]}" == "" ];
COMPREPLY=()
fi
else
COMPREPLY=()
fi
}
complete -F _complete_gvn gvn
--
-- bkuhn
_______________________________________________
Pokersource-users mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-users