File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,9 +124,10 @@ check_feature_branch() {
124124 return 0
125125 fi
126126
127- # Accept sequential prefix (3+ digits) but exclude malformed timestamps (7-digit date + 6-digit time)
127+ # Accept sequential prefix (3+ digits) but exclude malformed timestamps
128+ # Malformed: 7-or-8 digit date + 6-digit time with no trailing slug (e.g. "2026031-143022" or "20260319-143022")
128129 local is_sequential=false
129- if [[ " $branch " =~ ^[0-9]{3,}- ]] && [[ ! " $branch " =~ ^[0-9]{7}-[0-9]{6}- ]]; then
130+ if [[ " $branch " =~ ^[0-9]{3,}- ]] && [[ ! " $branch " =~ ^[0-9]{7}-[0-9]{6}- ]] && [[ ! " $branch " =~ ^[0-9]{7,8}-[0-9]{6}$ ]] ; then
130131 is_sequential=true
131132 fi
132133 if [[ " $is_sequential " != " true" ]] && [[ ! " $branch " =~ ^[0-9]{8}-[0-9]{6}- ]]; then
Original file line number Diff line number Diff line change @@ -139,8 +139,10 @@ function Test-FeatureBranch {
139139 return $true
140140 }
141141
142- # Accept sequential prefix (3+ digits) but exclude malformed timestamps (7-digit date + 6-digit time)
143- $isSequential = ($Branch -match ' ^[0-9]{3,}-' ) -and ($Branch -notmatch ' ^[0-9]{7}-[0-9]{6}-' )
142+ # Accept sequential prefix (3+ digits) but exclude malformed timestamps
143+ # Malformed: 7-or-8 digit date + 6-digit time with no trailing slug (e.g. "2026031-143022" or "20260319-143022")
144+ $hasMalformedTimestamp = ($Branch -match ' ^[0-9]{7}-[0-9]{6}-' ) -or ($Branch -match ' ^(?:\d{7}|\d{8})-\d{6}$' )
145+ $isSequential = ($Branch -match ' ^[0-9]{3,}-' ) -and (-not $hasMalformedTimestamp )
144146 if (-not $isSequential -and $Branch -notmatch ' ^\d{8}-\d{6}-' ) {
145147 Write-Output " ERROR: Not on a feature branch. Current branch: $Branch "
146148 Write-Output " Feature branches should be named like: 001-feature-name, 1234-feature-name, or 20260319-143022-feature-name"
Original file line number Diff line number Diff line change @@ -196,6 +196,16 @@ def test_rejects_partial_timestamp(self):
196196 result = source_and_call ('check_feature_branch "2026031-143022-feat" "true"' )
197197 assert result .returncode != 0
198198
199+ def test_rejects_timestamp_without_slug (self ):
200+ """check_feature_branch rejects timestamp-like branch missing trailing slug."""
201+ result = source_and_call ('check_feature_branch "20260319-143022" "true"' )
202+ assert result .returncode != 0
203+
204+ def test_rejects_7digit_timestamp_without_slug (self ):
205+ """check_feature_branch rejects 7-digit date + 6-digit time without slug."""
206+ result = source_and_call ('check_feature_branch "2026031-143022" "true"' )
207+ assert result .returncode != 0
208+
199209
200210# ── find_feature_dir_by_prefix Tests ─────────────────────────────────────────
201211
You can’t perform that action at this time.
0 commit comments