summaryrefslogtreecommitdiffstats
path: root/newrepo.sh
blob: 9eb2dc17872b882bb190c3641cb985461e799dbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash

set -e

die() {
    echo "$@" >&2
    exit 1
}

server=git@the-compiler.org

trap '[[ -d "$tmp" ]] && rm -rf "$tmp"' EXIT

top=$(git rev-parse --show-toplevel)
name=${top##*/}

if [[ "$1" == --private ]]; then
    user="@private"
    shift
else
    user="@public"
fi

desc="$1"

[[ -z "$desc" ]] && die "Usage: $0 [--private] <description>"

tmp=$(mktemp -d)
cd "$tmp"
git clone "ssh://$server/gitolite-admin"
cd gitolite-admin/conf

cat >> gitolite.conf << EOF

repo $name
    R                 = $user
    config cgit.desc  = $desc
    config cgit.owner = $(git config --get user.name)
EOF
git commit -am "Add new repository for $name"
git push
cd "$top"
git remote rm origin 2>/dev/null || true
git remote add origin "$server/$name"
git push -u --all
git push --tags