fix(git): Guard $gitConfig.name/email lookup against missing map keys
Accessing a missing key on a map value in text/template raises an error before `default` can run, so `configs.git` without `name`/`email` (or hosts without a `configs` key, e.g. termux-*) broke `chezmoi diff` with "map has no entry for key". Use `hasKey` before accessing each field instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0145M6KGu5gQ3brTPzqs8NwG
This commit is contained in:
@@ -13,8 +13,14 @@
|
|||||||
{{- $gitConfig = $currentUser.configs.git -}}
|
{{- $gitConfig = $currentUser.configs.git -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- $gitName := $gitConfig.name | default "Xavier Logerais" -}}
|
{{- $gitName := "Xavier Logerais" -}}
|
||||||
{{- $gitEmail := $gitConfig.email | default "xavier@logerais.com" -}}
|
{{- $gitEmail := "xavier@logerais.com" -}}
|
||||||
|
{{- if hasKey $gitConfig "name" -}}
|
||||||
|
{{- $gitName = $gitConfig.name -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if hasKey $gitConfig "email" -}}
|
||||||
|
{{- $gitEmail = $gitConfig.email -}}
|
||||||
|
{{- end -}}
|
||||||
[core]
|
[core]
|
||||||
excludesfile = ~/.config/git/ignore
|
excludesfile = ~/.config/git/ignore
|
||||||
attributesfile = ~/.config/git/attributes
|
attributesfile = ~/.config/git/attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user