fix: handle multi-hyphen prefixes correctly (GH#422)

The prefix mismatch detection was using ExtractIssuePrefix() which
tries to guess the prefix by analyzing suffix patterns. This failed
for multi-hyphen prefixes like "asianops-audit-" when issue IDs had
word-like suffixes (e.g., "asianops-audit-test") - the heuristic
would fall back to the first hyphen and report "asianops-" as the
prefix.

Fixed by checking directly if the issue ID starts with the configured
prefix using strings.HasPrefix(). This is more reliable than guessing
since we know the expected prefix from the database config.

Added test case TestImportMultiHyphenPrefix to prevent regression.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-23 16:20:04 -08:00
parent ee3d070d08
commit 3d924f88f3
2 changed files with 93 additions and 2 deletions

View File

@@ -231,8 +231,13 @@ func handlePrefixMismatch(ctx context.Context, sqliteStore *sqlite.SQLiteStorage
var tombstonesToRemove []string
for _, issue := range issues {
prefix := utils.ExtractIssuePrefix(issue.ID)
if !allowedPrefixes[prefix] {
// GH#422: Check if issue ID starts with configured prefix directly
// rather than extracting/guessing. This handles multi-hyphen prefixes
// like "asianops-audit-" correctly.
prefixMatches := strings.HasPrefix(issue.ID, configuredPrefix+"-")
if !prefixMatches {
// Extract prefix for error reporting (best effort)
prefix := utils.ExtractIssuePrefix(issue.ID)
if issue.IsTombstone() {
tombstoneMismatchPrefixes[prefix]++
tombstonesToRemove = append(tombstonesToRemove, issue.ID)