From 13ef76127de8950487dbc26bb93f5cd09de9ac57 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 25 Nov 2016 01:15:44 -0700 Subject: [PATCH] Suppress output unless the `git submodule update` call fails This will give a bit more warning to developers as to what might be going on, allowing them to respond appropriately. Closes #2479 --- plugins/git/functions | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/git/functions b/plugins/git/functions index 33158d646..dd6ac32a2 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -28,7 +28,7 @@ git_build_app_repo() { git remote add origin "$DOKKU_ROOT/$APP" &> /dev/null git fetch --depth=1 origin "refs/tags/$TMP_TAG" &> /dev/null git reset --hard FETCH_HEAD &> /dev/null - git submodule update --init --recursive &> /dev/null + suppress_output git submodule update --init --recursive GIT_DIR="$DOKKU_ROOT/$APP" git tag -d "$TMP_TAG" &> /dev/null || true find -name .git -prune -exec rm -rf {} \; > /dev/null @@ -41,6 +41,21 @@ git_build_app_repo() { fi } +suppress_output() { + declare desc="suppress all output from a given command unless there is an error" + local TMP_COMMAND_OUTPUT + TMP_COMMAND_OUTPUT=$(mktemp "/tmp/${FUNCNAME[0]}.XXXX") + trap 'rm -rf "$TMP_COMMAND_OUTPUT" > /dev/null' RETURN INT TERM EXIT + + $* 2>&1 > "$TMP_COMMAND_OUTPUT" || { + local exit_code="$?" + cat "$TMP_COMMAND_OUTPUT" + return "$exit_code" + } + return 0 +} + + git_hook_cmd() { declare desc="kick off receive-app trigger from git prereceive hook" local cmd="git-hook"