From 6d4750a3fced6ed93d78c1427a68aaf0ced0988c Mon Sep 17 00:00:00 2001 From: JDGrimes Date: Sat, 31 Jan 2015 12:08:28 -0500 Subject: [PATCH] Build tools: Update git-to-svn.sh Fixes several bugs and adds the following features: - Automatically stages the changes in SVN. - Automatically sets the correct MIME type for PNG images in the assets/ folder. Fixes #249 --- tools/bin/git-to-svn.sh | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/tools/bin/git-to-svn.sh b/tools/bin/git-to-svn.sh index 68d1c9ba..ffc218be 100755 --- a/tools/bin/git-to-svn.sh +++ b/tools/bin/git-to-svn.sh @@ -4,29 +4,48 @@ if [ -z "$1" ]; then echo 'Usage: git-to-svn.sh []' echo ' is the path within the SVN checkout to copy the files to.' echo ' It defaults to trunk. Another possible value would be branches/1.8.' - return 0 + exit 0 fi svn=$1 if [ -z "$2" ]; then - subpath=trunk + subpath=trunk/src else subpath=$2 fi -git=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +git=$( cd "$( dirname "${BASH_SOURCE[0]}" | xargs dirname | xargs dirname )" && pwd ) -echo "Removing old files from SVN /$subpath..." -sudo find "$svn/$subpath" -type f -exec rm '{}' ';' +echo "Syncing files from git to SVN /$subpath..." +rsync -avz --delete "$git/src/" "$svn/$subpath/" -echo "Copying new files from git to SVN /$subpath..." -cp -r "$git/src" "$svn/$subpath/" +echo 'Syncing the assets directory...' +rsync -avz --delete "$git/assets/" "$svn/assets/" -echo 'Copying the assets directory...' -sudo rm -rf "$svn/assets" -cp -r "$git/assets" "$svn/assets" +cd "$svn" -echo 'Done! You can now commit the changes.' +if svn status | grep -s '^!'; then + echo 'Removing deleted files from SVN...' + svn status | grep '^!' | awk '{print $2}' | xargs svn delete --force +fi + +echo 'Adding new files to SVN...' +svn add --force "$svn/$subpath/" --auto-props --parents --depth infinity -q +svn add --force assets/ --auto-props --parents --depth infinity -q + +echo 'Updating asset MIME types...' +OLD_IFS="$IFS" +IFS=$'\n' +for file in $( find assets/ -name "*.png" ); do + if svn info "$file" 1>/dev/null 2>&1; then + svn propset svn:mime-type image/png "$file" + fi +done +IFS="$OLD_IFS" + +echo 'Done! You can now commit the changes:' + +svn status # EOF