Created
August 4, 2011 12:18
-
-
Save scribu/1125050 to your computer and use it in GitHub Desktop.
Plugin deploy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# args | |
MSG=${1-'deploy from git'} | |
BRANCH=${2-'trunk'} | |
# paths | |
SRC_DIR=$(git rev-parse --show-toplevel) | |
DIR_NAME=$(basename $SRC_DIR) | |
DEST_DIR=~/svn/$DIR_NAME/$BRANCH | |
# build first | |
if [ -f "$SRC_DIR/bin/build" ]; then | |
$SRC_DIR/bin/build | |
fi | |
# make sure we're deploying from the right dir | |
if [ ! -d "$SRC_DIR/.git" ]; then | |
echo "$SRC_DIR doesn't seem to be a git repository" | |
exit | |
fi | |
# make sure the destination dir exists | |
mkdir -p $DEST_DIR | |
svn add $DEST_DIR 2> /dev/null | |
# delete everything except .svn dirs | |
for file in $(find $DEST_DIR/* -type -f -and -not -path "*.svn*") | |
do | |
rm $file | |
done | |
# copy everything over from git | |
rsync --recursive --exclude='*.git*' $SRC_DIR/* $DEST_DIR | |
cd $DEST_DIR | |
# check .svnignore | |
for file in $(cat "$SRC_DIR/.svnignore" 2> /dev/null) | |
do | |
rm -rf $DEST_DIR/$file | |
done | |
# Transform the readme | |
if [ -f README.md ]; then | |
mv README.md readme.txt | |
sed -i '' -e 's/^# \(.*\)$/=== \1 ===/' -e 's/ #* ===$/ ===/' -e 's/^## \(.*\)$/== \1 ==/' -e 's/ #* ==$/ ==/' -e 's/^### \(.*\)$/= \1 =/' -e 's/ #* =$/ =/' readme.txt | |
fi | |
# svn addremove | |
svn stat | awk '/^\?/ {print $2}' | xargs svn add > /dev/null 2>&1 | |
svn stat | awk '/^\!/ {print $2}' | xargs svn rm --force | |
svn stat | |
svn ci -m "$MSG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -lt 1 ]; then | |
echo 'usage: plugin-tag 1.2.3' | |
exit | |
fi | |
TAG_NAME=$1 | |
git tag $TAG_NAME | |
git push | |
git push --tags | |
plugin-deploy "tagging version $TAG_NAME" tags/$TAG_NAME |
FYI any file names containing an @ symbol will fail for the svn addremove stuff. Need to do what they suggest here: http://stackoverflow.com/a/6372054
svn stat | awk '/^\?/ {print $2}' | xargs -I x svn add x@ > /dev/null 2>&1
svn stat | awk '/^\!/ {print $2}' | xargs -I x svn rm --force x@
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info: http://scribu.net/blog/deploying-from-git-to-svn.html