Skip to content

Commit

Permalink
fix: Allow modify_ scripts to be encrypted
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Sep 29, 2021
1 parent c9e83b0 commit b7fb215
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/chezmoi/attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ func parseFileAttr(sourceName, encryptedSuffix string) FileAttr {
case strings.HasPrefix(name, modifyPrefix):
sourceFileType = SourceFileTypeModify
name = mustTrimPrefix(name, modifyPrefix)
if strings.HasPrefix(name, encryptedPrefix) {
name = mustTrimPrefix(name, encryptedPrefix)
encrypted = true
}
if strings.HasPrefix(name, privatePrefix) {
name = mustTrimPrefix(name, privatePrefix)
private = true
Expand Down
22 changes: 22 additions & 0 deletions internal/cmd/testdata/scripts/modifyencrypted.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[windows] skip 'UNIX only'
[!exec:age] skip 'age not found in $PATH'

mkageconfig

# test that chezmoi applies encrypted modify scripts
mkdir $CHEZMOISOURCEDIR
chezmoi encrypt --output=$CHEZMOISOURCEDIR${/}modify_encrypted_dot_modify.age golden/modify.sh
grep '-----BEGIN AGE ENCRYPTED FILE-----' $CHEZMOISOURCEDIR/modify_encrypted_dot_modify.age
chezmoi apply --force
cmp $HOME/.modify golden/.modify-modified

-- golden/.modify-modified --
# contents of .modify
# modified
-- golden/modify.sh --
#!/bin/sh

cat
echo "# modified"
-- home/user/.modify --
# contents of .modify

0 comments on commit b7fb215

Please sign in to comment.