refactor: unify command declaration across codebase

This commit is contained in:
Jose Diaz-Gonzalez
2020-02-10 01:40:30 -05:00
parent b0abeb49dd
commit e67b96780d
108 changed files with 475 additions and 315 deletions

View File

@@ -109,7 +109,7 @@ git_trigger_build() {
git_deploy_branch() {
declare desc="retrieve the deploy branch for a given application"
local cmd="git-hook"
declare cmd="git-hook"
local APP="$1"
local DOKKU_DEPLOY_BRANCH="$(fn-plugin-property-get "git" "$APP" "deploy-branch" "")"
@@ -125,9 +125,11 @@ git_deploy_branch() {
cmd-git-hook() {
declare desc="kick off receive-app trigger from git prereceive hook"
local cmd="git-hook"
local APP="$2"
declare cmd="git-hook"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local DOKKU_DEPLOY_BRANCH
is_valid_app_name "$APP"
DOKKU_DEPLOY_BRANCH="$(git_deploy_branch "$APP")"
@@ -198,7 +200,9 @@ git_receive_app() {
cmd-git-upload-pack() {
declare desc="executes git-upload-pack"
declare cmd="git-upload-pack"
declare APP="$2"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
APP="$(echo "$APP" | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g' | sed 's/^\///g')"
is_valid_app_name "$APP"
! apps_exists "$APP" >/dev/null 2>&1 && apps_maybe_create "$APP"
@@ -210,7 +214,7 @@ cmd-git-upload-pack() {
cmd-git-glob() {
declare desc="catch-all for any other git-* commands"
local cmd="git-*"
declare cmd="git-*"
local APP="$(echo "$2" | perl -pe 's/(?<!\\)'\''//g' | sed 's/\\'\''/'\''/g' | sed 's/^\///g')"
local APP_PATH=$DOKKU_ROOT/$APP
is_valid_app_name "$APP"

View File

@@ -6,9 +6,10 @@ set -eo pipefail
cmd-git-report() {
declare desc="displays a git report for one or more apps"
local cmd="git:report"
declare cmd="git:report"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" INFO_FLAG="$2"
local INSTALLED_APPS=$(dokku_apps)
local APP="$2" INFO_FLAG="$3"
if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then
INFO_FLAG="$APP"

View File

@@ -6,11 +6,11 @@ set -eo pipefail
cmd-git-initialize() {
declare desc="initialize a git repository for an app"
local cmd="git:initialize" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="git:initialize"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
is_valid_app_name "$APP"
is_valid_app_name "$APP"
dokku_log_info1_quiet "Initializing git repository for $APP"
fn-git-create-hook "$APP"
}

View File

@@ -6,10 +6,11 @@ set -eo pipefail
cmd-git-set() {
declare desc="set or clear a git property for an app"
local cmd="git:set" argv=("$@")
[[ ${argv[0]} == "$cmd" ]] && shift 1
declare cmd="git:set"
[[ "$1" == "$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"