mirror of
https://github.com/dokku/dokku.git
synced 2026-09-03 04:32:26 +02:00
It may be desirable to keep the contents of the git directory for the build process. Certain build tools can extract extra information from the .git directory, and some workflows may require that the shipped artifact has the entire source code available locally for later usage.
47 lines
1.4 KiB
Bash
Executable File
47 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
|
set -eo pipefail
|
|
[[ $DOKKU_TRACE ]] && set -x
|
|
|
|
fn-in-array() {
|
|
declare desc="return true if value ($1) is in list (all other arguments)"
|
|
|
|
local e
|
|
for e in "${@:2}"; do
|
|
[[ "$e" == "$1" ]] && return 0
|
|
done
|
|
return 1
|
|
}
|
|
|
|
git-set-cmd() {
|
|
declare desc="set or clear a git property for an app"
|
|
local cmd="git:set" argv=("$@")
|
|
[[ ${argv[0]} == "$cmd" ]] && shift 1
|
|
declare APP="$1" KEY="$2" VALUE="$3"
|
|
local VALID_KEYS=("deploy-branch" "keep-git-dir" "rev-env-var")
|
|
[[ -z "$APP" ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
[[ -z "$KEY" ]] && dokku_log_fail "No key specified"
|
|
|
|
if ! fn-in-array "$KEY" "${VALID_KEYS[@]}"; then
|
|
dokku_log_fail "Invalid key specified, valid keys include: deploy-branch, keep-git-dir, rev-env-var"
|
|
fi
|
|
|
|
if [[ -n "$VALUE" ]]; then
|
|
dokku_log_info2_quiet "Setting ${KEY} to ${VALUE}"
|
|
fn-plugin-property-write "git" "$APP" "$KEY" "$VALUE"
|
|
else
|
|
dokku_log_info2_quiet "Unsetting ${KEY}"
|
|
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
|
|
}
|
|
|
|
git-set-cmd "$@"
|