refactor: combine both clone and sync commands
Using a single command will allow users to not have to worry about the workflow they use to setup or update a given app.
This commit is contained in:
@@ -28,8 +28,7 @@ fn-help-content() {
|
||||
declare desc="return help content"
|
||||
cat <<help_content
|
||||
git:allow-host <host>, Adds a host to known_hosts
|
||||
git:clone [--build] <app> <repository> [<git-ref>], Creates an app from remote git repo
|
||||
git:fetch [--build] <app> <repository> [<git-ref>], Fetch the app at an optional repo object and build the codebase
|
||||
git:sync [--build] <app> <repository> [<git-ref>], Clone or fetch an app from remote git repo
|
||||
git:initialize <app>, Initialize a git repository for an app
|
||||
git:public-key, Outputs the dokku public deploy key
|
||||
git:report [<app>] [<flag>], Displays a git report for one or more apps
|
||||
|
||||
@@ -15,9 +15,9 @@ cmd-git-allow-host() {
|
||||
dokku_log_info1 "$HOST added to known hosts"
|
||||
}
|
||||
|
||||
cmd-git-clone() {
|
||||
declare desc="creates an app from remote git repo"
|
||||
local cmd="git:clone"
|
||||
cmd-git-sync() {
|
||||
declare desc="clone or fetch an app from remote git repo"
|
||||
local cmd="git:sync"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP GIT_REMOTE GIT_REF FLAG
|
||||
|
||||
@@ -42,44 +42,13 @@ cmd-git-clone() {
|
||||
return
|
||||
fi
|
||||
|
||||
fn-git-clone "$APP" "$GIT_REMOTE" "$GIT_REF"
|
||||
if [[ "$FLAG" == "--build" ]]; then
|
||||
if [[ -n "$GIT_REF" ]]; then
|
||||
plugn trigger receive-app "$APP" "$GIT_REF"
|
||||
else
|
||||
plugn trigger receive-app "$APP"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
cmd-git-fetch() {
|
||||
declare desc="fetch the app at an optional repo object and build the codebase"
|
||||
local cmd="git:fetch"
|
||||
[[ "$1" == "$cmd" ]] && shift 1
|
||||
declare APP GIT_REMOTE GIT_REF FLAG
|
||||
|
||||
ARGS=()
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "--build" ]]; then
|
||||
FLAG="--build"
|
||||
continue
|
||||
fi
|
||||
|
||||
ARGS+=("$arg")
|
||||
done
|
||||
|
||||
APP="${ARGS[0]}"
|
||||
GIT_REMOTE="${ARGS[1]}"
|
||||
GIT_REF="${ARGS[2]}"
|
||||
|
||||
verify_app_name "$APP"
|
||||
|
||||
if [[ -z "$GIT_REMOTE" ]]; then
|
||||
dokku_log_fail "Missing GIT_REMOTE parameter"
|
||||
return
|
||||
local APP_ROOT="$DOKKU_ROOT/$APP"
|
||||
if [[ "$(git -C "$APP_ROOT" count-objects)" == "0 objects, 0 kilobytes" ]]; then
|
||||
fn-git-clone "$APP" "$GIT_REMOTE" "$GIT_REF"
|
||||
else
|
||||
fn-git-fetch "$APP" "$GIT_REMOTE" "$GIT_REF"
|
||||
fi
|
||||
|
||||
fn-git-fetch "$APP" "$GIT_REMOTE" "$GIT_REF"
|
||||
if [[ "$FLAG" == "--build" ]]; then
|
||||
if [[ -n "$GIT_REF" ]]; then
|
||||
plugn trigger receive-app "$APP" "$GIT_REF"
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-fetch "$@"
|
||||
@@ -3,4 +3,4 @@ source "$PLUGIN_AVAILABLE_PATH/git/internal-functions"
|
||||
set -eo pipefail
|
||||
[[ $DOKKU_TRACE ]] && set -x
|
||||
|
||||
cmd-git-clone "$@"
|
||||
cmd-git-sync "$@"
|
||||
Reference in New Issue
Block a user