feat: Use base36 encoding for shorter polecat branch names

This commit is contained in:
Steve Yegge
2025-12-30 10:20:32 -08:00
parent 08d966a601
commit be979c66a2

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"
@@ -181,7 +182,8 @@ func (m *Manager) Add(name string) (*Polecat, error) {
polecatPath := m.polecatDir(name)
// Unique branch per run - prevents drift from stale branches
branchName := fmt.Sprintf("polecat/%s-%d", name, time.Now().UnixMilli())
// Use base36 encoding for shorter branch names (8 chars vs 13 digits)
branchName := fmt.Sprintf("polecat/%s-%s", name, strconv.FormatInt(time.Now().UnixMilli(), 36))
// Create polecats directory if needed
polecatsDir := filepath.Join(m.rig.Path, "polecats")
@@ -408,7 +410,8 @@ func (m *Manager) Recreate(name string, force bool) (*Polecat, error) {
// Create fresh worktree with unique branch name
// Old branches are left behind - they're ephemeral (never pushed to origin)
// and will be cleaned up by garbage collection
branchName := fmt.Sprintf("polecat/%s-%d", name, time.Now().UnixMilli())
// Use base36 encoding for shorter branch names (8 chars vs 13 digits)
branchName := fmt.Sprintf("polecat/%s-%s", name, strconv.FormatInt(time.Now().UnixMilli(), 36))
if err := repoGit.WorktreeAdd(polecatPath, branchName); err != nil {
return nil, fmt.Errorf("creating fresh worktree: %w", err)
}