From a166afed8afa2ea6f30c446aec7f4b4d07d3cff1 Mon Sep 17 00:00:00 2001 From: fiftydinar <65243233+fiftydinar@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:41:13 +0100 Subject: [PATCH] fix(chezmoi): Properly use default branch `yq` outputs "null" string when no results are found, so it's not an empty string. Branch "null" is passed as custom branch, which very likely doesn't exist in user's chezmoi repo. So to solve this issue, set "if string is empty or contains string "null", disable custom branch, otherwise enable" --- modules/chezmoi/chezmoi.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/chezmoi/chezmoi.sh b/modules/chezmoi/chezmoi.sh index a6f8522..9840160 100644 --- a/modules/chezmoi/chezmoi.sh +++ b/modules/chezmoi/chezmoi.sh @@ -19,10 +19,10 @@ fi DOTFILE_REPOSITORY=$(echo "$1" | yq -I=0 ".repository") # (string) # The chezmoi repository branch to use. DOTFILE_BRANCH=$(echo "$1" | yq -I=0 ".branch") -if [[ -n ${DOTFILE_BRANCH} ]]; then - INIT_BRANCH_FLAG="--branch ${DOTFILE_BRANCH}" +if ! [[ -z "${DOTFILE_BRANCH}" ]] || [[ "${DOTFILE_BRANCH}" == "null" ]]; then + INIT_BRANCH_FLAG="--branch ${DOTFILE_BRANCH}" else - INIT_BRANCH_FLAG="" + INIT_BRANCH_FLAG="" fi # If true, chezmoi services will be enabled for all logged in users, and users with lingering enabled. (default: true)