Skip to content

Commit

Permalink
merge preconditions
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaerten committed Jan 7, 2025
1 parent 028883e commit 3494378
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions taskfile/ast/precondition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion taskfile/ast/taskfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 3494378

Please sign in to comment.