diff --git a/plugins/git/post-app-clone-setup b/plugins/git/post-app-clone-setup index 04d9c5855..8d9939d5c 100755 --- a/plugins/git/post-app-clone-setup +++ b/plugins/git/post-app-clone-setup @@ -1,5 +1,6 @@ #!/usr/bin/env bash source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" +source "$PLUGIN_AVAILABLE_PATH/git/internal-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x @@ -8,15 +9,13 @@ trigger-git-post-app-clone-setup() { declare trigger="post-app-clone-setup" declare OLD_APP="$1" NEW_APP="$2" - if [[ -f "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" ]]; then - sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" - fi - fn-plugin-property-clone "git" "$OLD_APP" "$NEW_APP" pushd "$DOKKU_ROOT/$OLD_APP/." >/dev/null - find ./* \( -name ".cache" -o -name "cache" -o -name "VHOST" \) -prune -o -print | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP" + find ./* \( -name ".cache" -o -name "cache" -o -name "VHOST" -o -name "URLS" \) -prune -o -print | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP" popd &>/dev/null || pushd "/tmp" >/dev/null + + fn-git-create-hook "$NEW_APP" } trigger-git-post-app-clone-setup "$@" diff --git a/plugins/git/post-app-rename-setup b/plugins/git/post-app-rename-setup index 0482d58e2..1398cabd1 100755 --- a/plugins/git/post-app-rename-setup +++ b/plugins/git/post-app-rename-setup @@ -1,5 +1,6 @@ #!/usr/bin/env bash source "$PLUGIN_CORE_AVAILABLE_PATH/common/property-functions" +source "$PLUGIN_AVAILABLE_PATH/git/internal-functions" set -eo pipefail [[ $DOKKU_TRACE ]] && set -x @@ -8,16 +9,14 @@ trigger-git-post-app-rename-setup() { declare trigger="post-app-rename-setup" declare OLD_APP="$1" NEW_APP="$2" - if [[ -f "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" ]]; then - sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" - fi - fn-plugin-property-clone "git" "$OLD_APP" "$NEW_APP" fn-plugin-property-destroy "git" "$OLD_APP" pushd "$DOKKU_ROOT/$OLD_APP/." >/dev/null - find ./* \( -name ".cache" -o -name "cache" -o -name "VHOST" \) -prune -o -print | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP" + find ./* \( -name ".cache" -o -name "cache" -o -name "VHOST" -o -name "URLS" \) -prune -o -print | cpio -pdmu --quiet "$DOKKU_ROOT/$NEW_APP" popd &>/dev/null || pushd "/tmp" >/dev/null + + fn-git-create-hook "$NEW_APP" } trigger-git-post-app-rename-setup "$@" diff --git a/tests/unit/apps_1.bats b/tests/unit/apps_1.bats index 5b85ffacd..9d6d3f425 100644 --- a/tests/unit/apps_1.bats +++ b/tests/unit/apps_1.bats @@ -152,10 +152,20 @@ teardown() { echo "output: $output" echo "status: $status" assert_success + run /bin/bash -c "cat $DOKKU_ROOT/$TEST_APP/hooks/pre-receive" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "git-hook $TEST_APP" run /bin/bash -c "dokku apps:rename $TEST_APP great-test-name" echo "output: $output" echo "status: $status" assert_success + run /bin/bash -c "cat $DOKKU_ROOT/great-test-name/hooks/pre-receive" + echo "output: $output" + echo "status: $status" + assert_success + assert_output_contains "git-hook great-test-name" run /bin/bash -c "dokku apps:list | grep $TEST_APP" echo "output: $output" echo "status: $status"