Skip to content

Instantly share code, notes, and snippets.

@gonzedge
Last active September 30, 2015 14:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzedge/8447840ed0e5710eb228 to your computer and use it in GitHub Desktop.
Save gonzedge/8447840ed0e5710eb228 to your computer and use it in GitHub Desktop.
Put your git author in your git-svn commit messages (works great with `git pair`!)

This script will set up a hook to insert your git author information into the body of Subversion commit messages.

To set it up, cd into your favorite git-svn repository and run the following command:

bash < <( curl -s -L https://gist.githubusercontent.com/gonzedge/8447840ed0e5710eb228/raw/set-up-git-svn-hooks.sh )

Enjoy!

#!/bin/sh
git_prepare_commit_msg_hook=./.git/hooks/prepare-commit-msg
cat <<"END_OF_HOOK" > $git_prepare_commit_msg_hook
#!/bin/sh
author_label="Author Name"
author_name=`git config --local user.name`
author_email=`git config --local user.email`
if [ -z "$author_name" ]
then
author_name=`git config --global user.name`
author_email=`git config --global user.email`
fi
if [ -z "$author_name" ]
then
echo "git author does not appear to be set up correctly (aka, what's your name again?)"
exit 1;
fi
cat $1 | grep -q "$author_label"
if [ "$?" -ne "0" ]
then
echo >> $1
echo "$author_label: $author_name" >> $1
echo "Author Email: $author_email" >> $1
fi
END_OF_HOOK
chmod +x $git_prepare_commit_msg_hook
echo "$git_prepare_commit_msg_hook created!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment