refactor: deprecate git_deploy_branch in favor of plugn trigger
This commit is contained in:
5
docs/appendices/0.21.0-migration-guide.md
Normal file
5
docs/appendices/0.21.0-migration-guide.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# 0.21.0 Migration Guide
|
||||||
|
|
||||||
|
## Deprecations
|
||||||
|
|
||||||
|
- `git#git_deploy_branch()` is deprecated in favor of `plugn trigger git-deploy-branch`.
|
||||||
@@ -531,6 +531,21 @@ verify_app_name "$APP"
|
|||||||
# TODO
|
# TODO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `git-deploy-branch`
|
||||||
|
|
||||||
|
- Description: Outputs the deploy branch for an app, inherited or not
|
||||||
|
- Invoked by:
|
||||||
|
- Arguments: `$APP`
|
||||||
|
- Example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
```
|
||||||
|
|
||||||
### `git-post-pull`
|
### `git-post-pull`
|
||||||
|
|
||||||
- Description:
|
- Description:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|||||||
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
||||||
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
source "$PLUGIN_AVAILABLE_PATH/config/functions"
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
[[ $DOKKU_TRACE ]] && set -x
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
@@ -109,18 +110,11 @@ git_trigger_build() {
|
|||||||
|
|
||||||
git_deploy_branch() {
|
git_deploy_branch() {
|
||||||
declare desc="retrieve the deploy branch for a given application"
|
declare desc="retrieve the deploy branch for a given application"
|
||||||
declare cmd="git-hook"
|
declare APP="$1"
|
||||||
local APP="$1"
|
declare deprecated=true
|
||||||
|
dokku_log_warn "Deprecated: plugn#git-deploy-branch"
|
||||||
|
|
||||||
local DOKKU_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "$APP" "deploy-branch" "")"
|
fn-git-deploy-branch "$APP"
|
||||||
local DOKKU_GLOBAL_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "--global" "deploy-branch" "")"
|
|
||||||
if [[ -n "$DOKKU_DEPLOY_BRANCH" ]]; then
|
|
||||||
echo "$DOKKU_DEPLOY_BRANCH"
|
|
||||||
elif [[ -n "$DOKKU_GLOBAL_DEPLOY_BRANCH" ]]; then
|
|
||||||
echo "$DOKKU_GLOBAL_DEPLOY_BRANCH"
|
|
||||||
else
|
|
||||||
echo "master"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd-git-hook() {
|
cmd-git-hook() {
|
||||||
@@ -132,7 +126,7 @@ cmd-git-hook() {
|
|||||||
|
|
||||||
is_valid_app_name "$APP"
|
is_valid_app_name "$APP"
|
||||||
|
|
||||||
DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
|
DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
|
||||||
if ! git check-ref-format --branch "$DOKKU_DEPLOY_BRANCH" >/dev/null 2>&1; then
|
if ! git check-ref-format --branch "$DOKKU_DEPLOY_BRANCH" >/dev/null 2>&1; then
|
||||||
echo $'\e[1G\e[K'"-----> WARNING: Invalid branch name '$DOKKU_DEPLOY_BRANCH' specified via DOKKU_DEPLOY_BRANCH."
|
echo $'\e[1G\e[K'"-----> WARNING: Invalid branch name '$DOKKU_DEPLOY_BRANCH' specified via DOKKU_DEPLOY_BRANCH."
|
||||||
echo $'\e[1G\e[K'"-----> For more details, please see the man page for 'git-check-ref-format.'"
|
echo $'\e[1G\e[K'"-----> For more details, please see the man page for 'git-check-ref-format.'"
|
||||||
@@ -174,7 +168,7 @@ git_build() {
|
|||||||
fi
|
fi
|
||||||
local REF="$REV"
|
local REF="$REV"
|
||||||
else
|
else
|
||||||
DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
|
DOKKU_DEPLOY_BRANCH="$(fn-git-deploy-branch "$APP")"
|
||||||
REF=$(<"$DOKKU_ROOT/$APP/refs/heads/$DOKKU_DEPLOY_BRANCH")
|
REF=$(<"$DOKKU_ROOT/$APP/refs/heads/$DOKKU_DEPLOY_BRANCH")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
14
plugins/git/git-deploy-branch
Executable file
14
plugins/git/git-deploy-branch
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||||
|
set -eo pipefail
|
||||||
|
[[ $DOKKU_TRACE ]] && set -x
|
||||||
|
|
||||||
|
trigger-git-git-deploy-branch() {
|
||||||
|
declare desc="git deploy-branch plugin trigger"
|
||||||
|
declare trigger="git-deploy-branch"
|
||||||
|
declare APP="$1"
|
||||||
|
|
||||||
|
fn-git-deploy-branch "$APP"
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger-git-git-deploy-branch "$@"
|
||||||
@@ -69,3 +69,18 @@ cmd-git-report-single() {
|
|||||||
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
[[ "$value_exists" == "true" ]] || dokku_log_fail "not deployed"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn-git-deploy-branch() {
|
||||||
|
declare desc="retrieve the deploy branch for a given application"
|
||||||
|
local APP="$1"
|
||||||
|
|
||||||
|
local DOKKU_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "$APP" "deploy-branch" "")"
|
||||||
|
local DOKKU_GLOBAL_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "--global" "deploy-branch" "")"
|
||||||
|
if [[ -n "$DOKKU_DEPLOY_BRANCH" ]]; then
|
||||||
|
echo "$DOKKU_DEPLOY_BRANCH"
|
||||||
|
elif [[ -n "$DOKKU_GLOBAL_DEPLOY_BRANCH" ]]; then
|
||||||
|
echo "$DOKKU_GLOBAL_DEPLOY_BRANCH"
|
||||||
|
else
|
||||||
|
echo "master"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user