Skip to content

Refine !rename parsing to require directive token boundary#10

Merged
Therosin merged 2 commits intodevelopfrom
codex/update-rename-directive-recognition-in-parsekeeplist
Mar 1, 2026
Merged

Refine !rename parsing to require directive token boundary#10
Therosin merged 2 commits intodevelopfrom
codex/update-rename-directive-recognition-in-parsekeeplist

Conversation

@Therosin
Copy link
Member

@Therosin Therosin commented Mar 1, 2026

Motivation

  • Prevent filenames that merely begin with !rename (e.g. !rename_backup.dll) from being misinterpreted as rename directives by making directive detection token-aware.

Description

  • Update parseKeeplist in logic.ts to detect rename directives only when the line matches the token boundary !rename using /^!rename(\s|$)/, preserving existing parse/validation behavior for true !rename directives.
  • Add tests in logic_test.ts to verify that a literal like !rename_backup.dll is treated as a keep rule and that malformed true !rename directives (missing ->) still trigger the existing parse error.

Testing

  • Ran deno fmt logic.ts logic_test.ts which passed formatting checks.
  • Attempted deno task test but it failed in this environment due to inability to fetch the JSR metadata for @std/assert (external network manifest retrieval error), so test suite could not be completed here.

Codex Task

Copilot AI review requested due to automatic review settings March 1, 2026 14:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines keeplist parsing so !rename is recognized as a directive only when it appears as a standalone token (followed by whitespace or end-of-line), preventing literal filenames like !rename_backup.dll from being misinterpreted as rename directives.

Changes:

  • Update parseKeeplist to detect !rename directives with a token-boundary regex (/^!rename(\s|$)/).
  • Add tests ensuring !rename-prefixed literals are treated as keep rules and that malformed true !rename directives still raise the existing parse error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
logic.ts Tightens !rename directive detection to require a token boundary, preventing false-positive directive parsing.
logic_test.ts Adds regression tests covering !rename-prefixed literals and directive parsing error behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Therosin Therosin merged commit 355f296 into develop Mar 1, 2026
2 checks passed
@Therosin Therosin deleted the codex/update-rename-directive-recognition-in-parsekeeplist branch March 1, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants