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"
This commit is contained in:
fiftydinar 2024-11-19 16:41:13 +01:00 committed by GitHub
parent f176a3516e
commit a166afed8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)