// Given a patch version and a list of task names, creates a new task with // the given name for each variant, if applicable. func AddNewTasksForPatch(p *patch.Patch, patchVersion *version.Version, project *Project, taskNames []string) error { // create new tasks for all of the added patch tasks var newTasks []string for _, taskName := range taskNames { if !util.SliceContains(p.Tasks, taskName) { newTasks = append(newTasks, taskName) } } // add tasks to the patch in the db if err := p.AddTasks(taskNames); err != nil { return err } // add new tasks to the build, if they exist if len(newTasks) > 0 { builds, err := build.Find(build.ByIds(patchVersion.BuildIds)) if err != nil { return err } for _, b := range builds { if _, err = AddTasksToBuild(&b, project, patchVersion, newTasks); err != nil { return err } } } return nil }