@@ -7,40 +7,17 @@ import (
77 "strings"
88)
99
10+ // Workspace captures the repository snapshot and working directory that an etch
11+ // invocation reasons about. All process, Git, and filesystem effects are routed
12+ // through its private dependency bundle.
1013type Workspace struct {
1114 CWD string
1215 Root string
1316 Head string
1417 Ref string
1518 Unborn bool
1619 Untracked bool
17- git gitRunner
18- worktree workingTreeFS
19- temp workspaceTempStore
20- paths workspacePaths
21- }
22-
23- type workspaceDeps struct {
24- git gitRunner
25- worktree workingTreeFS
26- temp workspaceTempStore
27- paths workspacePaths
28- }
29-
30- func (d workspaceDeps ) withDefaults () workspaceDeps {
31- if d .git == nil {
32- d .git = realGitRunner {}
33- }
34- if d .worktree == nil {
35- d .worktree = osWorkingTreeFS {}
36- }
37- if d .temp == nil {
38- d .temp = osWorkspaceTempStore {}
39- }
40- if d .paths == nil {
41- d .paths = osWorkspacePaths {}
42- }
43- return d
20+ deps workspaceDeps
4421}
4522
4623// OpenWorkspace opens the process working directory. Prefer OpenWorkspaceAt
@@ -58,6 +35,7 @@ func openWorkspace(untracked bool, deps workspaceDeps) (*Workspace, error) {
5835 return openWorkspaceAt (cwd , untracked , deps )
5936}
6037
38+ // OpenWorkspaceAt opens the Git worktree containing cwd.
6139func OpenWorkspaceAt (cwd string , untracked bool ) (* Workspace , error ) {
6240 return openWorkspaceAt (cwd , untracked , workspaceDeps {})
6341}
@@ -95,7 +73,7 @@ func openWorkspaceAt(cwd string, untracked bool, deps workspaceDeps) (*Workspace
9573 if err == nil {
9674 ref = strings .TrimSpace (string (refBytes ))
9775 }
98- return & Workspace {CWD : cwd , Root : root , Head : head , Ref : ref , Unborn : unborn , Untracked : untracked , git : deps . git , worktree : deps . worktree , temp : deps . temp , paths : deps . paths }, nil
76+ return & Workspace {CWD : cwd , Root : root , Head : head , Ref : ref , Unborn : unborn , Untracked : untracked , deps : deps }, nil
9977}
10078
10179type ResolvedPath struct {
0 commit comments