Merge merges the second Taskfile into the first
(t2 *Taskfile, include *Include)
| 39 | |
| 40 | // Merge merges the second Taskfile into the first |
| 41 | func (t1 *Taskfile) Merge(t2 *Taskfile, include *Include) error { |
| 42 | if !t1.Version.Equal(t2.Version) { |
| 43 | return fmt.Errorf(`task: Taskfiles versions should match. First is "%s" but second is "%s"`, t1.Version, t2.Version) |
| 44 | } |
| 45 | if len(t2.Dotenv) > 0 { |
| 46 | return ErrIncludedTaskfilesCantHaveDotenvs |
| 47 | } |
| 48 | if t2.Output.IsSet() { |
| 49 | t1.Output = t2.Output |
| 50 | } |
| 51 | if t1.Includes == nil { |
| 52 | t1.Includes = NewIncludes() |
| 53 | } |
| 54 | if t1.Vars == nil { |
| 55 | t1.Vars = NewVars() |
| 56 | } |
| 57 | if t1.Env == nil { |
| 58 | t1.Env = NewVars() |
| 59 | } |
| 60 | if t1.Tasks == nil { |
| 61 | t1.Tasks = NewTasks() |
| 62 | } |
| 63 | if t2.Silent { |
| 64 | for _, t := range t2.Tasks.All(nil) { |
| 65 | if t.Silent == nil { |
| 66 | v := true |
| 67 | t.Silent = &v |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | if t2.UseGitignore != nil { |
| 72 | for _, t := range t2.Tasks.All(nil) { |
| 73 | if t.UseGitignore == nil { |
| 74 | v := *t2.UseGitignore |
| 75 | t.UseGitignore = &v |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | t1.Vars.Merge(t2.Vars, include) |
| 80 | t1.Env.Merge(t2.Env, include) |
| 81 | return t1.Tasks.Merge(t2.Tasks, include, t1.Vars) |
| 82 | } |
| 83 | |
| 84 | func (tf *Taskfile) UnmarshalYAML(node *yaml.Node) error { |
| 85 | switch node.Kind { |
nothing calls this directly
no test coverage detected