Skip to content

hrw4u: Fix section placement for hookless rules in u4wrh#12956

Open
zwoop wants to merge 1 commit intoapache:masterfrom
zwoop:U4wrhNoSection
Open

hrw4u: Fix section placement for hookless rules in u4wrh#12956
zwoop wants to merge 1 commit intoapache:masterfrom
zwoop:U4wrhNoSection

Conversation

@zwoop
Copy link
Contributor

@zwoop zwoop commented Mar 11, 2026

Old header_rewrite rules without an explicit hook condition default to REMAP. When u4wrh converted these, the section opened inside the if-block instead of wrapping it. Also emit comments inline inside if-blocks instead of deferring them to after the section closes, and remove the now-unused deferred comment machinery. In the forward direction, indent block-level comments at the statement level.

Co-Authored-By: Keele Clendenin

Old header_rewrite rules without an explicit hook condition
default to REMAP. When u4wrh converted these, the section
opened inside the if-block instead of wrapping it. Also emit
comments inline inside if-blocks instead of deferring them
to after the section closes, and remove the now-unused
deferred comment machinery. In the forward direction, indent
block-level comments at the statement level.

Co-Authored-By: Keele Clendenin
@zwoop zwoop added this to the 11.0.0 milestone Mar 11, 2026
@zwoop zwoop requested review from bneradt and Copilot March 11, 2026 16:36
@zwoop zwoop self-assigned this Mar 11, 2026
@zwoop zwoop added the hrw4u label Mar 11, 2026
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

Fixes u4wrh conversion for legacy header_rewrite rules that omit an explicit hook by ensuring the section wraps the generated if-block (rather than being opened inside it), and adjusts comment emission/indentation to be inline and statement-aligned.

Changes:

  • Relocate pre-section if blocks so the section header wraps them for hookless legacy rules.
  • Emit comments inline within if blocks and remove deferred-comment buffering.
  • Update/generate golden test fixtures for the new formatting and add an exception entry for the legacy no-hook case.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/hrw4u/src/hrw_visitor.py Fixes section placement by relocating pre-section if output; inlines comment emission and removes deferred-comment machinery.
tools/hrw4u/src/visitor.py Indents comment output at the current statement indentation level.
tools/hrw4u/tests/data/examples/all-nonsense.output.txt Updates golden output to reflect new in-block comment indentation.
tools/hrw4u/tests/data/conds/no-hook.input.txt Adds a legacy hookless u4wrh input fixture to reproduce the section-wrapping bug.
tools/hrw4u/tests/data/conds/no-hook.output.txt Adds corresponding expected header_rewrite output fixture.
tools/hrw4u/tests/data/conds/exceptions.txt Records the legacy no-hook case as an exception with rationale.

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