Skip to content

Commit

Permalink
fix: Preserve case in user template data
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Sep 23, 2022
1 parent 9dda54a commit 1fbe862
Show file tree
Hide file tree
Showing 17 changed files with 382 additions and 778 deletions.
25 changes: 13 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,19 @@ linters-settings:
- anon
- empty
- error
- github.com/charmbracelet/bubbletea\.Model
- github.com/charmbracelet/bubbletea\.Msg
- github.com/go-git/go-git/v5/plumbing/format/diff\.File
- github.com/go-git/go-git/v5/plumbing/format/diff\.Patch
- github.com/mitchellh/mapstructure\.DecodeHookFunc
- github.com/twpayne/chezmoi/v2/pkg/chezmoi\.ActualStateEntry
- github.com/twpayne/chezmoi/v2/pkg/chezmoi\.Encryption
- github.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateOrigin
- github.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateEntry
- github.com/twpayne/chezmoi/v2/pkg/chezmoi\.System
- github.com/twpayne/chezmoi/v2/pkg/chezmoi\.TargetStateEntry
- github.com/twpayne/go-vfs/v4\.FS
- github\.com/charmbracelet/bubbletea\.Model
- github\.com/charmbracelet/bubbletea\.Msg
- github\.com/go-git/go-git/v5/plumbing/format/diff\.File
- github\.com/go-git/go-git/v5/plumbing/format/diff\.Patch
- github\.com/mitchellh/mapstructure\.DecodeHookFunc
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.ActualStateEntry
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.Encryption
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.Format
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateOrigin
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.SourceStateEntry
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.System
- github\.com/twpayne/chezmoi/v2/pkg/chezmoi\.TargetStateEntry
- github\.com/twpayne/go-vfs/v4\.FS
- stdlib
misspell:
locale: US
Expand Down
5 changes: 0 additions & 5 deletions assets/chezmoi.io/docs/reference/templates/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,3 @@ NT\CurrentVersion`.
Additional variables can be defined in the config file in the `data` section.
Variable names must consist of a letter and be followed by zero or more letters
and/or digits.

!!! hint

Until [#463](https://github.com/twpayne/chezmoi/issues/463) is resolved, custom
data fields from the `data` section appear as all lowercase strings.
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,6 @@ but must meet the following criteria, in order of importance:
4. Not add significant extra complexity to the user interface or underlying
implementation.

## Why does chezmoi convert all my template variables to lowercase?

This is due to a feature in
[`github.com/spf13/viper`](https://github.com/spf13/viper), the library that
chezmoi uses to read its configuration file. For more information see [this
GitHub issue](https://github.com/twpayne/chezmoi/issues/463).

## Why does `chezmoi cd` spawn a shell instead of just changing directory?

`chezmoi cd` spawns a shell because it is not possible for a program to change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,12 @@ machine to machine. For example, for your home machine:
email = "me@home.org"
```

!!! note

All variable names will be converted to lowercase. This is due to a feature
of a library used by chezmoi. See [this GitHub
issue](https://github.com/twpayne/chezmoi/issues/463) for more information.

If you intend to store private data (e.g. access tokens) in
`~/.config/chezmoi/chezmoi.toml`, make sure it has permissions `0600`.

If you prefer, you can use any format supported by
[Viper](https://github.com/spf13/viper) for your configuration file. This
includes JSON, YAML, and TOML. Variable names must start with a letter and be
followed by zero or more letters or digits.
If you prefer, you can use JSON or YAML for your configuration file. Variable
names must start with a letter and be followed by zero or more letters or
digits.

Then, add `~/.gitconfig` to chezmoi using the `--autotemplate` flag to turn it
into a template and automatically detect variables from the `data` section of
Expand Down
10 changes: 1 addition & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ require (
github.com/rogpeppe/go-internal v1.9.0
github.com/rs/zerolog v1.28.0
github.com/sergi/go-diff v1.1.0
github.com/spf13/afero v1.9.2
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.13.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.0
github.com/twpayne/go-pinentry v0.2.0
github.com/twpayne/go-shell v0.3.1
Expand Down Expand Up @@ -89,14 +88,12 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
Expand All @@ -109,17 +106,13 @@ require (
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.2 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/xanzy/ssh-agent v0.3.2 // indirect
github.com/yuin/goldmark v1.4.15 // indirect
github.com/yuin/goldmark-emoji v1.0.1 // indirect
Expand All @@ -130,7 +123,6 @@ require (
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

exclude github.com/sergi/go-diff v1.2.0 // https://github.com/sergi/go-diff/issues/123
Loading

0 comments on commit 1fbe862

Please sign in to comment.