51cc14d028
* refactor(worktree): drop unused flat-layout worktrees/ path
Every worktree creation now routes through the task-dir layout
(~/.kandev/tasks/{title}_{suffix}/{repo}/); the legacy flat layout
under ~/.kandev/worktrees/ has been unreachable since the subtasks
PR populated TaskDirName/RepoName unconditionally. Removes the dead
Config.BasePath, Manager.createWorktree, and the flat reconciler.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* refactor(worktree): remove unused Reconcile, add guard regression test
Address PR review feedback:
- Reconcile (and reconcileTasksDir / isOrphanedTaskDir) had no callers
anywhere in the tree after the flat-layout removal. Deleted rather than
left dangling; if startup orphan cleanup is wired up later it can return
alongside its actual call site. Also moots the stale doc comment that
CodeRabbit flagged.
- Add TestCreate_MissingTaskDirFields_ReturnsErrTaskDirRequired covering
the three permutations (missing RepoName, missing TaskDirName, both
missing) so a regression in the ErrTaskDirRequired guard surfaces in
CI rather than silently.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
29 lines
851 B
Go
29 lines
851 B
Go
package worktree
|
|
|
|
import (
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
"github.com/kandev/kandev/internal/common/config"
|
|
"github.com/kandev/kandev/internal/common/logger"
|
|
)
|
|
|
|
// Provide creates the worktree manager using separate writer and reader pools.
|
|
func Provide(writer, reader *sqlx.DB, cfg *config.Config, log *logger.Logger) (*Manager, func() error, error) {
|
|
store, err := NewSQLiteStore(writer, reader)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
wtCfg := Config{
|
|
Enabled: cfg.Worktree.Enabled,
|
|
BranchPrefix: "kandev/",
|
|
FetchTimeoutSeconds: cfg.Worktree.FetchTimeoutSeconds,
|
|
PullTimeoutSeconds: cfg.Worktree.PullTimeoutSeconds,
|
|
}
|
|
wtCfg.SetTasksBasePathFallback(cfg.ResolvedHomeDir())
|
|
manager, err := NewManager(wtCfg, store, log)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
return manager, func() error { return nil }, nil
|
|
}
|