From 12efcd02b1997e8d0342509adfc6d2e5f979c412 Mon Sep 17 00:00:00 2001 From: kjwon15 Date: Thu, 22 Feb 2018 10:42:31 +0900 Subject: [PATCH 1/3] Prune worktree after build --- plugins/git/functions | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/git/functions b/plugins/git/functions index c98efab1b..a73926839 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -41,6 +41,7 @@ git_build_app_repo() { # unset the git quarantine path to allow us to use 2.13.0+ # See this issue for more information: https://github.com/dokku/dokku/issues/2796 env -u GIT_QUARANTINE_PATH git worktree add "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" "$REV" > /dev/null + trap 'git worktree prune > /dev/null' RETURN INT TERM EXIT popd > /dev/null pushd "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" > /dev/null else From 1025c7679fdff0e2ae9fe47bf8ef653f32671bdf Mon Sep 17 00:00:00 2001 From: kjwon15 Date: Thu, 22 Feb 2018 11:11:31 +0900 Subject: [PATCH 2/3] Fix trap Last trap will exec. --- plugins/git/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/functions b/plugins/git/functions index a73926839..35dcf7974 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -41,7 +41,7 @@ git_build_app_repo() { # unset the git quarantine path to allow us to use 2.13.0+ # See this issue for more information: https://github.com/dokku/dokku/issues/2796 env -u GIT_QUARANTINE_PATH git worktree add "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" "$REV" > /dev/null - trap 'git worktree prune > /dev/null' RETURN INT TERM EXIT + trap 'rm -rf "$GIT_BUILD_APP_REPO_TMP_WORK_DIR"; git worktree prune > /dev/null' RETURN INT TERM EXIT popd > /dev/null pushd "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" > /dev/null else From af19e5e453242402175364a52db8a1cde1189d04 Mon Sep 17 00:00:00 2001 From: kjwon15 Date: Sun, 4 Mar 2018 03:46:39 +0900 Subject: [PATCH 3/3] Prune git worktree immediately --- plugins/git/functions | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/git/functions b/plugins/git/functions index 35dcf7974..152360eac 100755 --- a/plugins/git/functions +++ b/plugins/git/functions @@ -41,7 +41,6 @@ git_build_app_repo() { # unset the git quarantine path to allow us to use 2.13.0+ # See this issue for more information: https://github.com/dokku/dokku/issues/2796 env -u GIT_QUARANTINE_PATH git worktree add "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" "$REV" > /dev/null - trap 'rm -rf "$GIT_BUILD_APP_REPO_TMP_WORK_DIR"; git worktree prune > /dev/null' RETURN INT TERM EXIT popd > /dev/null pushd "$GIT_BUILD_APP_REPO_TMP_WORK_DIR" > /dev/null else @@ -65,6 +64,12 @@ git_build_app_repo() { suppress_output git submodule update --init --recursive find . -name .git -prune -exec rm -rf {} \; > /dev/null + if use_git_worktree; then + pushd "$DOKKU_ROOT/$APP" + git worktree prune + popd + fi + local DOKKU_APP_DISABLE_ANSI_PREFIX_REMOVAL DOKKU_GLOBAL_DISABLE_ANSI_PREFIX_REMOVAL DOKKU_DISABLE_ANSI_PREFIX_REMOVAL DOKKU_APP_DISABLE_ANSI_PREFIX_REMOVAL=$(config_get "$APP" DOKKU_DISABLE_ANSI_PREFIX_REMOVAL || true) DOKKU_GLOBAL_DISABLE_ANSI_PREFIX_REMOVAL=$(config_get --global DOKKU_DISABLE_ANSI_PREFIX_REMOVAL || true)