Skip to content

Commit

Permalink
Address a few minor issues in the new build code
Browse files Browse the repository at this point in the history
Caught in self-review, and I don't feel like turning them into fixups
for all of the commits that introduced these.
  • Loading branch information
ruuda committed Jul 27, 2024
1 parent 7c8382a commit 12ffe62
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/rcl_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The following `build.rcl` writes two files to the `users` directory:

```rcl
let default_options = {
banner = "# This file is generated from build.rcl.\n",
banner = "# This file is generated from build.rcl.",
format = "toml",
};
{
Expand Down Expand Up @@ -74,8 +74,8 @@ The value to write to the file in the desired format.

### format

The output format. This must be one of the formats supported by
[`--format`](rcl_evaluate.md#-f-format-format).
The output format (`json`, `toml`, etc.). This must be one of the formats
supported by [`--format`](rcl_evaluate.md#-f-format-format).

### width

Expand Down
4 changes: 2 additions & 2 deletions examples/build.rcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"out/github_actions.yml": {
contents = import "github_actions.rcl",
format = "json",
banner = "# This file is generated from github_actions.rcl.\n",
banner = "# This file is generated from github_actions.rcl.",
},
"out/buckets.toml": {
contents = import "buckets.rcl",
format = "toml",
banner = "# This file is generated from buckets.rcl.\n",
banner = "# This file is generated from buckets.rcl.",
},
}
1 change: 1 addition & 0 deletions fuzz/dictionary_cli.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Commands
"build"
"evaluate"
"fmt"
"format"
Expand Down
9 changes: 6 additions & 3 deletions src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl Filesystem for SandboxFilesystem {

// Walk all parent directories, from the workdir down deeper, and create
// them if needed, and verify that they comply with the sandbox policy.
// `.ancestors()` returns the path itself aswell, so we `.skip(1)`.
// `.ancestors()` returns the path itself as well, so we `.skip(1)`.
let ancestors: Vec<_> = path_buf.ancestors().collect();
for ancestor in ancestors.iter().skip(1).rev() {
// Ancestors also includes the ancestors of the workdir, but we only
Expand Down Expand Up @@ -392,7 +392,10 @@ impl Filesystem for SandboxFilesystem {
// there is no portable way to sidestep that, and it's a quite
// pathological problem, so I'm going to accept the risk.
match self.mode {
SandboxMode::Unrestricted => {}
SandboxMode::Unrestricted => {
// The unrestricted policy places no requirements on the
// path, so we don't check anything here.
}
SandboxMode::Workdir => {
let abs_path = match std::fs::canonicalize(ancestor) {
Ok(path) => path,
Expand All @@ -413,7 +416,7 @@ impl Filesystem for SandboxFilesystem {
"'."
})
.with_body(concat! {
"Refusing to write to this path:"
"Refusing to write in this path:"
pprint::Doc::HardBreak pprint::Doc::HardBreak
indent! { pprint::Doc::path(ancestor) }
pprint::Doc::HardBreak pprint::Doc::HardBreak
Expand Down
2 changes: 1 addition & 1 deletion src/pprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl<'a> Doc<'a> {
/// Construct a highlighted document fragment for a file path.
///
/// This is expected to be used only in error messages, therefore it's okay
/// that we an owned copy of the path.
/// that we make an owned copy of the path.
pub fn path<P: AsRef<std::path::Path>>(path: P) -> Doc<'static> {
let path_str = path.as_ref().to_string_lossy();
Doc::highlight(&path_str).into_owned()
Expand Down

0 comments on commit 12ffe62

Please sign in to comment.