fix(scripts): portable uppercase for branch-name acronym retention (bash 3.2)#3192
Open
PascalThuet wants to merge 2 commits into
Open
fix(scripts): portable uppercase for branch-name acronym retention (bash 3.2)#3192PascalThuet wants to merge 2 commits into
PascalThuet wants to merge 2 commits into
Conversation
Branch-name generation keeps short uppercase acronyms (e.g. "AI") by re-checking
the lowercased word against the original description with ${word^^}. That
parameter expansion is bash 4+ only; on macOS's default bash 3.2 it errors with
"bad substitution", so the acronym/short-word retention branch never matches and
those words are dropped ("go AI now" yields 001-now instead of 001-ai-now). Use
tr '[:lower:]' '[:upper:]' instead, which is portable.
Applies to both the core create-new-feature.sh and the git extension's
create-new-feature-branch.sh. The existing
test_branch_name_short_word_case_sensitivity / test_short_word_retention tests
cover this and now pass on bash 3.2 (CI runs on bash 4+/Linux, so they passed
there already).
(Disclosure: an AI coding agent surfaced the failure while running the suite on
macOS and pinned the root cause; fix written and reviewed by me.)
- core create-new-feature.sh: match the acronym with `grep -qw` (POSIX whole-word) instead of `\b...\b` (GNU/BSD-only), matching the git extension and dropping a non-POSIX construct. - lint: add a CI guard rejecting bash 4+ case-modification expansions in *.sh. shellcheck assumes bash 4+ from the shebang and can't flag them, and CI has no bash-3.2 lane, so this prevents silently re-shipping the macOS regression this PR fixes. - update a stale PowerShell extension comment that cited the removed bash idiom. (Disclosure: prompted by an AI code review of the PR; written and reviewed by me.)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Branch-name generation keeps short uppercase acronyms (e.g.
AI) by re-checking the lowercased word against the original description with${word^^}. That parameter expansion is bash 4+ only; on macOS's default bash 3.2 it errors withbad substitution, so the acronym / short-word retention branch never matches and those words are silently dropped (go AI nowyields001-nowinstead of001-ai-now).Replace
${word^^}withtr '[:lower:]' '[:upper:]', which is portable. Applies to both the corescripts/bash/create-new-feature.shand the git extension'sextensions/git/scripts/bash/create-new-feature-branch.sh. No behavior change on bash 4+.CI runs on bash 4+/Linux, so the existing tests passed there; the bug only shows on the default macOS shell.
Testing
test_branch_name_short_word_case_sensitivityandtest_short_word_retention[go AI now-001-ai-now]now pass (they failed before this fix).test_timestamp_branches,test_git_extension,test_branch_numbering(99 passed, 35 skipped).shellcheck --severity=errorclean on both scripts.AI Disclosure
An AI coding agent surfaced the failing tests while running the suite on macOS and pinned the root cause (
${word^^}vs bash 3.2); the fix was written and reviewed by me.