Conversation
Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com>
- Force LC_ALL=C so ls always outputs English month names regardless of system locale - When no lines are parsed (e.g., non-English locale where regex fails to match), fall back to raw output instead of returning '(empty)' - This prevents silent data loss for users in zh_CN/ja/ko/etc. locales - Fixes #1276
…1362) `head -N file1 file2 ...` was rewritten to `rtk read file1 file2 ... --max-lines N`. The capture regex was greedy (`(.+)$`), so every file argument was folded into a single string. `rtk read` then silently mis-handled the shape and fell through to the system `read` builtin (`/usr/bin/read`) which rejects paths starting with `/` as "not a valid identifier". Tighten each head/tail regex to a single non-whitespace file argument (`\S+$`). When >1 file is provided the regex misses, `rewrite_line_range` returns `None`, and the command falls through to the native `head` / `tail` binary — which already handles multi-file input with the expected `==> name <==` banners. Same class as the cat multi-file fix in #989. Added six regression tests covering the `-N`, `--lines=N`, `-n N`, and `--lines N` variants for both `head` and `tail`.
- Move . and .. detection before date parsing (is_dotdir) for non-English locale compatibility - Add dotdirs counter to distinguish empty dir (only . and ..) from real content that failed to parse - Fix test_compact_empty to use real ls -la output (includes . and ..) - Add test_compact_empty_chinese_locale for Chinese locale empty dir case - Closes regression where fallback falsely triggered on empty directories
- Force LC_ALL=C so ls always outputs English month names - When zero lines parsed but directory has content, fallback to raw output - Add is_dotdir() to distinguish empty dirs (only . and ..) from unparseable content - Fix empty directory regression for both English and non-English locales - Closes #1276
Fix seems counter intuitive but it helps a lot on my machine. Before, I had 234 errors (23%) out of 1,000 tests run; now, I only have one (0.1%) It's not totaly fixed but it reduce error a lot and avoids having one almost every time I test a PR. Another way to completly fix it would be to use std::fs::set_times on old.trx to set each time in the past, but it requires unstable fs_set_times feature, so I'm not sure you'll agree with that Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com>
…eady be as small as possible
Consolidate stash default handlers to ensure "no local changes" is properly detected across all stash operations, not just the default push case. Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com>
Default `rtk git status` runs `git status --porcelain -b` to build its compact view, but porcelain v1 omits the state header git prints when a rebase, merge, cherry-pick, revert, bisect, am, or sparse checkout is in progress. That header is correctness-critical — hiding "You are currently editing a commit while rebasing..." leaves the user thinking the repo is clean when it isn't. `run_status` already captures plain `git status` output as `raw_output` for tracking, so this fix adds `extract_state_header` to pull the state block out of it and prepends the block to the compact output. Returns `None` when nothing is in progress so clean repos are unchanged. Covered states: interactive / regular rebase, merge-with-unmerged-paths, "still merging after conflicts fixed", cherry-pick, revert, bisect, am, sparse checkout. Preserves the directive hints git prints alongside (`git rebase --continue`, `git commit --amend`, `git bisect reset`, etc.), while still filtering generic `(use "git add")` / `(use "git restore")` noise. Design principle: Correctness vs Token Savings — never hide information that changes the user's understanding of repo state.
- Drop redundant LANG=C env (LC_ALL=C is sufficient). - Replace nested if/else chains in detect_status_state and extract_state_hint with const slices + iter for readability. - Drop the 2-space indent prefix on hint lines — adds nothing for machine consumption.
KuSh: the in-progress state line ("rebase in progress", "merge in
progress. unresolved conflicts", etc.) is enough — LLMs know which git
commands resolve each state, so the per-state hint list was noise.
Removes STATE_HINTS and extract_state_hint, and reduces extract_state_header
to a short walk that returns the first detected state summary or None.
Existing per-state tests now assert the exact compact summary.
fix(grep): adjust the command to fall through if the output would already be as small as possible
- **Path Centralization:** Hardcoded directory and file paths across all hook logic () are replaced with dedicated, exported constants in . This prevents magic strings and simplifies maintenance when system directories change. - **Code Cleanup:** Move all code only used by tests behind cfg(test) attribute - **Refactoring:** Apply Clippy fixes and address remaining warnings Signed-off-by: Nicolas Le Cam <niko.lecam@gmail.com>
Bumps [rustls-webpki](https://github.com/rustls/webpki) from 0.103.9 to 0.103.13. - [Release notes](https://github.com/rustls/webpki/releases) - [Commits](rustls/webpki@v/0.103.9...v/0.103.13) --- updated-dependencies: - dependency-name: rustls-webpki dependency-version: 0.103.13 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
… output `rtk curl` was unconditionally truncating any response >=500 bytes when a tee hint was available, inserting the literal `... (N bytes total)` marker mid-stream. For JSON bodies this produces invalid, unparseable output and silently breaks every downstream `jq`, `python -m json.tool`, or agent pipeline that consumes `rtk curl`. Two changes in `filter_curl_output`: 1. JSON heuristic passthrough — if the trimmed body starts/ends with matching JSON brackets, return it unchanged. The body is already buffered in memory so the check is essentially free. 2. `is_terminal()` gate — only truncate non-JSON output when stdout is a TTY. Pipes and shell redirects (`> file`, `| jq`) now receive the full body, matching what `curl -o file` already does and closing the silent-data-loss path described in #1282. The tee file is still written for inspection, but the hint line is suppressed in the passthrough cases so it never leaks into pipes. Tests: existing 5 cases updated to pass `is_tty=true` (preserve TTY-mode assertions); 4 new cases cover JSON object/array passthrough at >500 bytes and pipe-mode (non-TTY) full-body delivery. Verified end-to-end against the public repro from the issue: `rtk curl -s https://jsonplaceholder.typicode.com/posts | python3 -c 'import sys,json; print(len(json.load(sys.stdin)))'` now returns 100. Closes #1536 Refs #1282 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…y alloc Follow-up to the initial #1536 fix after a deeper review pass. - force_tee_hint() is no longer called on the passthrough path. Previously every non-TTY pipe invocation (curl | jq, curl | python -m json.tool — the exact scenarios this PR fixes) was still writing a tee log file as a side effect, which is wasteful: the tee file's purpose is to give the LLM a recovery path when output is truncated, and we are no longer truncating in those cases. - looks_like_json now also matches bare top-level JSON strings (e.g. /api/token endpoints returning a long quoted token). Previously a >500-byte bare JSON string on a TTY would still get truncated mid-stream and produce invalid output. - FilterResult.content is now Cow<'_, str> so the passthrough path no longer copies the whole body. For multi-MB curl responses piped through rtk this eliminates a full-size allocation. - Exit code from curl is propagated via Ok(result.exit_code) instead of the previously hardcoded Ok(0). On the success path the value is 0 anyway, but the inconsistency with the early-exit branch above made the intent unclear. Tests: 9 -> 11 (added bare-JSON-string passthrough and a Cow::Borrowed assertion verifying the passthrough paths don't allocate). cargo test --all: 1693 passed, 6 ignored. Verified end-to-end against jsonplaceholder.typicode.com/posts (~27 KB, 100 entries, parseable) and a randomly-generated 100-entry / 52 KB / 1450-line JSON served from a local http.server (rtk output byte-identical to source modulo the trailing newline added by println!). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fix(ls): LC_ALL=C + fallback to raw on unrecognized locale
fix: head/tail multi-file rewrite falls back to native command (#1362)
fix(pnpm): install don't take a list of packages
|
|
Character devices (c), block devices (b), pipes (p), and sockets (s) were silently dropped by compact_ls because only regular files (-), symlinks (l), and directories (d) were handled. This caused `rtk ls /dev/ttyACM*` to return "(empty)". Closes #844
fix(ls): handle all file types (device, pipe, socket) in ls filter
chore: Fix clippy warnings
fix: dotnet cmd test flakiness
refactor(git): Fix stash status detection for all cases
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features
Fix
bug(grep): -c count flag ignored, returns match summary + context instead of line count fix(grep): adjust the command to fall through if the output would already be as small as possible #1456 close bug(grep):
-ccount flag ignored — returns match summary + context instead of line count #1452fix(ls): LC_ALL=C + fallback to raw on unrecognized locale fix(ls): LC_ALL=C + fallback to raw on unrecognized locale #1338 close rtk ls returns "(empty)" for non-empty directories on non-English locales #1276 rtk ls returns "(empty)" with non-English locales (LANG=de_DE.UTF-8, fr_FR.UTF-8) #1475 [BUG] rtk ls parsing relies on POSIX/C locale date ordering and can return false (empty) output #1652 Bug:
rtk lsreturns empty output when shell aliaslsis mapped toeza#1321 rtk ls returns empty output for non-empty directories (100% information loss) #1566rtk ls -1returns empty output #803fix(ls): handle all file types (device, pipe, socket) in ls filter fix(ls): handle all file types (device, pipe, socket) in ls filter #1451 close RTK exhibits unusual behavior when using ls and wildcards. #844
fix: head/tail multi-file rewrite falls back to native command fix: head/tail multi-file rewrite falls back to native command (#1362) #1371 close [BUG] head -N with multiple files rewrites to invalid
rtk read file1 file2 ... --max-lines N#1362fix(pnpm): install don't take a list of packages fix(pnpm): install don't take a list of packages #1009
fix(tests): dotnet cmd test flakiness fix: dotnet cmd test flakiness #1238 solve an known test env issue
refactor(git): Fix stash status detection for all case refactor(git): Fix stash status detection for all cases #1586 close rtk git stash {push,pop,apply,drop} returns exit 0 on failure and produces ambiguous success output #1535
Others