You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(git): keep Unicode words in git extension branch names (#5553) - #5559
The git extension's branch scripts (bash, PowerShell, Python) still sanitized names with [^a-z0-9]. With the git extension installed, the before_specify hook turned a CJK-only description into the branch 001-, while the core script created specs/001-添加待办事项/. #4780 fixed the core scripts under the UTF-8 naming policy from #4574 and left extensions/git out of scope. This PR ports the same policy to the three extension twins.
Description
Before (sh / py / ps)
After (all three)
添加待办事项
001- / 001- / error
001-添加待办事项
支持 OAuth2 登录
001-oauth2
001-支持-oauth2-登录
Ünïcödé café
001-caf
001-Ünïcödé-café
Add API for 用户 DB
001-api-db
001-api-用户-db
--short-name "待办 事项!"
001-
001-待办-事项
Add the user login (ASCII)
001-user-login
001-user-login (unchanged)
Changes:
Naming. Unicode letters and decimal digits are kept, and only ASCII letters are lowercased. Short non-ASCII words are kept, because CJK words are often two characters. The logic mirrors core create-new-feature.*, and the extension output now matches the core script for the inputs above.
{author} and {app}. These template tokens stay ASCII-only. Each script has a separate ASCII cleaner for them, so their behavior does not change.
Bash. Unicode is classified through Python, and a UTF-8 locale is selected the same way as in core create-new-feature.sh. The script probes for Python itself (SPECKIT_PYTHON_EXECUTABLE, python3, python, py -3), so it still works when only git-common.sh is loaded or core common.sh predates _python3_command. An explicit non-UTF-8 LC_ALL with Unicode input gives a clear error. ASCII input stays shell-only and needs no Python.
Bash truncation. Names are truncated to 244 bytes by whole UTF-8 characters, dropping bytes under LC_ALL=C. On Git Bash for Windows (MSYS, 16-bit wchar_t), the locale-aware ${var%?} split a character outside the BMP when an odd-length ASCII prefix came first. For example, a followed by 70 copies of 𠀀 produced a broken 244-byte name ending in ➳. Core fit_branch_name has the same problem: with that input it returns a name ending in U+FFFD on Git Bash. Core is left unchanged to keep this PR in scope; I can follow up separately if you want.
PowerShell. The fallback join is now wrapped in @(), so punctuation-only input such as !!! no longer throws from [string]::Join($null). Core already does this. On main the same crash also blocked every CJK-only description. Truncation drops whole surrogate pairs.
Version. The git extension is bumped to 1.0.10 in extension.yml and catalog.json, and the README documents the naming.
Known limitation, inherited from core: Windows PowerShell 5.1 (.NET Framework) uses older Unicode tables than Python 3.12. Characters added in recent Unicode versions, such as U+9FEF, can therefore classify differently. Core create-new-feature.ps1 behaves the same way.
Testing
All commands below were run by Claude Code on my machine. Environment: Windows 11 zh-CN (code page 936), Python 3.12.10, Windows PowerShell 5.1, Git Bash 5.2. Linux runs used Ubuntu 24.04 on WSL2 with Python 3.12.3.
Tested locally with .\.venv\Scripts\specify.exe --help.
Ran the affected tests: python -m pytest tests/extensions/git -q.
Linux (Ubuntu 24.04 on WSL2): 179 passed, 110 skipped (pwsh is not installed there, so the PowerShell cases skip).
Linux, new tests against main's scripts: all 13 new bash/Python cases fail. They are cjk_only, cjk_mixed, cjk_acronyms, accented, cjk_short_name, a real branch checkout, {author}/{app} staying ASCII (from a project directory named Café 应用), Python lookup with core / git-common.sh only / an older core common.sh without _python3_command, and three truncation cases.
Windows with Git Bash (MSYS) as bash: the full run gave 202 passed, 3 failed, 84 skipped. Two of the failures were the astral truncation cases, caused by the test helper decoding the Python twin's cp936 stderr; after the _run_py fix below, both pass on a re-run. The remaining failure, test_git_branch_name_override_persist_hint_matches_bash, also fails on main (the git error message embeds the bash and Python temp paths, which differ).
Windows default (bash resolves to the WSL launcher, so bash cases skip): the 7 new Windows PowerShell 5.1 tests pass, and all 7 fail against main's script. The 5 other failures in this suite are in initialize-repo tests and also fail on main. Their assertions expect English PowerShell output, and the zh-CN host prints 警告:.
Test helpers: _run_bash and _branch_state now decode as UTF-8, and _run_py replaces undecodable bytes. Without this, a cp936 or cp1252 console decoded the UTF-8 branch names wrongly before the tests could compare them.
Tested with a sample project. Ran specify init "待办 应用" --integration claude --script ps --extension git in a directory with a Chinese name and a space. Then ran the git extension and core feature scripts in PowerShell 5.1 and Git Bash with Chinese descriptions. The branch and specs/ directory names now match.
On Git Bash, checked six truncation inputs (a + 𠀀×70, ab + 𠀀×70, 汉×100, ab + 汉×100, é×130, 𠀀×70). All three twins produce the same name of 244 bytes or fewer.
Ruff reports no new findings on the changed Python files. shellcheck --severity=error (as in CI) passes; overall shellcheck findings went from 9 to 8.
AI Disclosure
I did not use AI assistance for this contribution
I did use AI assistance (fill in the disclosure below)
AI disclosure: Claude Code (model: Claude Opus 5.5, extended thinking, human-supervised) found and reproduced the bug and generated the code and tests in this PR. Two review subagents, also Claude models, reviewed the diff for correctness and for security and scope. One of them found the Git Bash truncation bug, which Claude Code then reproduced and fixed. I reviewed the full diff before filing. The commit carries an Assisted-by: trailer.
The git extension's branch scripts still sanitized names with [^a-z0-9],
so a CJK-only description produced the branch 001- while the core script
created specs/001-<name>/. Port the core scripts' UTF-8 naming policy
(github#4574, github#4780) to the bash, PowerShell, and Python twins:
- keep Unicode letters and decimal digits; lowercase ASCII letters only
- keep short non-ASCII words (CJK words are often two characters)
- leave {author} and {app} template tokens ASCII-only, as before
- bash: classify Unicode via Python and pick a UTF-8 locale, mirroring
core create-new-feature.sh; truncate to 244 bytes by whole UTF-8
characters, since MSYS/Cygwin bash's 16-bit wchar_t lets ${var%?}
split characters outside the BMP
- PowerShell: guard the fallback join with @() so punctuation-only input
no longer throws on [string]::Join($null); drop whole surrogate pairs
when truncating
Bump the git extension to 1.0.10.
Assisted-by: Claude Code (model: Claude Opus 5.5, supervised)
- bash: quote the SPECIFY_FEATURE persist hint with shell_quote, as core
create-new-feature.sh does, instead of printf %q. Outside a UTF-8
locale (the macOS default) %q escaped each non-ASCII byte as $'\ooo',
so stderr was not valid UTF-8 and test_unicode_branch_is_created_and_
checked_out failed on macOS CI.
- Python: quote the POSIX hint with shlex.quote to stay byte-identical
with the bash twin.
- tests: cover Unicode names with no Python 3 available and with an
explicit LC_ALL=C/POSIX (clear error, exit 1, empty stdout, refs
unchanged, ASCII still succeeds), and the persist hint without a
UTF-8 locale. Addresses the Copilot review.
Assisted-by: Claude Code (model: Claude Opus 5.5, supervised)
Posted on behalf of @ckr-git by Claude Code (model: Claude Opus 5.5, extended thinking, human-supervised). Claude Code wrote the fix, the tests, and this summary; @ckr-git reviewed them before posting.
Copilot feedback (missing-Python and non-UTF-8 locale paths). Added bash tests for both failure paths, for a Unicode description and for --short-name:
No Python 3: python3, python, and py are shimmed to fail. The script exits 1 with "Python 3 is required to create a Unicode branch name", prints nothing on stdout, and leaves git refs unchanged. An ASCII description still succeeds under the same shims.
Explicit LC_ALL=C and LC_ALL=POSIX: the script exits 1 with "A UTF-8 locale is required ... LC_ALL=", with empty stdout and refs unchanged. ASCII still succeeds.
macOS CI failure.test_unicode_branch_is_created_and_checked_out failed on macOS because bash's stderr was not valid UTF-8. The persist hint used printf %q, which outside a UTF-8 locale escapes each non-ASCII byte as $'\ooo'. The hint now uses shell_quote, copied from core create-new-feature.sh, and the Python twin uses shlex.quote, as core create_new_feature.py does. Both produce identical output. A new test runs with an empty locale and checks the hint is export SPECIFY_FEATURE='001-添加待办事项'. The Windows jobs in that run were cancelled after the macOS failure, not failed.
Results with this commit:
Linux: 184 passed, 110 skipped. Against main's scripts, all 18 new bash/Python cases fail.
Windows with Git Bash: 209 passed, 1 failed. The failure is test_git_branch_name_override_persist_hint_matches_bash, which also fails on main locally.
shellcheck --severity=error and ruff report nothing new.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The git-extension tests lack coverage for Unicode decimal-digit preservation and rejection of other number categories across the three implementations, including Windows PowerShell 5.1.
The new decimal-digit policy has no coverage in the git-extension tests: the added Unicode cases all use letters. Please port the core tests/test_create_new_feature_python_parity.py::test_unicode_number_categories_match cases into the extension tests, checking that x٥ and x𝟘 are retained while x² and xⅫ become x. Run these cases across the three twins, including Windows PowerShell 5.1, so decimal-digit preservation and rejection of other number categories are both protected.
AI-generated review for the requesting reviewer by GitHub Copilot (model: unknown; autonomous mode; code inspection).
Port core's test_unicode_number_categories_match cases to the git
extension for bash, Python, and Windows PowerShell 5.1: decimal digits
(x٥, x𝟘) are kept, while other number categories (x², xⅫ) become
separators. Addresses the Copilot review.
Assisted-by: Claude Code (model: Claude Opus 5.5, supervised)
Posted on behalf of @ckr-git by Claude Code (model: Claude Opus 5.5, extended thinking, human-supervised). Claude Code wrote the tests and this summary; @ckr-git reviewed them before posting.
Copilot feedback (Unicode number categories). Ported the core test_unicode_number_categories_match cases to the git extension. They run for bash and Python (parity) and separately for Windows PowerShell 5.1 (and pwsh where available):
x٥ → 001-x٥ and x𝟘 → 001-x𝟘 (decimal digits are kept, including outside the BMP).
x² → 001-x and xⅫ → 001-x (other number categories become separators).
The scripts already behaved this way, so this commit adds tests only. Against main's scripts, the two decimal-digit cases fail in all three twins and the two separator cases pass, as expected.
The earlier Copilot item (missing-Python and non-UTF-8 locale paths) was addressed in 22299d8; see the round 1 summary above.
Results with this commit:
Linux: 188 passed, 118 skipped.
Windows PowerShell 5.1: the 4 new cases pass. The full git extension suite has no new failures; the 5 existing initialize-repo failures on a zh-CN host also fail on main.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Under limited output encodings, Unicode branch names become literal escapes in the persistence hint, so copying it selects a nonexistent feature instead of the newly created branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
triage-must-haveVerdict: high-value, important work for Spec Kit — do first
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #5553.
The git extension's branch scripts (bash, PowerShell, Python) still sanitized names with
[^a-z0-9]. With the git extension installed, thebefore_specifyhook turned a CJK-only description into the branch001-, while the core script createdspecs/001-添加待办事项/. #4780 fixed the core scripts under the UTF-8 naming policy from #4574 and leftextensions/gitout of scope. This PR ports the same policy to the three extension twins.添加待办事项001-/001-/ error001-添加待办事项支持 OAuth2 登录001-oauth2001-支持-oauth2-登录Ünïcödé café001-caf001-Ünïcödé-caféAdd API for 用户 DB001-api-db001-api-用户-db--short-name "待办 事项!"001-001-待办-事项Add the user login(ASCII)001-user-login001-user-login(unchanged)Changes:
create-new-feature.*, and the extension output now matches the core script for the inputs above.{author}and{app}. These template tokens stay ASCII-only. Each script has a separate ASCII cleaner for them, so their behavior does not change.create-new-feature.sh. The script probes for Python itself (SPECKIT_PYTHON_EXECUTABLE,python3,python,py -3), so it still works when onlygit-common.shis loaded or corecommon.shpredates_python3_command. An explicit non-UTF-8LC_ALLwith Unicode input gives a clear error. ASCII input stays shell-only and needs no Python.LC_ALL=C. On Git Bash for Windows (MSYS, 16-bitwchar_t), the locale-aware${var%?}split a character outside the BMP when an odd-length ASCII prefix came first. For example,afollowed by 70 copies of𠀀produced a broken 244-byte name ending in➳. Corefit_branch_namehas the same problem: with that input it returns a name ending in U+FFFD on Git Bash. Core is left unchanged to keep this PR in scope; I can follow up separately if you want.@(), so punctuation-only input such as!!!no longer throws from[string]::Join($null). Core already does this. Onmainthe same crash also blocked every CJK-only description. Truncation drops whole surrogate pairs.extension.ymlandcatalog.json, and the README documents the naming.Known limitation, inherited from core: Windows PowerShell 5.1 (.NET Framework) uses older Unicode tables than Python 3.12. Characters added in recent Unicode versions, such as U+9FEF, can therefore classify differently. Core
create-new-feature.ps1behaves the same way.Testing
All commands below were run by Claude Code on my machine. Environment: Windows 11 zh-CN (code page 936), Python 3.12.10, Windows PowerShell 5.1, Git Bash 5.2. Linux runs used Ubuntu 24.04 on WSL2 with Python 3.12.3.
.\.venv\Scripts\specify.exe --help.python -m pytest tests/extensions/git -q.main's scripts: all 13 new bash/Python cases fail. They arecjk_only,cjk_mixed,cjk_acronyms,accented,cjk_short_name, a real branch checkout,{author}/{app}staying ASCII (from a project directory namedCafé 应用), Python lookup with core /git-common.shonly / an older corecommon.shwithout_python3_command, and three truncation cases.bash: the full run gave 202 passed, 3 failed, 84 skipped. Two of the failures were the astral truncation cases, caused by the test helper decoding the Python twin's cp936 stderr; after the_run_pyfix below, both pass on a re-run. The remaining failure,test_git_branch_name_override_persist_hint_matches_bash, also fails onmain(the git error message embeds the bash and Python temp paths, which differ).main's script. The 5 other failures in this suite are ininitialize-repotests and also fail onmain. Their assertions expect English PowerShell output, and the zh-CN host prints警告:._run_bashand_branch_statenow decode as UTF-8, and_run_pyreplaces undecodable bytes. Without this, a cp936 or cp1252 console decoded the UTF-8 branch names wrongly before the tests could compare them.specify init "待办 应用" --integration claude --script ps --extension gitin a directory with a Chinese name and a space. Then ran the git extension and core feature scripts in PowerShell 5.1 and Git Bash with Chinese descriptions. The branch andspecs/directory names now match.a+𠀀×70,ab+𠀀×70,汉×100,ab+汉×100,é×130,𠀀×70). All three twins produce the same name of 244 bytes or fewer.shellcheck --severity=error(as in CI) passes; overall shellcheck findings went from 9 to 8.AI Disclosure
AI disclosure: Claude Code (model: Claude Opus 5.5, extended thinking, human-supervised) found and reproduced the bug and generated the code and tests in this PR. Two review subagents, also Claude models, reviewed the diff for correctness and for security and scope. One of them found the Git Bash truncation bug, which Claude Code then reproduced and fixed. I reviewed the full diff before filing. The commit carries an
Assisted-by:trailer.