2010-06-01 12:57:33 +02:00
|
|
|
#!/bin/sh
|
2010-04-24 19:30:38 +02:00
|
|
|
|
|
|
|
. $(dirname $0)/adc.common-functions
|
|
|
|
|
2011-01-15 16:39:56 +01:00
|
|
|
[ -z "$GL_RC" ] && die "ENV GL_RC not set"
|
2011-02-25 16:03:58 +01:00
|
|
|
[ -z "$2" ] && die "Usage: fork source_repo target_repo"
|
2011-01-15 16:39:56 +01:00
|
|
|
|
2011-11-22 10:25:15 +01:00
|
|
|
# all the can_* functions set $repo
|
|
|
|
can_read $1 || die "no read permissions on $repo"
|
|
|
|
from=$repo
|
2010-04-24 19:30:38 +02:00
|
|
|
|
2011-11-22 10:25:15 +01:00
|
|
|
can_create $2 || die "no create permissions on $repo"
|
|
|
|
to=$repo
|
2010-04-24 19:30:38 +02:00
|
|
|
|
2010-06-12 12:32:07 +02:00
|
|
|
# clone $from to $to
|
|
|
|
git clone --bare -l $GL_REPO_BASE_ABS/$from.git $GL_REPO_BASE_ABS/$to.git
|
2010-06-22 13:30:48 +02:00
|
|
|
[ $? -ne 0 ] && exit 1
|
2010-06-12 12:32:07 +02:00
|
|
|
|
2011-02-25 16:03:58 +01:00
|
|
|
echo "$from forked to $to"
|
|
|
|
|
2010-08-20 17:25:23 +02:00
|
|
|
# fix up creator, gitweb owner, and hooks
|
2010-04-24 19:30:38 +02:00
|
|
|
cd $GL_REPO_BASE_ABS/$to.git
|
2010-06-12 12:32:07 +02:00
|
|
|
echo $GL_USER > gl-creater
|
2010-08-20 17:25:23 +02:00
|
|
|
git config gitweb.owner "$GL_USER"
|
2011-01-15 16:39:56 +01:00
|
|
|
( $GL_BINDIR/gl-query-rc GL_WILDREPOS_DEFPERMS ) |
|
2010-08-20 17:25:23 +02:00
|
|
|
SSH_ORIGINAL_COMMAND="setperms $to" $GL_BINDIR/gl-auth-command $GL_USER
|
2012-02-29 08:53:58 +01:00
|
|
|
|
|
|
|
# symlink hooks
|
|
|
|
shopt -s nullglob
|
|
|
|
# the order is important; "package" hooks must override same-named "user" hooks
|
|
|
|
for i in `$GL_BINDIR/gl-query-rc GL_ADMINDIR`/hooks/common/* \
|
|
|
|
`$GL_BINDIR/gl-query-rc GL_PACKAGE_HOOKS `/common/*
|
|
|
|
do
|
|
|
|
ln -sf $i $GL_REPO_BASE_ABS/$to.git/hooks
|
|
|
|
done
|
2010-06-22 13:30:48 +02:00
|
|
|
|
|
|
|
if [ -n "$GL_WILDREPOS_DEFPERMS" ]; then
|
|
|
|
echo "$GL_WILDREPOS_DEFPERMS" > gl-perms
|
|
|
|
fi
|
|
|
|
|
2011-02-25 16:03:58 +01:00
|
|
|
echo "$from" > gl-forked-from
|
|
|
|
|
2010-09-24 12:49:33 +02:00
|
|
|
# run gitolite's post-init hook if you can (hook code expects GL_REPO to be set)
|
|
|
|
export GL_REPO; GL_REPO="$to"
|
|
|
|
[ -x hooks/gl-post-init ] && hooks/gl-post-init
|