fix: ensure we can disable setting the rev-env-var

This commit is contained in:
Jose Diaz-Gonzalez
2018-03-31 04:30:15 -04:00
parent 0d5a77fcd6
commit 23c25a44ec
5 changed files with 29 additions and 13 deletions

View File

@@ -152,14 +152,18 @@ git_hook_cmd() {
git_build() {
declare desc="setup and call git_build_app_repo"
local APP="$1"
local APP="$1" REV="$2"
local DOKKU_DEPLOY_BRANCH ENV_VAR_NAME REF
if [[ $# -ge 2 ]]; then
ENV_VAR_NAME="$(fn-plugin-property-get "git" "$APP" "rev-env-var" "GIT_REV")"
ENV_VAR_NAME="$(fn-plugin-property-get "git" "$APP" "rev-env-var")"
if [[ -z "$ENV_VAR_NAME" ]] && ! fn-plugin-property-exists "git" "$APP" "rev-env-var"; then
ENV_VAR_NAME="GIT_REV"
fi
if [[ -n "$ENV_VAR_NAME" ]]; then
config_set --no-restart "$APP" "${ENV_VAR_NAME}=${REV}" > /dev/null
fi
local REF="$2"
local REF="$REV"
else
DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
REF=$(< "$DOKKU_ROOT/$APP/refs/heads/$DOKKU_DEPLOY_BRANCH")

View File

@@ -30,9 +30,13 @@ git-set-cmd() {
fn-plugin-property-write "git" "$APP" "$KEY" "$VALUE"
else
dokku_log_info2_quiet "Unsetting ${KEY}"
fn-plugin-property-delete "git" "$APP" "$KEY"
if [[ "$KEY" == "enabled" ]]; then
fn-plugin-property-destroy "git" "$APP"
if [[ "$KEY" == "rev-env-var" ]]; then
fn-plugin-property-write "git" "$APP" "$KEY" "$VALUE"
else
fn-plugin-property-delete "git" "$APP" "$KEY"
if [[ "$KEY" == "enabled" ]]; then
fn-plugin-property-destroy "git" "$APP"
fi
fi
fi
}