feat: add ability to initialize a git repository out of band

This is useful in contexts where the repository directory may be created and interacted with via git-http-backend or other methods of updating a repository.
This commit is contained in:
Jose Diaz-Gonzalez
2018-04-01 23:13:11 -04:00
parent 72674e5c6c
commit 83f320ac8e
9 changed files with 120 additions and 12 deletions

View File

@@ -211,15 +211,7 @@ git_glob_cmd() {
if [[ $1 == "git-receive-pack" && ! -d "$APP_PATH/refs" ]]; then
[[ ! -d "$DOKKU_ROOT/$APP" ]] && apps_maybe_create "$APP"
git init --bare "$APP_PATH" > /dev/null
local PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
cat > "$PRERECEIVE_HOOK" <<EOF
#!/usr/bin/env bash
set -e; set -o pipefail;
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
EOF
chmod +x "$PRERECEIVE_HOOK"
fn-git-create-hook "$APP"
fi
if [[ $1 == "git-receive-pack" ]]; then
@@ -229,3 +221,22 @@ EOF
fi
git-shell -c "$args"
}
fn-git-create-hook() {
declare APP="$1"
local APP_PATH="$DOKKU_ROOT/$APP"
local PRERECEIVE_HOOK="$APP_PATH/hooks/pre-receive"
verify_app_name "$APP"
if [[ ! -d "$APP_PATH/refs" ]]; then
git init --bare "$APP_PATH" > /dev/null
fi
cat > "$PRERECEIVE_HOOK" <<EOF
#!/usr/bin/env bash
set -e; set -o pipefail;
cat | DOKKU_ROOT="$DOKKU_ROOT" dokku git-hook $APP
EOF
chmod +x "$PRERECEIVE_HOOK"
}