Skip to content

Commit

Permalink
Fix revdeps file
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Apr 28, 2024
1 parent 014c949 commit 17c14ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/heph/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
28 changes: 21 additions & 7 deletions graph/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion targetrun/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 17c14ab

Please sign in to comment.