aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails/22_forge/files/git-shell-commands/new
blob: 87d8e628ebc336836e25d579a7657a11dc991a23 (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
#!/bin/sh
set -e
if [ -z "$1" ]; then
    echo "Usage: new [REPO_NAME]"
    echo "Tip:   prefix with '.' to make private (e.g. new .myrepo)"
    exit 1
fi

REPO="$1"
REPO_PATH="$HOME/$REPO.git"

if [ -d "$REPO_PATH" ]; then
    echo "Repository $REPO already exists"
    exit 1
fi

git init --bare "$REPO_PATH"
echo "" > "$REPO_PATH/description"
chown -R git:git "$REPO_PATH"

if [ "${REPO#.}" = "$REPO" ]; then
    chmod -R 2755 "$REPO_PATH"
else
    chmod -R 2700 "$REPO_PATH"
fi

echo "Created repository $REPO"
echo "Clone: git@forge.jan.systems:$REPO.git"
if [ "${REPO#.}" = "$REPO" ]; then
    echo "Web:   https://forge.jan.systems/$REPO.git"
fi