From 186e9e70b65a56a842428520fcff5a54645782a9 Mon Sep 17 00:00:00 2001 From: Fedor Korotkiy Date: Thu, 22 Apr 2021 14:12:10 +0300 Subject: [PATCH] Revert "Revert "Update testtool change detection"" This reverts commit e75b41aec165614275d55632cc3d523948dae61c. --- tools/testtool/commands/deadlines.go | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/testtool/commands/deadlines.go b/tools/testtool/commands/deadlines.go index 5765442..f043692 100644 --- a/tools/testtool/commands/deadlines.go +++ b/tools/testtool/commands/deadlines.go @@ -15,8 +15,9 @@ const timeFormat = "02-01-2006 15:04" type ( Task struct { - Name string `yaml:"task"` - Score int `yaml:"score"` + Name string `yaml:"task"` + Score int `yaml:"score"` + Watch []string `yaml:"watch"` } Group struct { @@ -34,6 +35,16 @@ func (g Group) IsOpen() bool { return time.Until(t) < 0 } +func (d Deadlines) Tasks() []*Task { + var tasks []*Task + for _, g := range d { + for i := range g.Tasks { + tasks = append(tasks, &g.Tasks[i]) + } + } + return tasks +} + func (d Deadlines) FindTask(name string) (*Group, *Task) { for _, g := range d { for _, t := range g.Tasks { @@ -80,11 +91,19 @@ func findChangedTasks(d Deadlines, files []string) []string { } _, task := d.FindTask(components[0]) - if task == nil { + if task != nil { + tasks[task.Name] = struct{}{} continue } - tasks[task.Name] = struct{}{} + for _, task := range d.Tasks() { + for _, path := range task.Watch { + if components[0] == path { + tasks[task.Name] = struct{}{} + continue + } + } + } } var l []string