1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

merge preconditions

This commit is contained in:
Valentin Maerten
2025-01-07 21:05:43 +01:00
parent 596fd29cb2
commit 16ac79c561
2 changed files with 15 additions and 1 deletions

View File

@@ -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 { func (p *Precondition) DeepCopy() *Precondition {
if p == nil { if p == nil {
return nil return nil

View File

@@ -65,7 +65,7 @@ func (t1 *Taskfile) Merge(t2 *Taskfile, include *Include) error {
} }
t1.Vars.Merge(t2.Vars, include) t1.Vars.Merge(t2.Vars, include)
t1.Env.Merge(t2.Env, 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) return t1.Tasks.Merge(t2.Tasks, include, t1.Vars)
} }