mirror of
https://github.com/go-task/task.git
synced 2026-06-16 04:11:40 +00:00
feat: taskfile mutex for adding edge data
This commit is contained in:
@@ -3,6 +3,7 @@ package ast
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/dominikbraun/graph"
|
||||
"github.com/dominikbraun/graph/draw"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type TaskfileGraph struct {
|
||||
sync.Mutex
|
||||
graph.Graph[string, *TaskfileVertex]
|
||||
}
|
||||
|
||||
@@ -25,6 +27,7 @@ func taskfileHash(vertex *TaskfileVertex) string {
|
||||
|
||||
func NewTaskfileGraph() *TaskfileGraph {
|
||||
return &TaskfileGraph{
|
||||
sync.Mutex{},
|
||||
graph.New(taskfileHash,
|
||||
graph.Directed(),
|
||||
graph.PreventCycles(),
|
||||
|
||||
@@ -140,6 +140,8 @@ func (r *Reader) include(node Node) error {
|
||||
}
|
||||
|
||||
// Create an edge between the Taskfiles
|
||||
r.graph.Lock()
|
||||
defer r.graph.Unlock()
|
||||
edge, err := r.graph.Edge(node.Location(), includeNode.Location())
|
||||
if err == graph.ErrEdgeNotFound {
|
||||
// If the edge doesn't exist, create it
|
||||
|
||||
Reference in New Issue
Block a user