From 5dd297bb493b25935b14413af2f803ae9616a4ab Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Mon, 17 Feb 2020 06:21:08 -0500 Subject: [PATCH] refactor: move pre-receive hook modification to post-app-clone-setup trigger --- plugins/apps/subcommands/clone | 1 - plugins/git/post-app-clone-setup | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 plugins/git/post-app-clone-setup diff --git a/plugins/apps/subcommands/clone b/plugins/apps/subcommands/clone index 7ba17a6a9..e4fde7cc7 100755 --- a/plugins/apps/subcommands/clone +++ b/plugins/apps/subcommands/clone @@ -49,7 +49,6 @@ cmd-apps-clone() { fi rm -rf "$NEW_CACHE_DIR" - [[ -f "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" ]] && sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" [[ "$SKIP_REBUILD" == "true" ]] || ps_rebuild "$NEW_APP" plugn trigger post-app-clone "$OLD_APP" "$NEW_APP" dokku_log_info1_quiet "Cloning $OLD_APP to $NEW_APP... done" diff --git a/plugins/git/post-app-clone-setup b/plugins/git/post-app-clone-setup new file mode 100755 index 000000000..68fda4efb --- /dev/null +++ b/plugins/git/post-app-clone-setup @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -eo pipefail +[[ $DOKKU_TRACE ]] && set -x + +trigger-git-post-app-clone-setup() { + declare desc="modifies git-hook" + declare trigger="post-app-clone-setup" + declare OLD_APP="$1" NEW_APP="$2" + + [[ -f "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" ]] && sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" +} + +trigger-git-post-app-clone-setup "$@"