File tree 3 files changed +27
-1
lines changed
assets/chezmoi.io/docs/reference/special-files
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ archives to be included as if they were in the source state.
12
12
externals to be included on different machines.
13
13
14
14
If a ` .chezmoiexternal.$FORMAT ` file is located in an ignored directory (one
15
- listed in [ ` .chezmoiignore ` ] ( chezmoiignore.md ) ), all entries within the file are also ignored.
15
+ listed in [ ` .chezmoiignore ` ] ( chezmoiignore.md ) ), all entries within the file are
16
+ also ignored.
16
17
17
18
Entries are indexed by target name relative to the directory of the
18
19
` .chezmoiexternal.$FORMAT ` file, and must have a ` type ` and a ` url ` field.
@@ -48,6 +49,8 @@ Entries may have the following fields:
48
49
| ` pull.args ` | [ ] string | * none* | Extra args to ` git pull ` |
49
50
| ` archive.extractAppleDouble ` | bool | ` false ` | If ` true ` , AppleDouble files are extracted |
50
51
52
+ ` url ` must be an ` https:// ` , ` http:// ` , or ` file:// ` URL.
53
+
51
54
If any of the optional ` checksum.sha256 ` , ` checksum.sha384 ` , or
52
55
` checksum.sha512 ` fields are set, chezmoi will verify that the downloaded data
53
56
has the given checksum.
Original file line number Diff line number Diff line change @@ -1561,6 +1561,18 @@ func (s *SourceState) getExternalDataRaw(
1561
1561
external * External ,
1562
1562
options * ReadOptions ,
1563
1563
) ([]byte , error ) {
1564
+ // Handle file:// URLs by always reading from disk.
1565
+ switch urlStruct , err := url .Parse (external .URL ); {
1566
+ case err != nil :
1567
+ return nil , err
1568
+ case urlStruct .Scheme == "file" :
1569
+ data , err := s .system .ReadFile (NewAbsPath (urlStruct .Path ))
1570
+ if err != nil {
1571
+ return nil , err
1572
+ }
1573
+ return data , nil
1574
+ }
1575
+
1564
1576
var now time.Time
1565
1577
if options != nil && options .TimeNow != nil {
1566
1578
now = options .TimeNow ()
Original file line number Diff line number Diff line change
1
+ exec chezmoi apply
2
+ cmp $HOME/.file golden/.file
3
+
4
+ -- golden/.file --
5
+ # contents of .file
6
+ -- home/user/.local/share/chezmoi/.chezmoiexternal.toml --
7
+ [".file"]
8
+ type = "file"
9
+ url = "file://{{ .chezmoi.homeDir }}/.local/share/file.txt"
10
+ -- home/user/.local/share/file.txt --
11
+ # contents of .file
You can’t perform that action at this time.
0 commit comments