Skip to content

Commit

Permalink
Made pre-commit work in sillicon macos and linux
Browse files Browse the repository at this point in the history
While running the previous version of the precommit I got the following
error:
```
Found configured hook: pre-commit
Running command: sh pre-commit
Fetching advisory database from
  `https://github.com/RustSec/advisory-db.git`
Updating crates.io index
Scanning Cargo.lock for vulnerabilities (184 crate dependencies)
src/jailer/src/env.rs
sed: illegal option -- z
usage: sed script [-Ealnru] [-i extension] [file ...]
sed [-Ealnu] [-i extension] [-e script] ... [-f script_file]
  ... [file ...]
Configured hook command failed
pre-commit hook rejected
```

Tested a couple different things and the `paste` command seemed to work
both on macos (M1) and on linux (tested it in an ubuntu:22.04
container).

Signed-off-by: seafoodfry <[email protected]>
  • Loading branch information
seafoodfry authored and pb8o committed Jul 16, 2024
1 parent de48fd6 commit 4488f10
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ for i in $(git diff --name-only --cached --diff-filter=d); do
extension="${filename##*.}"
if [ "$extension" = "rs" ]; then
# Read rustfmt config, replace '\n' with ','
rustfmt_config="$(sed -z "s/\n/,/g;s/,$/\n/" ./tests/fmt.toml)"
rustfmt_config="$(paste -sd, ./tests/fmt.toml)"
# We first do a check run, this will fail when it finds a non-matching license.
rustfmt $i --check --config $rustfmt_config
# Run `cargo fmt` for this file
Expand Down

0 comments on commit 4488f10

Please sign in to comment.