46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package lane
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"inbox/internal/base/slug"
|
|
)
|
|
|
|
func DefaultBranchName(workspaceSlug, topicID, laneSlug string) string {
|
|
return "lane/" + runtimeWorkspaceSlug(workspaceSlug) + "/" + runtimeLaneSlug(laneSlug) + "-" + runtimeTopicSuffix(topicID)
|
|
}
|
|
|
|
func DefaultWorktreePath(workspaceRoot, workspaceSlug, topicID, laneSlug string) string {
|
|
return filepath.Join(filepath.Dir(workspaceRoot), runtimeWorkspaceSlug(workspaceSlug)+"--"+runtimeLaneSlug(laneSlug)+"--"+runtimeTopicSuffix(topicID))
|
|
}
|
|
|
|
func DefaultContainerName(workspaceSlug, topicID, laneSlug string) string {
|
|
return "lane-" + runtimeWorkspaceSlug(workspaceSlug) + "-" + runtimeLaneSlug(laneSlug) + "-" + runtimeTopicSuffix(topicID)
|
|
}
|
|
|
|
func runtimeWorkspaceSlug(value string) string {
|
|
if normalized := slug.Normalize(value); normalized != "" {
|
|
return normalized
|
|
}
|
|
return "workspace"
|
|
}
|
|
|
|
func runtimeLaneSlug(value string) string {
|
|
if normalized := slug.Normalize(value); normalized != "" {
|
|
return normalized
|
|
}
|
|
return "lane"
|
|
}
|
|
|
|
func runtimeTopicSuffix(value string) string {
|
|
normalized := slug.Normalize(strings.TrimPrefix(strings.TrimSpace(value), "topic-"))
|
|
if normalized == "" {
|
|
return "topic"
|
|
}
|
|
if len(normalized) > 12 {
|
|
return normalized[len(normalized)-12:]
|
|
}
|
|
return normalized
|
|
}
|