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
71 lines
1.5 KiB
Cheetah
71 lines
1.5 KiB
Cheetah
{{- $hostname := output "hostname" | trim -}}
|
|
{{- $username := .chezmoi.username -}}
|
|
{{- $currentHost := index .hosts $hostname -}}
|
|
{{- $currentUser := "" -}}
|
|
{{- if $currentHost -}}
|
|
{{- if hasKey $currentHost.users $username -}}
|
|
{{- $currentUser = index $currentHost.users $username -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $gitConfig := dict -}}
|
|
{{- if and $currentUser (hasKey $currentUser "configs") -}}
|
|
{{- if hasKey $currentUser.configs "git" -}}
|
|
{{- $gitConfig = $currentUser.configs.git -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- $gitName := "Xavier Logerais" -}}
|
|
{{- $gitEmail := "xavier@logerais.com" -}}
|
|
{{- if hasKey $gitConfig "name" -}}
|
|
{{- $gitName = $gitConfig.name -}}
|
|
{{- end -}}
|
|
{{- if hasKey $gitConfig "email" -}}
|
|
{{- $gitEmail = $gitConfig.email -}}
|
|
{{- end -}}
|
|
[core]
|
|
excludesfile = ~/.config/git/ignore
|
|
attributesfile = ~/.config/git/attributes
|
|
pager = delta
|
|
|
|
[user]
|
|
name = {{ $gitName }}
|
|
email = {{ $gitEmail }}
|
|
|
|
[credential]
|
|
helper = cache
|
|
|
|
[credential "https://gitea.logerais.com"]
|
|
helper = cache
|
|
helper = !tea login helper
|
|
|
|
[credential "https://gitea.cloud.logerais.com"]
|
|
helper = cache
|
|
helper = !tea login helper
|
|
|
|
[init]
|
|
defaultBranch = main
|
|
|
|
[rerere]
|
|
enabled = 1
|
|
|
|
[merge]
|
|
conflictstyle = diff3
|
|
|
|
[page]
|
|
diff = delta
|
|
show = delta
|
|
log = delta
|
|
blame = delta
|
|
reflog = delta
|
|
|
|
[delta]
|
|
navigate = true
|
|
side-by-side = true
|
|
dark = true
|
|
syntax-theme = Coldark-Dark
|
|
|
|
[interactive]
|
|
diffFilter = delta --color-only
|
|
|
|
[alias]
|
|
tree = !git ls-files | tree --fromfile -C
|