Girocco::Config::project_owners: Introduce configuration variable
[girocco.git] / mirroring / clone.sh
blob5c379265812fc8a5802c54645c82d3d491c845a5
1 #!/bin/bash
3 # Invoked from mirroring/cloned.pl
5 . @basedir@/shlib.sh
7 set -e
9 projdir="$1"
10 proj="${projdir%.git}"
12 cd "$cfg_reporoot/$projdir"
13 trap "echo '@OVER@'; touch .clone_failed" EXIT
14 url="$(cat base_url)"
16 if [ "$cfg_project_owners" = "source" ]; then
17 echo "$(stat -c %U "$url" 2>/dev/null)" >owner
20 mail="$(cat owner)"
22 # Configure
23 echo "Configuring repository..."
24 git config --bool mirror.allowed true
26 # Initial mirror
27 echo "Initiating mirroring..."
28 case "$url" in
29 svn://*)
30 GIT_DIR=. git svn init -s "$url"
31 GIT_DIR=. git svn fetch
32 # Neat Trick suggested by Miklos Vajna
33 GIT_DIR=. git config remote.origin.url .
34 GIT_DIR=. git config remote.origin.fetch +refs/remotes/heads/*:refs/heads/*
35 GIT_DIR=. git config remote.origin.fetch +refs/remotes/trunk:refs/heads/master
36 GIT_DIR=. git config remote.origin.fetch +refs/remotes/tags/*:refs/tags/*
37 GIT_DIR=. git fetch
39 *) git mirror "$url";;
40 esac
42 # The rest
43 echo "Final touches..."
44 git update-server-info
45 trap "" EXIT
46 mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <<EOT
47 Congratulations! The clone of project $proj just completed.
49 * Source URL: $url
50 * GitWeb interface: $cfg_gitweburl/$projdir
51 * Project settings: $cfg_webadmurl/editproj.cgi?name=$proj
53 Have a lot of fun.
54 EOT
56 echo "Mirroring finished successfuly!"
57 rm .clone_in_progress
58 echo "@OVER@"