Skip to content

Commit

Permalink
fix: Respect config file umask setting when creating entries
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Dec 4, 2022
1 parent 725d427 commit feab4e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/chezmoi/sourcestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,13 @@ func WithTemplateOptions(templateOptions []string) SourceStateOption {
}
}

// WithUmask sets the umask.
func WithUmask(umask fs.FileMode) SourceStateOption {
return func(s *SourceState) {
s.umask = umask
}
}

// WithVersion sets the version.
func WithVersion(version semver.Version) SourceStateOption {
return func(s *SourceState) {
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ func (c *Config) newSourceState(
chezmoi.WithSystem(c.sourceSystem),
chezmoi.WithTemplateFuncs(c.templateFuncs),
chezmoi.WithTemplateOptions(c.Template.Options),
chezmoi.WithUmask(c.Umask),
chezmoi.WithVersion(c.version),
}, options...)...)

Expand Down
10 changes: 10 additions & 0 deletions pkg/cmd/testdata/scripts/issue2609.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[windows] skip 'UNIX only'

# test that chezmoi apply uses the umask from the configuration file
exec chezmoi apply
cmpmod 600 $HOME/.file

-- home/user/.config/chezmoi/chezmoi.yaml --
umask: 0o077
-- home/user/.local/share/chezmoi/dot_file --
# contents of .file

0 comments on commit feab4e7

Please sign in to comment.