Skip to content

Commit

Permalink
chore: Tidy up entry type set logic
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Oct 15, 2022
1 parent 801a79b commit 504ca18
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions assets/chezmoi.io/docs/reference/command-line-flags/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Set the output format.

Only operate on target state entries of type *types*. *types* is a
comma-separated list of target states (`all`, `dirs`, `files`, `remove`,
`scripts`, `symlinks`, and `encrypted`) and can be excluded by preceding them
with a `no`.
`scripts`, `symlinks`) and/or source attributes (`encrypted`, `externals`) and
can be excluded by preceding them with a `no`.

!!! example

Expand Down
7 changes: 3 additions & 4 deletions pkg/chezmoi/entrytypeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,10 @@ func (s *EntryTypeSet) IncludeFileInfo(fileInfo fs.FileInfo) bool {

// IncludeTargetStateEntry returns true if type of targetStateEntry is a member.
func (s *EntryTypeSet) IncludeTargetStateEntry(targetStateEntry TargetStateEntry) bool {
if s.IncludeEncrypted() && targetStateEntry.SourceAttr().Encrypted {
switch sourceAttr := targetStateEntry.SourceAttr(); {
case s.IncludeEncrypted() && sourceAttr.Encrypted:
return true
}

if s.IncludeExternals() && targetStateEntry.SourceAttr().External {
case s.IncludeExternals() && sourceAttr.External:
return true
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@ func newConfig(options ...configOption) (*Config, error) {
},
managed: managedCmdConfig{
exclude: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesNone),
include: chezmoi.NewEntryTypeSet(
chezmoi.EntryTypeDirs | chezmoi.EntryTypeFiles | chezmoi.EntryTypeSymlinks | chezmoi.EntryTypeEncrypted,
),
include: chezmoi.NewEntryTypeSet(chezmoi.EntryTypesAll &^ (chezmoi.EntryTypeRemove | chezmoi.EntryTypeScripts)),
},
mergeAll: mergeAllCmdConfig{
recursive: true,
Expand Down

0 comments on commit 504ca18

Please sign in to comment.