From 5a91ed909d1e09f7850246dced7044e018434721 Mon Sep 17 00:00:00 2001 From: Jay Pokale Date: Wed, 25 Nov 2026 20:04:07 +0530 Subject: [PATCH 1/3] fix(scripts): keep combining marks inside Unicode feature-name words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The core create-new-feature scripts kept only letters (L*) and decimal digits when building branch names, so combining marks (Mn/Mc/Me) were treated as separators. Scripts that write vowels and diacritics as marks (Devanagari, Thai, Arabic with harakat, decomposed accents) were split mid-word: "नमस्ते दुनिया" became "001-नमस-त-द". Keep marks in the bash, Python and PowerShell variants. Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous) --- scripts/bash/create-new-feature.sh | 5 ++- scripts/powershell/create-new-feature.ps1 | 4 +- scripts/python/create_new_feature.py | 7 +++- .../test_create_new_feature_python_parity.py | 38 +++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/scripts/bash/create-new-feature.sh b/scripts/bash/create-new-feature.sh index 6c2f04b8bd..9c23807acd 100644 --- a/scripts/bash/create-new-feature.sh +++ b/scripts/bash/create-new-feature.sh @@ -201,10 +201,13 @@ unicode_words() { fi printf '%s' "$name" | "${python_cmd[@]}" -c ' import sys +import unicodedata value = sys.stdin.buffer.read().decode("utf-8") lower = str.maketrans("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") result = "".join( - char if char.isalpha() or char.isdecimal() else sys.argv[1] + char + if char.isalpha() or char.isdecimal() or unicodedata.category(char).startswith("M") + else sys.argv[1] for char in value.translate(lower) ) sys.stdout.buffer.write(result.encode("utf-8")) diff --git a/scripts/powershell/create-new-feature.ps1 b/scripts/powershell/create-new-feature.ps1 index edb75b3222..f4ac59ee36 100644 --- a/scripts/powershell/create-new-feature.ps1 +++ b/scripts/powershell/create-new-feature.ps1 @@ -93,11 +93,11 @@ function ConvertTo-UnicodeWords { param([string]$Name, [string]$Separator) $lowerName = ConvertTo-AsciiLower -Name $Name - return [regex]::Replace($lowerName, '[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\p{L}\p{Nd}]', { + return [regex]::Replace($lowerName, '[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\p{L}\p{M}\p{Nd}]', { param($match) if ($match.Length -eq 2) { $category = [System.Globalization.CharUnicodeInfo]::GetUnicodeCategory($match.Value, 0) - if ($category.ToString() -match '(Letter|DecimalDigitNumber)$') { + if ($category.ToString() -match '(Letter|Mark|DecimalDigitNumber)$') { return $match.Value } } diff --git a/scripts/python/create_new_feature.py b/scripts/python/create_new_feature.py index 2099a73708..3a15c6a845 100644 --- a/scripts/python/create_new_feature.py +++ b/scripts/python/create_new_feature.py @@ -9,6 +9,7 @@ import re import shlex import sys +import unicodedata from dataclasses import dataclass from pathlib import Path @@ -177,7 +178,11 @@ def _clean_branch_name(name: str) -> str: def _unicode_words(name: str, separator: str) -> str: return "".join( - char if char.isalpha() or char.isdecimal() else separator + char + if char.isalpha() + or char.isdecimal() + or unicodedata.category(char).startswith("M") + else separator for char in name.translate(_ASCII_LOWER) ) diff --git a/tests/test_create_new_feature_python_parity.py b/tests/test_create_new_feature_python_parity.py index e98f65e463..8dc37976d9 100644 --- a/tests/test_create_new_feature_python_parity.py +++ b/tests/test_create_new_feature_python_parity.py @@ -196,6 +196,44 @@ def test_unicode_number_categories_match( assert json_stdout(result)["BRANCH_NAME"] == expected +@pytest.mark.parametrize( + "variant", + [ + pytest.param("bash", marks=requires_bash), + "python", + pytest.param( + "powershell", + marks=pytest.mark.skipif(not HAS_POWERSHELL, reason="no PowerShell available"), + ), + ], +) +@pytest.mark.parametrize( + ("description", "expected"), + [ + ("नमस्ते दुनिया", "001-नमस्ते-दुनिया"), + ("สร้างระบบล็อกอิน", "001-สร้างระบบล็อกอิน"), + ("مَرْحَبًا بالعالم", "001-مَرْحَبًا-بالعالم"), + ("cafe\u0301 menu", "001-cafe\u0301-menu"), + ], + ids=["devanagari", "thai", "arabic_diacritics", "decomposed_accent"], +) +def test_combining_marks_stay_inside_words( + repo: Path, variant: str, description: str, expected: str +) -> None: + powershell = variant == "powershell" + args = ( + ("-Json", "-DryRun", description) + if powershell + else ("--json", "--dry-run", description) + ) + command = {"bash": bash_cmd, "python": py_cmd, "powershell": ps_cmd}[variant] + + result = run(command(repo, SCRIPT, *args), repo) + + assert result.returncode == 0, result.stderr + assert json_stdout(result)["BRANCH_NAME"] == expected + + @requires_bash def test_bash_reports_missing_utf8_locale_for_unicode_only( repo: Path, tmp_path: Path From a206c2389aa5c734a62c13ffd8b72e0dad709718 Mon Sep 17 00:00:00 2001 From: Jay Pokale Date: Wed, 25 Nov 2026 20:49:29 +0530 Subject: [PATCH 2/3] test(scripts): run combining-marks cases on pwsh and Windows PowerShell 5.1 The regression test used ps_cmd, which prefers pwsh, so the PowerShell sanitizer change was never exercised on Windows PowerShell 5.1. Run the PowerShell cases explicitly through pwsh and WINDOWS_POWERSHELL, each skipped when its runtime is absent. Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous) --- .../test_create_new_feature_python_parity.py | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/test_create_new_feature_python_parity.py b/tests/test_create_new_feature_python_parity.py index 8dc37976d9..c495d66c4a 100644 --- a/tests/test_create_new_feature_python_parity.py +++ b/tests/test_create_new_feature_python_parity.py @@ -17,6 +17,7 @@ from tests.conftest import requires_bash from tests.parity_helpers import ( HAS_POWERSHELL, + HAS_PWSH, WINDOWS_POWERSHELL, _bash_posix_path, bash_cmd, @@ -74,8 +75,14 @@ def repo_pair(tmp_path: Path) -> tuple[Path, Path]: pytest.param("bash", marks=requires_bash), "python", pytest.param( - "powershell", - marks=pytest.mark.skipif(not HAS_POWERSHELL, reason="no PowerShell available"), + "pwsh", + marks=pytest.mark.skipif(not HAS_PWSH, reason="pwsh not available"), + ), + pytest.param( + "windows-powershell-5.1", + marks=pytest.mark.skipif( + not WINDOWS_POWERSHELL, reason="Windows PowerShell 5.1 not available" + ), ), ], ) @@ -220,15 +227,15 @@ def test_unicode_number_categories_match( def test_combining_marks_stay_inside_words( repo: Path, variant: str, description: str, expected: str ) -> None: - powershell = variant == "powershell" - args = ( - ("-Json", "-DryRun", description) - if powershell - else ("--json", "--dry-run", description) - ) - command = {"bash": bash_cmd, "python": py_cmd, "powershell": ps_cmd}[variant] + if variant in ("pwsh", "windows-powershell-5.1"): + exe = "pwsh" if variant == "pwsh" else WINDOWS_POWERSHELL + script = repo / ".specify/scripts/powershell/create-new-feature.ps1" + cmd = [exe, "-NoProfile", "-File", str(script), "-Json", "-DryRun", description] + else: + command = {"bash": bash_cmd, "python": py_cmd}[variant] + cmd = command(repo, SCRIPT, "--json", "--dry-run", description) - result = run(command(repo, SCRIPT, *args), repo) + result = run(cmd, repo) assert result.returncode == 0, result.stderr assert json_stdout(result)["BRANCH_NAME"] == expected From 809cb109e1ab3b9d779108668f9d166dc2bc5151 Mon Sep 17 00:00:00 2001 From: Jay Pokale Date: Thu, 26 Nov 2026 02:39:12 +0530 Subject: [PATCH 3/3] test(scripts): put the pwsh and Windows PowerShell 5.1 cases on the combining-marks test The previous commit parametrized the wrong test: test_empty_feature_name_warning received the pwsh and windows-powershell-5.1 variants but still looks up "powershell" in its command table, so every pwsh case raised KeyError. Restore that test's original "powershell" variant and move the two explicit runtimes to test_combining_marks_stay_inside_words, which already handles them. Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous) --- .../test_create_new_feature_python_parity.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_create_new_feature_python_parity.py b/tests/test_create_new_feature_python_parity.py index c495d66c4a..9ef5b9299b 100644 --- a/tests/test_create_new_feature_python_parity.py +++ b/tests/test_create_new_feature_python_parity.py @@ -75,14 +75,8 @@ def repo_pair(tmp_path: Path) -> tuple[Path, Path]: pytest.param("bash", marks=requires_bash), "python", pytest.param( - "pwsh", - marks=pytest.mark.skipif(not HAS_PWSH, reason="pwsh not available"), - ), - pytest.param( - "windows-powershell-5.1", - marks=pytest.mark.skipif( - not WINDOWS_POWERSHELL, reason="Windows PowerShell 5.1 not available" - ), + "powershell", + marks=pytest.mark.skipif(not HAS_POWERSHELL, reason="no PowerShell available"), ), ], ) @@ -209,8 +203,14 @@ def test_unicode_number_categories_match( pytest.param("bash", marks=requires_bash), "python", pytest.param( - "powershell", - marks=pytest.mark.skipif(not HAS_POWERSHELL, reason="no PowerShell available"), + "pwsh", + marks=pytest.mark.skipif(not HAS_PWSH, reason="pwsh not available"), + ), + pytest.param( + "windows-powershell-5.1", + marks=pytest.mark.skipif( + not WINDOWS_POWERSHELL, reason="Windows PowerShell 5.1 not available" + ), ), ], )