mirror of
https://github.com/dokku/dokku.git
synced 2026-02-23 19:50:34 +01:00
fix: ensure we call apps_create at all proper locations
This commit is contained in:
@@ -11,7 +11,7 @@ apps_create() {
|
||||
[[ -d "$DOKKU_ROOT/$APP" ]] && dokku_log_fail "Name is already taken"
|
||||
|
||||
mkdir -p "$DOKKU_ROOT/$APP"
|
||||
echo "Creating $APP... done"
|
||||
dokku_log_info1_quiet "Creating $APP... done"
|
||||
plugn trigger post-create "$APP"
|
||||
}
|
||||
|
||||
@@ -58,3 +58,18 @@ apps_exists() {
|
||||
[[ -d "$DOKKU_ROOT/$APP" ]] || dokku_log_fail "App does not exist"
|
||||
dokku_log_info1 "App already exists"
|
||||
}
|
||||
|
||||
apps_maybe_create() {
|
||||
declare desc="creates an app dir if allowed"
|
||||
declare APP="$1"
|
||||
|
||||
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
|
||||
DOKKU_GLOBAL_DISABLE_AUTOCREATE="$(config_get --global DOKKU_DISABLE_APP_AUTOCREATION || true)"
|
||||
if [[ "$DOKKU_GLOBAL_DISABLE_AUTOCREATE" == "true" ]]; then
|
||||
dokku_log_warn "App auto-creation disabled."
|
||||
dokku_log_fail " ! Re-enable app auto-creation or create an app with 'dokku apps:create ${APP}'"
|
||||
else
|
||||
suppress_output apps_create "$APP"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -1186,3 +1186,17 @@ release_app_deploy_lock() {
|
||||
|
||||
flock -u "$APP_DEPLOY_LOCK_FD" && rm -f "$APP_DEPLOY_LOCK_FILE" &> /dev/null
|
||||
}
|
||||
|
||||
suppress_output() {
|
||||
declare desc="suppress all output from a given command unless there is an error"
|
||||
local TMP_COMMAND_OUTPUT
|
||||
TMP_COMMAND_OUTPUT=$(mktemp "/tmp/${FUNCNAME[0]}.XXXX")
|
||||
trap 'rm -rf "$TMP_COMMAND_OUTPUT" > /dev/null' RETURN INT TERM EXIT
|
||||
|
||||
"$@" > "$TMP_COMMAND_OUTPUT" 2>&1 || {
|
||||
local exit_code="$?"
|
||||
cat "$TMP_COMMAND_OUTPUT"
|
||||
return "$exit_code"
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -36,15 +36,7 @@ git_build_app_repo() {
|
||||
chmod 755 "$GIT_BUILD_APP_REPO_TMP_WORK_DIR"
|
||||
unset GIT_DIR GIT_WORK_TREE
|
||||
|
||||
DOKKU_GLOBAL_DISABLE_AUTOCREATE="$(config_get --global DOKKU_DISABLE_APP_AUTOCREATION || true)"
|
||||
if [[ ! -d "$DOKKU_ROOT/$APP" ]]; then
|
||||
if [[ "$DOKKU_GLOBAL_DISABLE_AUTOCREATE" == "true" ]]; then
|
||||
dokku_log_warn "Invalid app name '$APP' specified."
|
||||
dokku_log_fail "Check the name of the app or create an app with 'dokku apps:create ${APP}'"
|
||||
else
|
||||
apps_create "$APP"
|
||||
fi
|
||||
fi
|
||||
[[ ! -d "$DOKKU_ROOT/$APP" ]] && apps_maybe_create "$APP"
|
||||
|
||||
if use_git_worktree; then
|
||||
# git worktree - this method uses git worktree which was introduced in git 2.5
|
||||
@@ -107,20 +99,6 @@ git_trigger_build() {
|
||||
fi
|
||||
}
|
||||
|
||||
suppress_output() {
|
||||
declare desc="suppress all output from a given command unless there is an error"
|
||||
local TMP_COMMAND_OUTPUT
|
||||
TMP_COMMAND_OUTPUT=$(mktemp "/tmp/${FUNCNAME[0]}.XXXX")
|
||||
trap 'rm -rf "$TMP_COMMAND_OUTPUT" > /dev/null' RETURN INT TERM EXIT
|
||||
|
||||
"$@" > "$TMP_COMMAND_OUTPUT" 2>&1 || {
|
||||
local exit_code="$?"
|
||||
cat "$TMP_COMMAND_OUTPUT"
|
||||
return "$exit_code"
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
git_deploy_branch() {
|
||||
declare desc="retrieve the deploy branch for a given application"
|
||||
local cmd="git-hook"
|
||||
@@ -207,6 +185,8 @@ git_upload_pack_cmd() {
|
||||
declare APP="$2"
|
||||
APP="$(echo "$APP" | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g' | sed 's/^\///g')"
|
||||
is_valid_app_name "$APP"
|
||||
[[ ! -d "$DOKKU_ROOT/$APP" ]] && apps_maybe_create "$APP"
|
||||
|
||||
plugn trigger git-pre-pull "$APP"
|
||||
cat | git-upload-pack "$DOKKU_ROOT/$APP"
|
||||
plugn trigger git-post-pull "$APP"
|
||||
@@ -220,6 +200,8 @@ git_glob_cmd() {
|
||||
is_valid_app_name "$APP"
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user