Wrap text
Report abuse
|
|
#!/usr/bin/env bash
HTTP=0
SSH_INIT='ssh git.keep "rm -fr /var/cache/git/testing.git; git --git-dir=/var/cache/git/testing.git --bare init"'
SSH_DEST=ssh://git.keep/var/cache/git/testing.git
announce() {
set -o |grep xtrace |grep off 2>/dev/null >/dev/null
SET=$?
set +o xtrace
echo "======================"
echo $1
echo "======================"
if [ ${SET} -eq 1 ]; then
set -o xtrace
fi
}
update_git_svn() {
announce "update git-upstream"
(
cd git-upstream
git svn rebase
)
update_git_local
}
update_git_local() {
announce "update git local"
(
cd git-local
git pull
if [ ${HTTP} -eq 1 ]; then
git push --all ${SSH_DEST}
fi
)
}
update_git_users() {
announce "update user git copies"
(cd git-users/me && git pull)
(cd git-users/you && git pull)
}
add_svn_file() {
announce "adding $1 to svn upstream"
(
cd svn-upstream-checkout/trunk
date >$1
svn add $1
svn ci -m "$2"
)
[ -d git-upstream ] && update_git_svn
[ -d git-local ] && update_git_local
[ -d git-users ] && update_git_users
}
add_git_file() {
announce "adding $2 in git $1 and pushing"
(
cd git-users/$1
date >$2
git add .
git commit -m "$3" --author "$1 <$1@hax0rs.spork.in>"
git push
)
[ -d git-local ] && update_git_local
[ -d git-users ] && update_git_users
}
##############
# START HERE #
##############
announce "about to start working in `pwd`; ok?"
read response
if [ "x"${response}"x" == "xyx" ]; then
echo "continuing"
else
echo "dying"
exit 1
fi
set -o xtrace
announce "make svn upstream"
svnadmin create svn-upstream-source
announce "checkout svn upstream"
SVN=file://`pwd`/svn-upstream-source
svn co ${SVN} svn-upstream-checkout
(
cd svn-upstream-checkout
svn mkdir trunk branches tags
svn ci -m 'Initial structure'
)
add_svn_file "FIRST" "It has begun!"
if [ ${HTTP} -eq 1 ]; then
announce "make git http repo"
${SSH_INIT}
fi
announce "make git upstream"
mkdir git-upstream
(
cd git-upstream
git svn init -t tags -b branches -T trunk ${SVN}
git svn fetch
)
announce "make local git mirror"
git clone git-upstream git-local
update_git_svn
update_git_local
announce "make user git copies"
mkdir git-users
git clone git-local git-users/me
git clone git-local git-users/you
#####################
# SETUP IS COMPLETE #
#####################
add_svn_file "SECOND" "The second is this!"
add_git_file "me" "FROM-ME" "You need this file!"
add_svn_file "THIRD" "More, more, more"
add_git_file "you" "FROM-YOU" "Winner!"
add_git_file "me" "ANOTHER_ONE" "ZOMG!"
add_svn_file "FOURTH" "Yawn!"
|