fix(import): support hierarchical hash IDs in --rename-on-import

The isNumeric function was rejecting valid hierarchical hash IDs like
'6we.2' that contain dots for parent.child notation. This caused
`bd import --rename-on-import` to fail with "non-numeric suffix" errors.

Changes:
- Rename isNumeric to isValidIDSuffix for clarity
- Accept dots (.) in addition to alphanumeric for hierarchical IDs
- Update test cases to cover hierarchical ID formats
This commit is contained in:
Ryan Snodgrass
2025-12-16 00:12:10 -08:00
parent fa566a9700
commit c7b45a8a40
3 changed files with 895 additions and 246 deletions

View File

@@ -524,7 +524,7 @@ func TestIsBoundary(t *testing.T) {
}
}
func TestIsNumeric(t *testing.T) {
func TestIsValidIDSuffix(t *testing.T) {
tests := []struct {
s string
want bool
@@ -538,18 +538,24 @@ func TestIsNumeric(t *testing.T) {
{"09ea", true},
{"abc123", true},
{"zzz", true},
// Hierarchical suffixes (hash.number format)
{"6we.2", true},
{"abc.1", true},
{"abc.1.2", true},
{"abc.1.2.3", true},
{"1.5", true},
// Invalid suffixes
{"", false}, // Empty string now returns false
{"1.5", false}, // Non-base36 characters
{"A3F8", false}, // Uppercase not allowed
{"@#$!", false}, // Special characters not allowed
{"", false}, // Empty string
{"A3F8", false}, // Uppercase not allowed
{"@#$!", false}, // Special characters not allowed
{"abc-def", false}, // Hyphens not allowed in suffix
}
for _, tt := range tests {
t.Run(tt.s, func(t *testing.T) {
got := isNumeric(tt.s)
got := isValidIDSuffix(tt.s)
if got != tt.want {
t.Errorf("isNumeric(%q) = %v, want %v", tt.s, got, tt.want)
t.Errorf("isValidIDSuffix(%q) = %v, want %v", tt.s, got, tt.want)
}
})
}