Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Make deploying from Git repositories to SVN a bit easier.
if [ $# -eq 0 ]; then
echo "Run this script from within the root of the git repository that you'd like to deploy."
echo "You can only deploy something that's already been tagged in git."
echo 'Usage: ` <tag | HEAD>`'
exit 1
GIT_DIR=$( pwd )
PLUGIN=$( basename $GIT_DIR )
# Make sure we don't have uncommitted changes.
if [[ -n $( git status -s --porcelain ) ]]; then
echo "Uncommitted changes found."
echo "Please deal with them and try again clean."
exit 1
if [ "$TARGET" != "HEAD" ]; then
# Make sure we're trying to deploy something that's been tagged. Don't deploy non-tagged.
if [ -z $( git tag | grep "^$TARGET$" ) ]; then
echo "Tag $TARGET not found in git repository."
echo "Please try again with a valid tag."
exit 1
read -p "You are about to deploy a change from an unstable state 'HEAD'. This should only be done to update string typos for translators. Are you sure? [y/N]" -n 1 -r
if [[ $REPLY != "y" && $REPLY != "Y" ]]
exit 1
git checkout $TARGET
# Prep a home to drop our new files in. Just make it in /tmp so we can start fresh each time.
rm -rf $SVN_DIR
echo "Checking out SVN shallowly to $SVN_DIR"
svn -q checkout "$PLUGIN/" --depth=empty $SVN_DIR
echo "Done!"
echo "Checking out SVN trunk to $SVN_DIR/trunk"
svn -q up trunk
echo "Done!"
echo "Checking out SVN tags shallowly to $SVN_DIR/tags"
svn -q up tags --depth=empty
echo "Done!"
echo "Deleting everything in trunk except for .svn directories"
for file in $(find $SVN_DIR/trunk/* -not -path "*.svn*"); do
rm $file 2>/dev/null
echo "Done!"
echo "Rsync'ing everything over from Git except for .git stuffs and stuff in .svnignore"
rsync -r --exclude-from "$GIT_DIR/.svnignore" $GIT_DIR/* $SVN_DIR/trunk
echo "Done!"
echo "Updating stable tag in readme.txt"
perl -pi -e "s/Stable tag: .*/Stable tag: $TARGET/" trunk/readme.txt
echo "Now, your turn. Go to $SVN_DIR and add handle adding or removing any files, then tag and commit."

This comment has been minimized.

Copy link
Owner Author

@georgestephanis georgestephanis commented Nov 21, 2018

Keep a .svnignore file in your git directory with files and paths that shouldn't get shoved across to svn. It'll probably look something like this:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment