Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 55 lines (44 sloc) 1.64 KB
#!/bin/sh
# TODO Someday support:
# [--branch <branch name> | --calculate-branches]
#
if [ -z "$1" ]; then
REF="HEAD"
else
REF=$1
fi
# Make sure we where called correctly.
CURRENT_GIT="$(git rev-parse --git-dir 2>/dev/null)" || exit 4 "** Must be called from within a git repository **"
COMMIT_REF=$(git name-rev --name-only $REF) || exit 5 "** Must provide a single, valid sha-1 commit id **"
BRANCH=${COMMIT_REF/~[0-9]*/}
if [ $BRANCH = "" ]; then
exit
fi
# Include or general drupal sync config.
. /etc/drupal_sync.conf
# Figure out what our module name is.
if [ "$CURRENT_GIT" == '.git' ]; then
MODULE=`pwd | sed 's@/.*/@@'`
else
# TODO I think this is broken
MODULE=`git rev-parse --git-dir | sed 's@/.*/\(.*\)/\.git@\1@'`
fi
clean_up() {
cvs -d/srv/cvs/drupal up -C $GITSRV/$MODULE_BASE/.cvsco/$MODULE/$BRANCH/ > /dev/null
rm $GITSRV/$MODULE_BASE/.cvsco/$MODULE/$BRANCH/.msg $GITSRV/$MODULE_BASE/.cvsco/$MODULE/$BRANCH/.cvsexportcommit.diff
find $GITSRV/$MODULE_BASE/.cvsco/$MODULE/$BRANCH -name '.#*' -exec rm '{}' \;
echo "** CVS commit failed. Cleaning up cvs directory... **"
exit 2
}
if [ $MODULE = 'core' ]; then
MODULE_BASE="drupal"
else
MODULE_BASE="contrib"
fi
echo '** Exporting commit to CVS: **'
git cvsexportcommit -ucpw $GITSRV/$MODULE_BASE/.cvsco/$MODULE/$BRANCH $REF || clean_up
#drup-cvstogit $MODULE
echo '** Re-updating local git repos from CVS **'
git cvsimport -umak -p u -o master -C $GITSRV/$MODULE_BASE/.cvsimport/$MODULE -d:pserver:anonymous@cvs.drupal.org:/cvs/drupal-contrib contributions/modules/$MODULE > /dev/null
git --git-dir=$GITSRV/$MODULE_BASE/$MODULE.git fetch
git pull && git rebase origin/$BRANCH