fix: accept 3-char all-letter base36 hashes in ExtractIssuePrefix (#446)
isLikelyHash() required at least one digit to distinguish hashes from
English words, but base36 hashes can be all-letters by chance.
This caused ExtractIssuePrefix("xa-adt-bat") to return "xa" instead
of "xa-adt", breaking import for 20 issues in xa-adapt.
Fix: Accept all-letter suffixes for 3-char only, keep digit requirement
for 4+ chars where word collision probability is low enough (~0.2%).
Rationale:
- 3-char: 36³ = 46K hashes, ~1000 common words = ~2% collision
- 4-char: 36⁴ = 1.6M hashes, ~3000 words = ~0.2% collision
- 5+ char: collision rate negligible
This commit is contained in:
@@ -413,9 +413,9 @@ func TestExtractIssuePrefix(t *testing.T) {
|
||||
expected: "my-cool-app", // 3-char base36 hash
|
||||
},
|
||||
{
|
||||
name: "3-char all-letters suffix (should fall back to first hyphen)",
|
||||
name: "3-char all-letters suffix (now treated as hash, GH #446)",
|
||||
issueID: "test-proj-abc",
|
||||
expected: "test", // All letters = not a hash, falls back to first hyphen
|
||||
expected: "test-proj", // 3-char all-letter now accepted as hash (GH #446)
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user