From caafa4e63d474f9cecf5197d274defbe27fe51f3 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 7 Dec 2022 15:59:50 +0100 Subject: dashboard: split createBugReport() Factor out job-related code so that the rest can be better reused. --- dashboard/app/reporting.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'dashboard') diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index 89ab77406..b7c6be72c 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -388,10 +388,6 @@ func reproStr(level dashapi.ReproLevel) string { // nolint: gocyclo func createBugReport(c context.Context, bug *Bug, crash *Crash, crashKey *db.Key, bugReporting *BugReporting, reporting *Reporting) (*dashapi.BugReport, error) { - reportingConfig, err := json.Marshal(reporting.Config) - if err != nil { - return nil, err - } var job *Job if bug.BisectCause == BisectYes || bug.BisectCause == BisectInconclusive || bug.BisectCause == BisectHorizont { // If we have bisection results, report the crash/repro used for bisection. @@ -411,6 +407,23 @@ func createBugReport(c context.Context, bug *Bug, crash *Crash, crashKey *db.Key } } } + rep, err := crashBugReport(c, bug, crash, crashKey, bugReporting, reporting) + if err != nil { + return nil, err + } + if job != nil { + rep.BisectCause = bisectFromJob(c, rep, job) + } + return rep, nil +} + +// crashBugReport fills in crash and build related fields into *dashapi.BugReport. +func crashBugReport(c context.Context, bug *Bug, crash *Crash, crashKey *db.Key, + bugReporting *BugReporting, reporting *Reporting) (*dashapi.BugReport, error) { + reportingConfig, err := json.Marshal(reporting.Config) + if err != nil { + return nil, err + } crashLog, _, err := getText(c, textCrashLog, crash.Log) if err != nil { return nil, err @@ -499,9 +512,6 @@ func createBugReport(c context.Context, bug *Bug, crash *Crash, crashKey *db.Key rep.Maintainers = append(rep.Maintainers, mgr.CC.BuildMaintainers...) } } - if job != nil { - rep.BisectCause = bisectFromJob(c, rep, job) - } if err := fillBugReport(c, rep, bug, bugReporting, build); err != nil { return nil, err } -- cgit mrf-deployment