fix: ensure the pre-receive hook and URLS files are correct when cloning or renaming apps

Closes #8035
This commit is contained in:
Jose Diaz-Gonzalez
2025-10-19 22:12:34 -04:00
parent 959c93b95b
commit efd25cfb45
3 changed files with 16 additions and 10 deletions

View File

@@ -8,15 +8,15 @@ 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
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
}
trigger-git-post-app-clone-setup "$@"

View File

@@ -8,16 +8,16 @@ 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
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
}
trigger-git-post-app-rename-setup "$@"

View File

@@ -152,10 +152,16 @@ teardown() {
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/$TEST_APP/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"