twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.

Home Page:https://www.chezmoi.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.chezmoiignore thinks closing braces are a pattern

blindelectron opened this issue · comments

Describe the bug

When trying to ignore files while the current operating system is windows. Chezmoi throws an invalid pattern error at the end of the if statement.

To reproduce

Add .chezmoiignore to the source state with the following contents:

{{ if ne .chezmoi.os "windows" }}
AppData/
AppData/**
portable/keyop/
portable/keyop/**)
.config/scoop/
.config/scoop/**
Documents/
Documents/**
{{ end }}}}

Expected behavior

Chezmoi will ignore the listed files and folders if the os is not windows.

Output of command with the --verbose flag

$ chezmoi --verbose re-add
chezmoi: C:/Users/ethan/.local/share/chezmoi/.chezmoiignore.tmpl:1: }}: invalid pattern                                                                                                     

Output of chezmoi doctor

$ chezmoi doctor
RESULT    CHECK                       MESSAGE                                                                                                                                               
ok        version                     v2.48.1, commit 4ad03d7a6ff4d4aafeb65efbfa47c1529238c302, built at 2024-05-12T19:30:56Z, built by goreleaser                                          
ok        latest-version              v2.48.1                                                                                                                                               
ok        os-arch                     windows/amd64                                                                                                                                         
ok        systeminfo                  Microsoft Windows 11 Pro (10.0.22621 N/A Build 22621)                                                                                                 
ok        go-version                  go1.22.3 (gc)                                                                                                                                         
ok        executable                  ~/scoop/apps/chezmoi/current/chezmoi.exe                                                                                                              
ok        upgrade-method              replace-executable                                                                                                                                    
ok        config-file                 ~/.config/chezmoi/chezmoi.toml, last modified 2024-05-24T22:04:55-05:00                                                                               
warning   source-dir                  ~/.local/share/chezmoi is a git working tree (dirty)                                                                                                  
ok        suspicious-entries          no suspicious entries                                                                                                                                 
warning   working-tree                ~/.local/share/chezmoi is a git working tree (dirty)                                                                                                  
ok        dest-dir                    ~ is a directory                                                                                                                                      
ok        cd-command                  found C:/windows/system32/cmd.exe                                                                                                                     
ok        cd-args                     'C:\\windows\\system32\\cmd.exe'                                                                                                                      
info      diff-command                not set                                                                                                                                               
ok        edit-command                found C:/windows/system32/notepad.exe                                                                                                                 
ok        edit-args                   'C:\\windows\\system32\\notepad.exe'                                                                                                                  
ok        git-command                 found ~/scoop/shims/git.exe, version 2.43.0                                                                                                           
ok        merge-command               found ~/scoop/shims/vimdiff.exe                                                                                                                       
ok        shell-command               found C:/windows/system32/cmd.exe                                                                                                                     
ok        shell-args                  'C:\\windows\\system32\\cmd.exe'                                                                                                                      
ok        age-command                 found ~/scoop/shims/age.exe, version 1.1.1                                                                                                            
info      gpg-command                 gpg not found in $PATH                                                                                                                                
info      pinentry-command            not set                                                                                                                                               
info      1password-command           op not found in $PATH                                                                                                                                 
ok        bitwarden-command           found C:/ProgramData/chocolatey/bin/bw.exe, version 2024.4.1                                                                                          
info      bitwarden-secrets-command   bws not found in $PATH                                                                                                                                
info      dashlane-command            dcli not found in $PATH                                                                                                                               
info      doppler-command             doppler not found in $PATH                                                                                                                            
info      gopass-command              gopass not found in $PATH                                                                                                                             
info      keepassxc-command           keepassxc-cli not found in $PATH                                                                                                                      
info      keepassxc-db                not set                                                                                                                                               
info      keeper-command              keeper not found in $PATH                                                                                                                             
info      lastpass-command            lpass not found in $PATH                                                                                                                              
info      pass-command                pass not found in $PATH                                                                                                                               
info      passhole-command            ph not found in $PATH                                                                                                                                 
info      rbw-command                 rbw not found in $PATH                                                                                                                                
info      vault-command               vault not found in $PATH                                                                                                                              
info      vlt-command                 vlt not found in $PATH                                                                                                                                
info      secret-command              not set

chezmoi is correct here. Lines in .chezmoiignore files are filepath globs as understood by bmatcuk/doublestar and }} is not a valid pattern.

Note the extra }} at the end of the {{ end }} template statement on the last line.

my god, I am such an idiot, didn't even notice those, oops I guess thats what I get for not putting my screen reader into the coding profile.

No worries, glad that the problem is solved :)