From 5000c32efe32c6def2756c882aa4f071250ba4f9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 1 Aug 2019 20:53:24 -0400 Subject: [PATCH 1/2] fix: add test for warning on pushing to wrong branch Closes #3592 --- plugins/git/functions | 6 +++--- tests/unit/10_git.bats | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/git/functions b/plugins/git/functions index 163e0f1bc..4f19b65a4 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -143,12 +143,12 @@ git_hook_cmd() { # shellcheck disable=SC2086 git_receive_app "$APP" "$newrev" else - if [[ $(find "$PLUGIN_PATH"/enabled/*/receive-branch 2>/dev/null | wc -l) != 0 ]]; then + if [[ $(find "$PLUGIN_PATH"/enabled/*/receive-branch 2>/dev/null | wc -l) != 1 ]]; then # shellcheck disable=SC2086 plugn trigger receive-branch $APP $newrev $refname else - echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to master." - echo $'\e[1G\e[K'"-----> for example, try 'git push ${refname/refs\/heads\//}:master'" + echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to ${DOKKU_DEPLOY_BRANCH}." + echo $'\e[1G\e[K'"-----> for example, try 'git push ${refname/refs\/heads\//}:${DOKKU_DEPLOY_BRANCH}'" fi fi done diff --git a/tests/unit/10_git.bats b/tests/unit/10_git.bats index f522410b4..eba3424e0 100644 --- a/tests/unit/10_git.bats +++ b/tests/unit/10_git.bats @@ -28,6 +28,12 @@ teardown() { echo "status: $status" assert_success + run deploy_app + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "deploy did not complete" + run /bin/bash -c "dokku git:set $TEST_APP deploy-branch app-branch" GIT_REMOTE_BRANCH=app-branch deploy_app echo "output: $output" From 5f4f12c27fb4d66168f3702a9bec45f853413e1f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 1 Aug 2019 20:54:18 -0400 Subject: [PATCH 2/2] fix: add `run` as prefix to `deploy_app` --- tests/unit/10_git.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/10_git.bats b/tests/unit/10_git.bats index eba3424e0..9a7449911 100644 --- a/tests/unit/10_git.bats +++ b/tests/unit/10_git.bats @@ -18,7 +18,7 @@ teardown() { echo "status: $status" assert_success - GIT_REMOTE_BRANCH=global-branch deploy_app + GIT_REMOTE_BRANCH=global-branch run deploy_app echo "output: $output" echo "status: $status" assert_success @@ -35,7 +35,7 @@ teardown() { assert_output_contains "deploy did not complete" run /bin/bash -c "dokku git:set $TEST_APP deploy-branch app-branch" - GIT_REMOTE_BRANCH=app-branch deploy_app + GIT_REMOTE_BRANCH=app-branch run deploy_app echo "output: $output" echo "status: $status" assert_success