MCPcopy
hub / github.com/six2dez/OneListForAll / Run

Function Run

internal/update/update.go:29–65  ·  view source on GitHub ↗
(opts Options)

Source from the content-addressed store, hash-verified

27}
28
29func Run(opts Options) ([]SourceResult, error) {
30 cfg, err := config.Load(opts.ConfigPath)
31 if err != nil {
32 return nil, err
33 }
34
35 selected := make([]config.Source, 0, len(cfg.Sources))
36 for _, s := range cfg.Sources {
37 if opts.SourceName == "" || s.Name == opts.SourceName {
38 selected = append(selected, s)
39 }
40 }
41 if len(selected) == 0 {
42 return nil, fmt.Errorf("no sources matched %q", opts.SourceName)
43 }
44
45 if err := os.MkdirAll("sources", 0o755); err != nil {
46 return nil, fmt.Errorf("create sources dir: %w", err)
47 }
48
49 results := make([]SourceResult, 0, len(selected))
50 for _, src := range selected {
51 r, err := syncSource(src, opts.DryRun)
52 if err != nil {
53 return nil, err
54 }
55 results = append(results, r)
56 }
57
58 if !opts.DryRun {
59 if err := writeLock(results, cfg); err != nil {
60 return nil, err
61 }
62 }
63
64 return results, nil
65}
66
67func syncSource(src config.Source, dryRun bool) (SourceResult, error) {
68 repoDir := filepath.Join("sources", src.Name)

Callers 2

runUpdateFunction · 0.92
runPipelineFunction · 0.92

Calls 3

LoadFunction · 0.92
syncSourceFunction · 0.85
writeLockFunction · 0.85

Tested by

no test coverage detected