1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package storage
import (
"os/exec"
"strings"
"github.com/thepeterstone/claudomator/internal/task"
)
// SeedProjects upserts the default project registry on startup.
func (s *DB) SeedProjects() error {
projects := []*task.Project{
{
ID: "claudomator",
Name: "claudomator",
LocalPath: "/workspace/claudomator",
RemoteURL: localBareRemote("/workspace/claudomator"),
Type: "web",
},
{
ID: "nav",
Name: "nav",
LocalPath: "/workspace/nav",
RemoteURL: localBareRemote("/workspace/nav"),
Type: "android",
},
}
for _, p := range projects {
if err := s.UpsertProject(p); err != nil {
return err
}
}
return nil
}
// localBareRemote returns the URL of the "local" git remote for dir,
// falling back to dir itself if the remote is not configured.
func localBareRemote(dir string) string {
out, err := exec.Command("git", "-C", dir, "remote", "get-url", "local").Output()
if err == nil {
if url := strings.TrimSpace(string(out)); url != "" {
return url
}
}
return dir
}
|