Skip to content

Commit

Permalink
fix(chezmoi): Properly use default branch
Browse files Browse the repository at this point in the history
`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"
  • Loading branch information
fiftydinar authored Nov 19, 2024
1 parent f176a35 commit a166afe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/chezmoi/chezmoi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

2 comments on commit a166afe

@yacoob
Copy link
Contributor

@yacoob yacoob commented on a166afe Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and I've just discovered this in my fresh custom install 😅 Thanks for the fix!

@yacoob
Copy link
Contributor

@yacoob yacoob commented on a166afe Nov 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

welp, it's still not fixed :D A PR incoming.

Please sign in to comment.