Compare commits

..
Author SHA1 Message Date
dependabot[bot] 806c0df361 build(deps): bump actions/github-script from 7.1.0 to 9.0.0
Bumps [actions/github-script](https://github.com/actions/github-script) from 7.1.0 to 9.0.0.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/f28e40c7f34bde8b3046d885e986cb6290c5673b...3a2844b7e9c422d3c10d287c895573f7108da1b3)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-version: 9.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-09-09 00:30:42 +00:00
Nicolas Le Cam 8e9aa04cb2 Merge pull request #3258 from breisnerlopez/fix/grep-l-max-len-collision
test(grep): pin -l/-L parity with grep, including numeric patterns
2026-09-09 02:06:09 +02:00
Nicolas Le CamandClaude Opus 5 d554bef221 test(grep): cover the numeric pattern that -l silently swallowed
A non-numeric pattern stops at clap's parse error and falls back to raw
grep, so rtk and grep agree byte-for-byte whether or not `-l` is bound to
--max-len: the three existing cases still pass with the bug reintroduced.
Only a numeric pattern reaches the wrong answer -- rtk printed nothing and
exited 1 where grep listed the file.

Drop the clap-level test and the comment sentence with it. Develop's
test_grep_parse_files_with_matches_l already fails under the same mutation,
and -L never had a short binding on --max-len, so src/main.rs is untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 01:53:30 +02:00
breisnerlopez 74ec07017f fix(grep): put --max-len before positionals in bench; reuse assert_eq_grep
Address review:
- benchmark.sh: with trailing_var_arg on extra_args, --max-len after the
  positionals was swallowed and forwarded raw to grep (unknown option ->
  bench FAIL). Move it before -rn/pattern so rtk parses it; verified 320KB
  -> 14.8KB (~95%) and that --max-len 40 vs 200 changes output size.
- grep_faithful_format_test: the inline cmp closure duplicated the existing
  assert_eq_grep helper (rtk_grep + grep_plain, same stdout/exit asserts);
  drop it in.
2026-09-08 15:30:49 +02:00
breisnerlopez 5681008ca9 fix(grep): free -l for GNU --files-with-matches instead of --max-len
`-l` was bound to RTK's `--max-len`, colliding with GNU grep where `-l`
means `--files-with-matches`. Running `grep -l <pattern>` made clap read
the pattern as a usize and error (`invalid value '<pattern>' for
'--max-len'`), dropping the command to a raw-grep fallback at 0% savings.

Drop the short binding. `-l`/`-L` now flow to `extra_args`, where the
existing `has_format_flag` already routes them to the grep passthrough
(GNU semantics, minimal output). `--max-len` keeps its long form and its
default of 80; nothing internal used the short.

- src/main.rs: remove `short = 'l'` from `Grep::max_len` + clap-parse
  regression test.
- tests/grep_faithful_format_test.rs: end-to-end test asserting
  `rtk grep -l/-L` is byte-identical to `grep -l/-L`, covering `-l`
  leading and trailing.
- scripts/benchmark.sh: the max-len bench used the old `-l 40` alias ->
  `--max-len 40`.
- docs/usage/FEATURES.md: drop the `-l` short from the grep options table.
2026-09-08 15:30:49 +02:00
2 changed files with 27 additions and 1 deletions

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ jobs:
permission-pull-requests: write
- name: Add wrong-base label and comment
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
+26
View File
@@ -209,3 +209,29 @@ fn dash_m_max_count_is_per_file_like_grep_n() {
let f2 = write(d.path(), "b.txt", "hit\nhit\nhit\n");
assert_eq_grep_with_and_without_n(&["-m", "2", "hit", &f1, &f2]); // 2 per file, both files
}
// Regression: the `-l` short used to be bound to RTK's --max-len, so `grep -l PAT`
// made clap read PAT as a usize and error out (0% savings via raw fallback).
// `-l` is GNU grep's --files-with-matches; `rtk grep -l` must match `grep -l`
// byte-for-byte (explicit file args => deterministic order). Also covers `-l`
// trailing (arg-order sensitivity) and `-L` (--files-without-match).
#[test]
fn dash_l_and_dash_cap_l_match_grep() {
let d = tempfile::tempdir().unwrap();
let f1 = write(d.path(), "hit1.txt", "alpha\ntenant_id here\n");
let f2 = write(d.path(), "miss.txt", "nothing to see\n");
let f3 = write(d.path(), "hit2.txt", "tenant_id again\n");
let f4 = write(d.path(), "port.txt", "listen on 8080\n");
assert_eq_grep(&["-l", "tenant_id", &f1, &f2, &f3]); // -l leading (the token that broke)
assert_eq_grep(&["tenant_id", &f1, &f2, &f3, "-l"]); // -l trailing
assert_eq_grep(&["-L", "tenant_id", &f1, &f2, &f3]); // -L files-without-match
// A numeric pattern is the only form that failed silently: bound to `usize`,
// `-l` swallowed it as max_len and read the first path as the pattern, so rtk
// printed nothing and exited 1 while grep listed the file. A non-numeric
// pattern stops at clap's parse error and falls back to raw grep, which is
// byte-identical here and so invisible to the assertions above.
assert_eq_grep(&["-l", "8080", &f4, &f2]);
assert_eq_grep(&["-L", "8080", &f4, &f2]);
}