Skip to content

Commit

Permalink
docs: Add example of extracting selected files from external archive
Browse files Browse the repository at this point in the history
This is an add on to the previous fix for #2056 which adds an example of
how to use `input` filters in `.chezmoiexternal.toml` to the
user guide (`docs/user-guide/include-files-from-elsewhere.md`).

The commit also includes an update to
`docs/reference/special-files-and-directories/chezmoiexternal-format.md`
which uses the new simplified `input` filter syntax and makes a minor
change to the comment about excluded directory trees in
`pkg/chezmoi/sourcestate.go`.
  • Loading branch information
ktetzlaff authored and twpayne committed May 7, 2022
1 parent 1c11ff1 commit a0d699c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Expand Up @@ -116,5 +116,5 @@ re-download unless forced. To force chezmoi to re-download URLs, pass the
url = "https://api.github.com/repos/vrana/adminer/tarball"
refreshPeriod = "744h"
stripComponents = 2
include = ["*", "*/plugins", "*/plugins/**"]
include = ["*/plugins/**"]
```
21 changes: 21 additions & 0 deletions assets/chezmoi.io/docs/user-guide/include-files-from-elsewhere.md
Expand Up @@ -69,6 +69,27 @@ When using Oh My Zsh, make sure you disable auto-updates by setting
`~/.oh-my-zsh` directory to drift out of sync with chezmoi's source state. To
update Oh My Zsh and its plugins, refresh the downloaded archives.

## Include a subdirectory with selected files from a URL

Use `include` pattern filters to include only selected files from an archive
URL.

For example, to import just the required source files of the
[zsh-syntax-highlighting
plugin](https://github.com/zsh-users/zsh-syntax-highlighting) in the example
above, add in `include` filter to the `zsh-syntax-highlighting` section as shown
below:

```toml title="~/.local/share/chezmoi/.chezmoiexternal.toml"
[".oh-my-zsh/custom/plugins/zsh-syntax-highlighting"]
type = "archive"
url = "https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz"
exact = true
stripComponents = 1
refreshPeriod = "168h"
include = ["*/*.zsh", "*/.version", "*/.revision-hash", "*/highlighters/**"]
```

## Include a single file from a URL

Including single files uses the same mechanism as including a subdirectory
Expand Down
2 changes: 1 addition & 1 deletion pkg/chezmoi/sourcestate.go
Expand Up @@ -1889,7 +1889,7 @@ func (s *SourceState) readExternalArchive(
// otherwise it is not possible to differentiate between
// identically-named files at the same level.
if patternSet.match(name) == patternSetMatchExclude {
// In case that `name` is a directory tree which matched an explicit
// In case that `name` is a directory which matched an explicit
// exclude pattern, return fs.SkipDir to exclude not just the
// directory itself but also everything it contains (recursively).
if fileInfo.IsDir() && len(patternSet.excludePatterns) > 0 {
Expand Down

0 comments on commit a0d699c

Please sign in to comment.