Git-to-SVN Plugin Deploy by Scribu
James DiGioia
#!/usr/bin/env bash# argsMSG=${1-'deploy from git'}BRANCH=${2-'trunk'}# pathsSRC_DIR=$(git rev-parse --show-toplevel)DIR_NAME=$(basename $SRC_DIR)DEST_DIR=~/svn/$DIR_NAME/$BRANCH# build firstif [ -f "$SRC_DIR/bin/build" ]; then$SRC_DIR/bin/buildfi# make sure we're deploying from the right dirif [ ! -d "$SRC_DIR/.git" ]; thenecho "$SRC_DIR doesn't seem to be a git repository"exitfi# make sure the destination dir existsmkdir -p $DEST_DIRsvn add $DEST_DIR 2> /dev/null# delete everything except .svn dirsfor file in $(find $DEST_DIR/* -type -f -and -not -path "*.svn*")dorm $filedone# copy everything over from gitrsync --recursive --exclude='*.git*' $SRC_DIR/* $DEST_DIRcd $DEST_DIR# check .svnignorefor file in $(cat "$SRC_DIR/.svnignore" 2> /dev/null)dorm -rf $DEST_DIR/$filedone# Transform the readmeif [ -f README.md ]; thenmv README.md readme.txtsed -i '' -e 's/^# (.*)$/=== 1 ===/' -e 's/ #* ===$/ ===/' -e 's/^## (.*)$/== 1 ==/' -e 's/ #* ==$/ ==/' -e 's/^### (.*)$/= 1 =/' -e 's/ #* =$/ =/' readme.txtfi# svn addremovesvn stat | awk '/^?/ {print $2}' | xargs svn add > /dev/null 2>&1svn stat | awk '/^!/ {print $2}' | xargs svn rm --forcesvn statsvn ci -m "$MSG"
plugin-deploy.sh
#!/bin/bashif [ $# -lt 1 ]; thenecho 'usage: plugin-tag 1.2.3'exitfiTAG_NAME=$1git tag $TAG_NAMEgit pushgit push --tagsplugin-deploy "tagging version $TAG_NAME" tags/$TAG_NAME
plugin-tag.sh