Skip to content

Commit

Permalink
Build tools: Update git-to-svn.sh
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JDGrimes committed Jan 31, 2015
1 parent f41fbe3 commit 6d4750a
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions tools/bin/git-to-svn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,48 @@ if [ -z "$1" ]; then
echo 'Usage: git-to-svn.sh <path-to-svn> [<subpath>]'
echo ' <subpath> 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

0 comments on commit 6d4750a

Please sign in to comment.