Summary
I encountered a panic when running against the ardupilot repository in this PR #915
Insrc/identity.rs this line caused prek to panic
tags.extend(tags_from_filename(path));
if executable {
if let Ok(shebang) = parse_shebang(path) {
tags.extend(tags_from_interpreter(&shebang[0]));
}
}
output:
prek run check-executables-have-shebangs --all-files --verbose
thread '<unnamed>' panicked at src/identify.rs:767:55:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It panics because of illegal access of the first element in what could still be an empty list (&shebang[0]).
I adressed the issue in #915, as well, but only adressed the illegal access, not the parse_shebang function itself.
Platform
Darwin 24.6.0 arm64
Version
v0.2.9
.pre-commit-config.yaml
No response
Log file
No response
Summary
I encountered a panic when running against the ardupilot repository in this PR #915
In
src/identity.rsthis line caused prek to panicoutput:
It panics because of illegal access of the first element in what could still be an empty list (
&shebang[0]).I adressed the issue in #915, as well, but only adressed the illegal access, not the
parse_shebangfunction itself.Platform
Darwin 24.6.0 arm64
Version
v0.2.9
.pre-commit-config.yaml
No response
Log file
No response