Girocco::Util: Fix package name
[girocco.git] / jobs / clone.sh
blobfd23e4a98aade2a582d6c4bb835369e3dcbda968
1 #!/bin/bash
3 . shlib.sh
5 set -e
7 proj="$1"
8 queuedir="$(pwd)"
10 bang_setup
11 bang_action="clone"
12 bang_trap() {
13 # This removes any remnants from "$cfg_reporoot"/$proj.git _and_ gets rid
14 # of the group record.
15 perl -I. -MGirocco::Project -e 'Girocco::Project->ghost('"'$proj'"')->delete;'
16 cd "$queuedir" && rm -rf "$proj"/* && rmdir -p "$proj"
19 cd "$proj"
20 url="$(cat base_url)"
21 mail="$(cat owner)"
23 # First, the boring clone itself
24 ref=()
25 if [ -s objects/info/alternates ]; then
26 ref=(--reference "$(cat objects/info/alternates | sed 's#/objects$##')")
28 bang git clone "${ref[@]}" --bare "$url" repodir
30 # Double-check that we aren't going to overwrite anything existing
31 ! [ -d "$cfg_reporoot/$proj.git" ]
33 # Set up fork container if necessary
34 lproj="$(echo "$proj" | sed 's/^\(.*\/\)\(.*\)/\1/')"
35 if [ z"$lproj" != z"$proj" ]; then
36 bang mkdir -m 0775 -p "$cfg_reporoot/$lproj"
39 # Move us into our new home
40 bang mv repodir "$cfg_reporoot/$proj.git"
41 bang chmod g+w base_url owner description homepage README.html
42 bang mv base_url owner description homepage README.html "$cfg_reporoot/$proj.git/"
44 # Reconfigure
45 bang git --git-dir="$cfg_reporoot/$proj.git" config --bool --add mirror.allowed true
46 bang git --git-dir="$cfg_reporoot/$proj.git" update-server-info
48 # Clean up the queue
49 cd "$queuedir" && rm -rf "$proj"/* && rmdir -p "$proj"
50 # NO bang BELOW THIS POINT! rm -r depends on cwd.
52 mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <<EOT
53 Congratulations! The clone of project $proj just completed.
55 * GitWeb interface: $cfg_gitweburl/$proj.git
56 * Project settings: $cfg_webadmurl/editproj.cgi?name=$proj
58 Have a lot of fun.
59 EOT