fix: ensure the pre-receive hook and URLS files are correct when cloning or renaming apps
Closes #8035
This commit is contained in:
@@ -8,15 +8,15 @@ trigger-git-post-app-clone-setup() {
|
|||||||
declare trigger="post-app-clone-setup"
|
declare trigger="post-app-clone-setup"
|
||||||
declare OLD_APP="$1" NEW_APP="$2"
|
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-clone "git" "$OLD_APP" "$NEW_APP"
|
||||||
|
|
||||||
pushd "$DOKKU_ROOT/$OLD_APP/." >/dev/null
|
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
|
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 "$@"
|
trigger-git-post-app-clone-setup "$@"
|
||||||
|
|||||||
@@ -8,16 +8,16 @@ trigger-git-post-app-rename-setup() {
|
|||||||
declare trigger="post-app-rename-setup"
|
declare trigger="post-app-rename-setup"
|
||||||
declare OLD_APP="$1" NEW_APP="$2"
|
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-clone "git" "$OLD_APP" "$NEW_APP"
|
||||||
fn-plugin-property-destroy "git" "$OLD_APP"
|
fn-plugin-property-destroy "git" "$OLD_APP"
|
||||||
|
|
||||||
pushd "$DOKKU_ROOT/$OLD_APP/." >/dev/null
|
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
|
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 "$@"
|
trigger-git-post-app-rename-setup "$@"
|
||||||
|
|||||||
@@ -152,10 +152,16 @@ teardown() {
|
|||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
assert_output_contains "git-hook $TEST_APP"
|
||||||
run /bin/bash -c "dokku apps:rename $TEST_APP great-test-name"
|
run /bin/bash -c "dokku apps:rename $TEST_APP great-test-name"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
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"
|
run /bin/bash -c "dokku apps:list | grep $TEST_APP"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
|
|||||||
Reference in New Issue
Block a user