Skip to content

Commit

Permalink
feat: Remove deprecated --autotemplate flag
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Apr 21, 2023
1 parent ebc536f commit ed0c798
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 394 deletions.
16 changes: 0 additions & 16 deletions assets/chezmoi.io/docs/reference/commands/add.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@ Add *target*s to the source state. If any target is already in the source
state, then its source state is replaced with its current state in the
destination directory.

## `--autotemplate` (deprecated)

Automatically generate a template by replacing strings that match variable
values from the `data` section of the config file with their respective config
names as a template string. Longer substitutions occur before shorter ones.
This implies the `--template` option.

!!! warning

`--autotemplate` uses a greedy algorithm which occasionally generates
templates with unwanted variable substitutions. Carefully review any
templates it generates.

`--autotemplate` has been deprecated and will be removed in a future
release of chezmoi.

## `--encrypt`

Encrypt files using the defined encryption method.
Expand Down
119 changes: 0 additions & 119 deletions pkg/chezmoi/autotemplate.go

This file was deleted.

190 changes: 0 additions & 190 deletions pkg/chezmoi/autotemplate_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/chezmoi/sourcestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ type ReplaceFunc func(targetRelPath RelPath, newSourceStateEntry, oldSourceState

// AddOptions are options to SourceState.Add.
type AddOptions struct {
AutoTemplate bool // Automatically create templates, if possible.
Create bool // Add create_ entries instead of normal entries.
Encrypt bool // Encrypt files.
EncryptedSuffix string // Suffix for encrypted files.
Expand Down Expand Up @@ -1876,13 +1875,6 @@ func (s *SourceState) newSourceStateFileEntryFromFile(
if err != nil {
return nil, err
}
if options.AutoTemplate {
var replacements bool
contents, replacements = autoTemplate(contents, s.TemplateData())
if replacements {
fileAttr.Template = true
}
}
if len(contents) == 0 {
fileAttr.Empty = true
}
Expand Down Expand Up @@ -1920,8 +1912,6 @@ func (s *SourceState) newSourceStateFileEntryFromSymlink(
contents := []byte(linkname)
template := false
switch {
case options.AutoTemplate:
contents, template = autoTemplate(contents, s.TemplateData())
case options.Template:
template = true
case !options.Template && options.TemplateSymlinks:
Expand Down
17 changes: 0 additions & 17 deletions pkg/chezmoi/sourcestate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,23 +428,6 @@ func TestSourceStateAdd(t *testing.T) {
),
},
},
{
name: "template",
destAbsPaths: []AbsPath{
NewAbsPath("/home/user/.template"),
},
addOptions: AddOptions{
AutoTemplate: true,
Filter: NewEntryTypeFilter(EntryTypesAll, EntryTypesNone),
},
tests: []any{
vfst.TestPath("/home/user/.local/share/chezmoi/dot_template.tmpl",
vfst.TestModeIsRegular,
vfst.TestModePerm(0o666&^chezmoitest.Umask),
vfst.TestContentsString("key = {{ .variable }}\n"),
),
},
},
{
name: "dir_and_dir_file",
destAbsPaths: []AbsPath{
Expand Down
Loading

0 comments on commit ed0c798

Please sign in to comment.