MCPcopy Index your code
hub / github.com/go-task/task / Merge

Method Merge

taskrc/ast/taskrc.go:39–75  ·  view source on GitHub ↗

Merge combines the current TaskRC with another TaskRC, prioritizing non-nil fields from the other TaskRC.

(other *TaskRC)

Source from the content-addressed store, hash-verified

37
38// Merge combines the current TaskRC with another TaskRC, prioritizing non-nil fields from the other TaskRC.
39func (t *TaskRC) Merge(other *TaskRC) {
40 if other == nil {
41 return
42 }
43
44 t.Version = cmp.Or(other.Version, t.Version)
45
46 if t.Experiments == nil && other.Experiments != nil {
47 t.Experiments = other.Experiments
48 } else if t.Experiments != nil && other.Experiments != nil {
49 maps.Copy(t.Experiments, other.Experiments)
50 }
51
52 // Merge Remote fields
53 t.Remote.Insecure = cmp.Or(other.Remote.Insecure, t.Remote.Insecure)
54 t.Remote.Offline = cmp.Or(other.Remote.Offline, t.Remote.Offline)
55 t.Remote.Timeout = cmp.Or(other.Remote.Timeout, t.Remote.Timeout)
56 t.Remote.CacheExpiry = cmp.Or(other.Remote.CacheExpiry, t.Remote.CacheExpiry)
57 t.Remote.CacheDir = cmp.Or(other.Remote.CacheDir, t.Remote.CacheDir)
58 if len(other.Remote.TrustedHosts) > 0 {
59 merged := slices.Concat(other.Remote.TrustedHosts, t.Remote.TrustedHosts)
60 slices.Sort(merged)
61 t.Remote.TrustedHosts = slices.Compact(merged)
62 }
63 t.Remote.CACert = cmp.Or(other.Remote.CACert, t.Remote.CACert)
64 t.Remote.Cert = cmp.Or(other.Remote.Cert, t.Remote.Cert)
65 t.Remote.CertKey = cmp.Or(other.Remote.CertKey, t.Remote.CertKey)
66
67 t.Verbose = cmp.Or(other.Verbose, t.Verbose)
68 t.Silent = cmp.Or(other.Silent, t.Silent)
69 t.Color = cmp.Or(other.Color, t.Color)
70 t.DisableFuzzy = cmp.Or(other.DisableFuzzy, t.DisableFuzzy)
71 t.Concurrency = cmp.Or(other.Concurrency, t.Concurrency)
72 t.Interactive = cmp.Or(other.Interactive, t.Interactive)
73 t.Failfast = cmp.Or(other.Failfast, t.Failfast)
74 t.TempDir = cmp.Or(other.TempDir, t.TempDir)
75}

Callers 2

GetConfigFunction · 0.95

Calls

no outgoing calls

Tested by 1