-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preprocessor: require absolute paths for upload files
When a file is uploaded, it is currently uploaded relative to the current working directory of a multi-step script. For example, if a script step changes directory, subsequent uploads (with relative paths) are processed relative to that new working directory. This is incredibly confusing and wrong, because it is entirely counter to the expectation of the script writer who is most likely expecting txtar-like semantics. Switch to those semantics, that the txtar-specified file is relative to the starting working directory ($HOME) unless specified as absolute. This requires a fix in content/docs/tutorial/validating-simple-yaml-files/en.md which was relying on the broken previous behaviour. Preprocessor-No-Write-Cache: true Signed-off-by: Paul Jolly <[email protected]> Change-Id: I83d07aec141e52acc08b5ed54671d7a3cf97adbd Dispatch-Trailer: {"type":"trybot","CL":1176743,"patchset":8,"ref":"refs/changes/43/1176743/8","targetBranch":"alpha"}
- Loading branch information
Showing
5 changed files
with
124 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
internal/cmd/preprocessor/cmd/testdata/execute_check_upload_structure.txtar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Ensure that we create uploaded files in the right place, | ||
# regardless of working directory at the time of the upload. | ||
|
||
unquote content/dir/en.md | ||
|
||
exec preprocessor execute | ||
|
||
cmp hugo/content/en/dir/index.md golden/hugo/content/en/dir/index.md | ||
|
||
-- hugo/.keep -- | ||
-- content/site.cue -- | ||
package site | ||
-- content/dir/page.cue -- | ||
package site | ||
|
||
content: dir: page: { | ||
leftDelim: "{{{" | ||
rightDelim: "}}}" | ||
} | ||
-- content/dir/en.md -- | ||
>--- | ||
>title: JSON Superset | ||
>--- | ||
> | ||
>{{{with script "en" "1"}}} | ||
>find $HOME -type f | sort | ||
>{{{end}}} | ||
> | ||
>{{{with upload "en" "2"}}} | ||
>-- one.txt -- | ||
>{{{end}}} | ||
>{{{with upload "en" "3"}}} | ||
>-- another/two.txt -- | ||
>{{{end}}} | ||
> | ||
>{{{with script "en" "4"}}} | ||
>find $HOME -type f | sort | ||
>cd another | ||
>{{{end}}} | ||
> | ||
>{{{with upload "en" "5"}}} | ||
>-- one.txt -- | ||
>{{{end}}} | ||
>{{{with upload "en" "6"}}} | ||
>-- another/two.txt -- | ||
>{{{end}}} | ||
> | ||
>{{{with script "en" "7"}}} | ||
>find $HOME -type f | sort | ||
>{{{end}}} | ||
> | ||
-- golden/hugo/content/en/dir/index.md -- | ||
--- | ||
title: JSON Superset | ||
--- | ||
|
||
```text { title="TERMINAL" codeToCopy="ZmluZCAkSE9NRSAtdHlwZSBmIHwgc29ydAo=" } | ||
$ find $HOME -type f | sort | ||
/home/runner/.bash_logout | ||
/home/runner/.bashrc | ||
/home/runner/.profile | ||
``` | ||
|
||
```txt { title="one.txt" } | ||
``` | ||
```txt { title="another/two.txt" } | ||
``` | ||
|
||
```text { title="TERMINAL" codeToCopy="ZmluZCAkSE9NRSAtdHlwZSBmIHwgc29ydApjZCBhbm90aGVyCg==" } | ||
$ find $HOME -type f | sort | ||
/home/runner/.bash_logout | ||
/home/runner/.bashrc | ||
/home/runner/.profile | ||
/home/runner/another/two.txt | ||
/home/runner/one.txt | ||
$ cd another | ||
``` | ||
|
||
```txt { title="one.txt" } | ||
``` | ||
```txt { title="another/two.txt" } | ||
``` | ||
|
||
```text { title="TERMINAL" codeToCopy="ZmluZCAkSE9NRSAtdHlwZSBmIHwgc29ydAo=" } | ||
$ find $HOME -type f | sort | ||
/home/runner/.bash_logout | ||
/home/runner/.bashrc | ||
/home/runner/.profile | ||
/home/runner/another/two.txt | ||
/home/runner/one.txt | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters