diff --git a/taskfile/ast/precondition.go b/taskfile/ast/precondition.go index 9d8ad80f..69ca5f00 100644 --- a/taskfile/ast/precondition.go +++ b/taskfile/ast/precondition.go @@ -40,6 +40,20 @@ func (p *Preconditions) DeepCopy() *Preconditions { } } +func (p *Preconditions) Merge(other *Preconditions) { + if p == nil || p.Preconditions == nil || other == nil { + return + } + + p.mutex.Lock() + defer p.mutex.Unlock() + + other.mutex.RLock() + defer other.mutex.RUnlock() + + p.Preconditions = append(p.Preconditions, deepcopy.Slice(other.Preconditions)...) +} + func (p *Precondition) DeepCopy() *Precondition { if p == nil { return nil diff --git a/taskfile/ast/taskfile.go b/taskfile/ast/taskfile.go index 98e2fce3..988ae216 100644 --- a/taskfile/ast/taskfile.go +++ b/taskfile/ast/taskfile.go @@ -65,7 +65,7 @@ func (t1 *Taskfile) Merge(t2 *Taskfile, include *Include) error { } t1.Vars.Merge(t2.Vars, include) t1.Env.Merge(t2.Env, include) - // TODO:@vmaerten Merge precondition + t1.Preconditions.Merge(t2.Preconditions) return t1.Tasks.Merge(t2.Tasks, include, t1.Vars) }