Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow executable bits to be overridden in archive-file externals #3102

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading