From 6317a37c98aed55e1e5e0eac32af9aa820d0896f Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Wed, 7 Feb 2024 10:59:06 +0000 Subject: [PATCH] Update branch deploy script --- tools/branch-deploy.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/branch-deploy.sh b/tools/branch-deploy.sh index ba04946..df1cdfb 100755 --- a/tools/branch-deploy.sh +++ b/tools/branch-deploy.sh @@ -1,18 +1,23 @@ #!/bin/bash # Deploys all branches of a Hugo repository to a structure of folders. # Useful for deploying all PRs/branches of a Hugo installation to a test URL for viewing. +set -u # Args: folder -TARGET_FOLDER="$1" +TARGET_FOLDER=$(realpath $1) +URL_BASE="$2" +INDEX_PAGE="${TARGET_FOLDER}/index.html" mkdir -p "${TARGET_FOLDER}" # Track all remote branches locally -git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done +git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote" 2>/dev/null; done # Pull the branches -git pull --all -git fetch --all +git pull --all > /dev/null +git fetch --all > /dev/null + +echo -e "

Branches

\n" >> "${INDEX_PAGE}" \ No newline at end of file