Skip to content

Commit 7976373

Browse files
committedOct 6, 2023
fix: Add chattr +remove support for files
Resolves: #3282
1 parent 784d38b commit 7976373

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
 

‎internal/cmd/chattrcmd.go

+5
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ func (m *modifier) modifyFileAttr(fileAttr chezmoi.FileAttr) chezmoi.FileAttr {
560560
Type: chezmoi.SourceFileTypeSymlink,
561561
Template: m.template.modify(fileAttr.Template),
562562
}
563+
case chezmoi.SourceFileTypeRemove:
564+
return chezmoi.FileAttr{
565+
TargetName: fileAttr.TargetName,
566+
Type: chezmoi.SourceFileTypeRemove,
567+
}
563568
default:
564569
panic(fmt.Sprintf("%d: unknown source file type", fileAttr.Type))
565570
}

‎internal/cmd/testdata/scripts/chattr.txtar

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ exec chezmoi chattr empty $HOME${/}.file
66
! exists $CHEZMOISOURCEDIR/dot_file
77
exists $CHEZMOISOURCEDIR/empty_dot_file
88

9+
# test that chezmoi chattr remove sets the remove attribute on a file
10+
exec chezmoi chattr remove $HOME${/}.file
11+
! exists $CHEZMOISOURCEDIR/empty_dot_file
12+
exists $CHEZMOISOURCEDIR/remove_dot_file
13+
14+
# test that chezmoi chattr noremove removes the remove attribute on a file
15+
exec chezmoi chattr noremove,empty $HOME${/}.file
16+
! exists $CHEZMOISOURCEDIR/remove_dot_file
17+
exists $CHEZMOISOURCEDIR/empty_dot_file
18+
919
# test that chezmoi attr +p sets the private attribute on a file
1020
exec chezmoi chattr +p $HOME${/}.file
1121
! exists $CHEZMOISOURCEDIR/empty_dot_file

0 commit comments

Comments
 (0)
Please sign in to comment.