diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2022-12-07 15:59:50 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2022-12-09 13:55:42 +0100 |
| commit | caafa4e63d474f9cecf5197d274defbe27fe51f3 (patch) | |
| tree | badaef6d55632f2c79ff8d89b50275af9dd787eb /dashboard | |
| parent | 1034e5fa9a3f3cf21edc4bb0193fd5b2a0ec8893 (diff) | |
dashboard: split createBugReport()
Factor out job-related code so that the rest can be better reused.
Diffstat (limited to 'dashboard')
| -rw-r--r-- | dashboard/app/reporting.go | 24 |
1 files changed, 17 insertions, 7 deletions
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 } |
