Merge pull request #8058 from dokku/8035-clone-rename-push-fix

Ensure the pre-receive hook and URLS files are correct when cloning or renaming apps
This commit is contained in:
Jose Diaz-Gonzalez
2025-10-27 01:55:34 -04:00
committed by GitHub
3 changed files with 18 additions and 10 deletions

View File

@@ -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 "$@"

View File

@@ -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 "$@"

View File

@@ -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"