blob: 53899ebeb7ebc15085dce1aa84ba0fff3d92f490 (
plain) (
blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#!/bin/sh
set -e
REPO=""
DESC=""
PROJ=""
VISIBILITY="public"
main() {
parse_args "$@"
repo_name=$(basename "$REPO" .git)
if [ -n "$PROJ" ]; then
proj_dir="{{ obsd_git_home }}/$VISIBILITY/$PROJ"
if [ ! -d "$proj_dir" ]; then
mkdir "$proj_dir"
fi
repo_path="$proj_dir/$repo_name.git"
else
repo_path="{{ obsd_git_home }}/$VISIBILITY/$repo_name.git"
fi
if [ ! -d "$repo_path" ]; then
echo "Creating bare repository: $repo_name.git"
git init --bare --initial-branch=main "$repo_path"
chown -R git:git "$repo_path"
if [ -n "$DESC" ]; then
echo "$DESC" >>"$repo_path/description"
fi
fi
}
parse_args() {
while [ $# -gt 0 ]; do
case "$1" in
--visibility)
VISIBILITY="$2"
case "$VISIBILITY" in public | private) ;; *) usage ;; esac
shift 2
;;
--description)
DESC="$2"
shift 2
;;
--project)
PROJ="$2"
shift 2
;;
-*)
echo "Unknown option: $1" >&2
exit 1
;;
*)
if [ -n "$REPO" ]; then
echo "Unexpected argument: $1" >&2
usage
fi
REPO="$1"
shift
;;
esac
done
[ -n "$REPO" ] || usage
}
usage() {
echo "Usage: $0 [--visibility public|private] [--description DESC] [--project PROJ] <repo>" >&2
exit 1
}
main "$@"
|