morningman opened a new pull request, #67491:
URL: https://github.com/apache/doris/pull/67491

   ### What problem does this PR solve?
   
   Issue Number: close #xxx
   
   Related PR: #66957 (introduced the regression), #67487 (a PR currently 
blocked by it)
   
   Problem Summary:
   
   The PR title checker rejects every title whose type or scope contains a 
hyphen:
   
   ```
   [fix](arrow-flight) ...
   [feature](inverted-index) ...
   [improvement](github-actions) ...
   ```
   
   **88 of the last 1500 commits on master use such a title**, including #66957 
itself — the change that introduced the current check. Its own title, 
`[improvement](github-actions) Reduce redundant GitHub Actions runs and 
checkouts`, would not pass the checker it added.
   
   **Root cause.** #66957 replaced the `deepakputhraya/action-pr-title` action 
with an inline `grep -qE` and kept the action's regex verbatim, with the 
comment "Same regex as the previously used ... submodule". But that action is 
**JavaScript**, where `\-` inside a character class is a valid escape for a 
literal hyphen. **POSIX ERE has no such escape** — a backslash inside a bracket 
expression is just a backslash. So
   
   ```
   [a-zA-Z0-9 \-_]
   ```
   
   does not mean "letters, digits, space, hyphen, underscore". It makes `\` a 
member and then reads `-_` as a range endpoint, which leaves the hyphen itself 
out of the set. Porting the pattern from JS to `grep` silently changed its 
meaning.
   
   The fix is to put the literal hyphen last in the bracket expression, which 
is how POSIX spells it:
   
   ```diff
   -if ! grep -qE '\[([a-zA-Z0-9 \-_])+\]\(([a-zA-Z0-9 \-_])+\)(.*)' <<< 
"${TITLE}"; then
   +if ! grep -qE '\[([a-zA-Z0-9 _-])+\]\(([a-zA-Z0-9 _-])+\)(.*)' <<< 
"${TITLE}"; then
   ```
   
   A comment now records why the JS form cannot be restored verbatim, so the 
pattern is not "fixed back" later.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [x] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [x] Other reason: the change is a single workflow regex; it is 
exercised by this PR's own title check and by the evidence below.
   
   The old expression is not merely permissive-but-wrong — BSD grep rejects it 
outright:
   
   ```
   $ /usr/bin/grep -qE '\[([a-zA-Z0-9 \-_])+\]\(([a-zA-Z0-9 \-_])+\)(.*)' <<< 
'[fix](arrow-flight) x'
   grep: invalid character range
   ```
   
   Old vs new, on the two grep implementations available to me locally:
   
   | Title | old (BSD) | new (BSD) | old (ugrep) | new (ugrep) |
   |---|---|---|---|---|
   | `[fix](arrow-flight) point query` | FAIL | PASS | PASS | PASS |
   | `[fix](arrow-flight-sql) x` | FAIL | PASS | PASS | PASS |
   | `[improvement](github-actions) Reduce redundant runs` | FAIL | PASS | PASS 
| PASS |
   | `[fix](arrow_flight) underscore` | FAIL | PASS | PASS | PASS |
   | `[fix](nereids) plain` | FAIL | PASS | PASS | PASS |
   | `[opt](build) Decouple status.h` | FAIL | PASS | PASS | PASS |
   | `no brackets` | FAIL | **FAIL** | FAIL | **FAIL** |
   | `[fix] no scope` | FAIL | **FAIL** | FAIL | **FAIL** |
   
   The last two rows are the point: the check is not weakened, malformed titles 
are still rejected.
   
   I do not have GNU grep on this machine, so I did not run the new expression 
under it. GNU grep rejecting the **old** expression is directly observed — it 
is what the failing `Check PR title` run on #67487 shows. That the **new** 
expression works there follows from the POSIX rule the fix relies on: a hyphen 
last in a bracket expression is a literal hyphen on any conforming engine, and 
GNU grep documents this explicitly.
   
   Note this PR's own title deliberately uses `(ci)` rather than a hyphenated 
scope, because a fork PR is checked by the workflow on the base branch — that 
is, the broken one this PR fixes.
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. PR titles with a hyphen in the type or scope are accepted 
again, as they were before #66957. No other title is newly accepted or newly 
rejected.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_017omcvWDsxEc9AyU83aBZ2g
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to