fix(dolt): add YAML fallback for custom types/statuses
When the Dolt database connection is temporarily unavailable (e.g., stale connection, server restart), GetCustomTypes() and GetCustomStatuses() now fall back to reading from config.yaml instead of failing. This matches the SQLite storage behavior and fixes the stop hook failure where `gt costs record` would fail with "invalid issue type: event" when the Dolt connection was broken. The fallback is checked in two cases: 1. When database query returns an error 2. When database has no custom types/statuses configured Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -721,3 +721,30 @@ func GetCustomTypesFromYAML() []string {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// GetCustomStatusesFromYAML retrieves custom statuses from config.yaml.
|
||||
// This is used as a fallback when the database doesn't have status.custom set yet
|
||||
// or when the database connection is temporarily unavailable.
|
||||
// Returns nil if no custom statuses are configured in config.yaml.
|
||||
func GetCustomStatusesFromYAML() []string {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Try to get status.custom from viper (config.yaml or env var)
|
||||
value := v.GetString("status.custom")
|
||||
if value == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parse comma-separated list
|
||||
parts := strings.Split(value, ",")
|
||||
result := make([]string, 0, len(parts))
|
||||
for _, p := range parts {
|
||||
trimmed := strings.TrimSpace(p)
|
||||
if trimmed != "" {
|
||||
result = append(result, trimmed)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user