From 17c14ab8d9dccc44bd8556e79e4c5840019d98d5 Mon Sep 17 00:00:00 2001 From: Raphael Vigee Date: Tue, 23 Apr 2024 11:11:09 +0100 Subject: [PATCH] Fix revdeps file --- cmd/heph/query.go | 2 +- graph/dag.go | 28 +++++++++++++++++++++------- targetrun/run.go | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/cmd/heph/query.go b/cmd/heph/query.go index d1bc1a35..3a2515db 100644 --- a/cmd/heph/query.go +++ b/cmd/heph/query.go @@ -642,7 +642,7 @@ var revdepsCmd = &cobra.Command{ return fmt.Errorf("%v is outside repo", p) } - children := bs.Graph.DAG().GetFileChildren([]string{rel}, bs.Graph.Targets().Slice()) + children := bs.Graph.DAG().GetFileChildren([]string{p}, bs.Graph.Targets().Slice()) if err != nil { return err } diff --git a/graph/dag.go b/graph/dag.go index 02931e35..636f44b4 100644 --- a/graph/dag.go +++ b/graph/dag.go @@ -193,13 +193,9 @@ func (d *DAG) GetFileChildren(paths []string, universe []*Target) []*Target { descendants := NewTargets(0) for _, path := range paths { - for _, target := range universe { - for _, file := range target.HashDeps.Files { - if file.RelRoot() == path { - descendants.Add(target) - break - } - } + target := d.getFileChildren(path, universe) + if target != nil { + descendants.Add(target) } } @@ -208,6 +204,24 @@ func (d *DAG) GetFileChildren(paths []string, universe []*Target) []*Target { return descendants.Slice() } +func (d *DAG) getFileChildren(path string, universe []*Target) *Target { + for _, target := range universe { + for _, file := range target.Deps.All().Files { + if file.Abs() == path { + return target + } + } + for _, file := range target.HashDeps.Files { + if file.Abs() == path { + return target + + } + } + } + + return nil +} + func (d *DAG) mapToArray(m map[string]interface{}) []*Target { a := make([]*Target, 0, len(m)) for _, anci := range m { diff --git a/targetrun/run.go b/targetrun/run.go index 13da9546..fadc611c 100644 --- a/targetrun/run.go +++ b/targetrun/run.go @@ -143,7 +143,7 @@ func (e *Runner) Run(ctx context.Context, rr Request, iocfg sandbox.IOConfig, tr sandbox.AddPathEnv(env, binDir, target.Sandbox && !hasPathInEnv) execCtx := ctx - if target.Timeout > 0 { + if !rr.Shell && target.Timeout > 0 { var cancel context.CancelFunc execCtx, cancel = context.WithTimeout(ctx, target.Timeout) defer cancel()