Skip to content

Commit 204fd86

Browse files
committed
Do not allow Mode or Permissions to be nil
1 parent c161fd1 commit 204fd86

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

installer/prepare.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ type PreparedDotfile struct {
3939
// Mode represents the change in the file mode bits of the source and
4040
// target os.FileMode (does not include permissions). This will not be set
4141
// if the sources are irregular.
42-
Mode *FileMode
42+
Mode FileMode
4343

4444
// Permissions represents the change in permission between the compiled source
4545
// and the currently installed dotfile. Equal permissions can be verified
4646
// by calling Permissions.IsSame.
47-
Permissions *FileMode
47+
Permissions FileMode
4848

4949
// SourcePermissionsDiffer indicates that a compiled dotfile (one with
5050
// multiple sources) does not have consistent permissions across all
@@ -67,7 +67,7 @@ type PreparedDotfile struct {
6767
// IsChanged reports if the prepared dotfile has changes from the target
6868
// dotfile.
6969
func (p *PreparedDotfile) IsChanged() bool {
70-
return p.IsNew || p.ContentsDiffer || p.Permissions.IsChanged() || p.Mode.IsChanged()
70+
return p.IsNew || p.Added || p.Removed || p.ContentsDiffer || p.Permissions.IsChanged() || p.Mode.IsChanged()
7171
}
7272

7373
// FileMode represents the new and old dotfile file mode.
@@ -161,7 +161,7 @@ func PrepareDotfiles(dotfiles resolver.Dotfiles, config config.SourceConfig) Pre
161161
targetMode = targetInfo.Mode()
162162
}
163163

164-
prepared.Permissions = &FileMode{
164+
prepared.Permissions = FileMode{
165165
Old: targetMode & os.ModePerm,
166166
New: sourcePermissions,
167167
}
@@ -170,7 +170,7 @@ func PrepareDotfiles(dotfiles resolver.Dotfiles, config config.SourceConfig) Pre
170170
prepared.SourcesAreIrregular = !isAllRegular(sourceInfo)
171171

172172
if len(sourceInfo) > 0 && !prepared.SourcesAreIrregular {
173-
prepared.Mode = &FileMode{
173+
prepared.Mode = FileMode{
174174
Old: targetMode &^ os.ModePerm,
175175
New: sourceInfo[0].Mode() &^ os.ModePerm,
176176
}

0 commit comments

Comments
 (0)