Skip to content

Commit 46e8c3d

Browse files
committed
Added which works similar to
1 parent f34bb41 commit 46e8c3d

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

‎plugins/git/commands‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
source "$(dirname $0)/../dokku_common"
44

5-
create_bare_repository() {
6-
git init --bare "$2" > /dev/null
5+
create_pre_receive_hook() {
76
PRERECEIVE_HOOK="$2/hooks/pre-receive"
87
cat > "$PRERECEIVE_HOOK" <<EOF
98
#!/usr/bin/env bash
@@ -13,6 +12,11 @@ EOF
1312
chmod +x "$PRERECEIVE_HOOK"
1413
}
1514

15+
create_bare_repository() {
16+
git init --bare "$2" > /dev/null
17+
create_pre_receive_hook "$@"
18+
}
19+
1620
case "$1" in
1721
git-hook)
1822
verify_app_name "$2"
@@ -64,9 +68,28 @@ case "$1" in
6468
info "Application $APP created!"
6569
;;
6670

71+
clone)
72+
cleanup_clone() {
73+
dokku delete "$APP"
74+
}
75+
check_app_name "$2"
76+
verify_max_args 4 "$@"
77+
[[ -d "$APP_DIR/refs" ]] && fail "$APP: already exist"
78+
info "Cloning $APP repository from $3..."
79+
git clone --bare -b "${4:-master}" "$3" "$APP_DIR"
80+
cd "$APP_DIR"
81+
HEAD="$(git rev-parse "${4:-master}")"
82+
trap cleanup_clone EXIT
83+
create_pre_receive_hook "$APP" "$APP_DIR"
84+
dokku rebuild "$APP" "$HEAD"
85+
echo "$HEAD" > "refs/heads/master"
86+
trap - EXIT
87+
;;
88+
6789
help | git:help)
6890
cat && cat <<EOF
69-
create <app> Create shallow app
91+
create <app> Create shallow app
92+
clone <app> <repository> [branch] Create application by cloning git repository
7093
EOF
7194
;;
7295

0 commit comments

Comments
 (0)