diff --git a/plugins/git/commands b/plugins/git/commands index ec5a452be..bfe9fff0c 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -6,14 +6,13 @@ git_archive_all() { TMP_WORK_DIR=$(mktemp -d) chmod 755 $TMP_WORK_DIR unset GIT_DIR GIT_WORK_TREE - git clone -q $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null pushd $TMP_WORK_DIR > /dev/null + git clone -q $DOKKU_ROOT/$APP $TMP_WORK_DIR &> /dev/null git config advice.detachedHead false git checkout $REV &> /dev/null git submodule update --init --recursive &> /dev/null find -name .git -prune -exec rm -rf {} \; > /dev/null tar c . - popd > /dev/null rm -rf $TMP_WORK_DIR > /dev/null } @@ -41,6 +40,11 @@ case "$1" in pluginhook git-post-pull $APP ;; + git-rebuild) + APP="$2"; REF=$(< "$DOKKU_ROOT/$APP/refs/heads/master") + git_archive_all $APP $REF | dokku receive $APP | sed -u "s/^/"$'\e[1G'"/" + ;; + git-*) APP="$(echo $2 | perl -pe 's/(? List processes running in app container(s) ps:start Start app container(s) ps:stop Stop app container(s) + ps:rebuild Rebuild an app + ps:rebuildall Rebuild all apps ps:restart Restart app container(s) ps:restartall Restart all deployed app containers EOF diff --git a/tests/unit/ps.bats b/tests/unit/ps.bats index 53efb0b35..915563a61 100644 --- a/tests/unit/ps.bats +++ b/tests/unit/ps.bats @@ -57,3 +57,14 @@ teardown() { echo "status: "$status assert_success } + +@test "ps:rebuild" { + run bash -c "dokku ps:rebuild $TEST_APP" + echo "output: "$output + echo "status: "$status + assert_success + run bash -c "docker ps -q --no-trunc | grep -q $(< $DOKKU_ROOT/$TEST_APP/CONTAINER)" + echo "output: "$output + echo "status: "$status + assert_success +}