Skip to content

Commit

Permalink
feat: Allow executable bits to be overridden in archive-file externals
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Jul 18, 2023
1 parent a642b70 commit 48b25f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ If `type` is `archive-file` then the target is a file or symlink with the
contents of the entry `path` in the archive at `url`. The optional integer field
`stripComponents` will remove leading path components from the members of the
archive before comparing them with `path`. The behavior of `format` is the same
as for `archive`.
as for `archive`. If `executable` is `true` then chezmoi will set the executable
bits on the target file, even if they are not set in the archive.

If `type` is `git-repo` then chezmoi will run `git clone $URL $TARGET_NAME`
with the optional `clone.args` if the target does not exist. If the target
Expand Down
2 changes: 1 addition & 1 deletion pkg/chezmoi/sourcestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,7 @@ func (s *SourceState) readExternalArchiveFile(
TargetName: fileInfo.Name(),
Type: SourceFileTypeFile,
Empty: fileInfo.Size() == 0,
Executable: isExecutable(fileInfo),
Executable: isExecutable(fileInfo) || external.Executable,
Private: isPrivate(fileInfo),
ReadOnly: isReadOnly(fileInfo),
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/cmd/testdata/scripts/external.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ chhome home12/user
exec chezmoi apply
cmp $HOME/.file golden/dir/file

chhome home13/user

# test that chezmoi can set executable bits on archive-file externals
exec chezmoi apply
[umask:002] cmpmod 775 $HOME/.file
[umask:022] cmpmod 755 $HOME/.file

-- archive/dir/file --
# contents of dir/file
-- golden/.file --
Expand Down Expand Up @@ -142,6 +149,13 @@ cmp $HOME/.file golden/dir/file
url = "{{ env "HTTPD_URL" }}/archive.tar.gz"
path = "dir/file"
stripComponents = 1
-- home13/user/.local/share/chezmoi/.chezmoiexternal.toml --
[".file"]
type = "archive-file"
url = "{{ env "HTTPD_URL" }}/archive.tar.gz"
path = "dir/file"
executable = true
stripComponents = 1
-- home2/user/.local/share/chezmoi/.chezmoiexternal.toml --
[".file"]
type = "file"
Expand Down

0 comments on commit 48b25f7

Please sign in to comment.