feat: Use base36 encoding for shorter polecat branch names
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -181,7 +182,8 @@ func (m *Manager) Add(name string) (*Polecat, error) {
|
|||||||
|
|
||||||
polecatPath := m.polecatDir(name)
|
polecatPath := m.polecatDir(name)
|
||||||
// Unique branch per run - prevents drift from stale branches
|
// 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
|
// Create polecats directory if needed
|
||||||
polecatsDir := filepath.Join(m.rig.Path, "polecats")
|
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
|
// Create fresh worktree with unique branch name
|
||||||
// Old branches are left behind - they're ephemeral (never pushed to origin)
|
// Old branches are left behind - they're ephemeral (never pushed to origin)
|
||||||
// and will be cleaned up by garbage collection
|
// 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 {
|
if err := repoGit.WorktreeAdd(polecatPath, branchName); err != nil {
|
||||||
return nil, fmt.Errorf("creating fresh worktree: %w", err)
|
return nil, fmt.Errorf("creating fresh worktree: %w", err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user