Skip to content

fix(hooks): honor exclude_commands for head/tail rewrites - #3378

Closed
mohammedelkarsh wants to merge 1 commit into
rtk-ai:developfrom
mohammedelkarsh:fix/3371-exclude-head-tail
Closed

mohammedelkarsh wants to merge 1 commit into
rtk-ai:developfrom
mohammedelkarsh:fix/3371-exclude-head-tail

Conversation

@mohammedelkarsh

Copy link
Copy Markdown

Summary

  • head/tail rewrites now consult hooks.exclude_commands before the rewrite_line_range short-circuit
  • Makes exclude_commands = [cat, head, tail] consistent: all three stay unre written
  • Adds regression coverage for head -N, tail -N, and tail -n N

Fixes #3371

Test plan

  • cargo test exclude_head_and_tail / head_rewrites_when_not_excluded
  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • Manual: rtk hook check 'head -50 big.log' with exclude_commands = [head] prints No rewrite

The head/tail short-circuit skipped the exclude matcher, so listing
head/tail in hooks.exclude_commands had no effect unlike cat.

Fixes rtk-ai#3371
@KuSh

KuSh commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

Closing as a duplicate of #3324, which fixes the same gap; #3324 will carry Fixes #3371.

There were seven PRs open against this one fast path. #3324 was picked on shape: it strips the env prefix before matching, so sudo head -20 f and FOO=1 head -20 f are covered too. This version matches cmd_part raw, so those still rewrite past the exclusion.

Thanks for the report and the fix — #3371 is what made the cluster findable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[hooks] exclude_commands silently ignored for head/tail rewrites (honored for cat)

2 participants