-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-wrapper
More file actions
executable file
·39 lines (33 loc) · 947 Bytes
/
create-wrapper
File metadata and controls
executable file
·39 lines (33 loc) · 947 Bytes
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
#!/bin/sh
source /etc/profile.d/env.sh
if [ "$VERBOSE" = "true" ]; then
echo $SSH_ORIGINAL_COMMAND 1>&2
fi
cmd=$(echo $SSH_ORIGINAL_COMMAND | cut -d ' ' -f 1)
cd /repos
if [ "$cmd" = "git-receive-pack" ] && [ ! "$DO_NOT_CREATE_IF_NOT_EXIST" = "true" ]; then
# Parse repo name
repo=$(echo $SSH_ORIGINAL_COMMAND | cut -d ' ' -f 2 | xargs)
if [ "$?" -ne 0 ]; then
echo "error parsing repo name! aborting!" 1>&2
exit 1
fi
# Check for directory:
if [ ! -d $repo ]; then
echo "$repo does not exist! creating..." 1>&2
mkdir -p $repo
fi
# Check for git repo:
git -C $repo --git-dir=. rev-parse 2>/dev/null
if [ "$?" -ne 0 ]; then
echo -n "$repo is not a bare git repository! " 1>&2
if [ "$(ls -A $repo)" ]; then
echo "destination is not empty! aborting initialization!" 1>&2
exit 1
else
echo "initializing..." 1>&2
git init --bare $repo 1>/dev/null 2>&1
fi
fi
fi
/usr/bin/git-shell -c "$SSH_ORIGINAL_COMMAND"