From 1bd538f42c8ec8512d864f739dd98dce3d41256a Mon Sep 17 00:00:00 2001 From: Zubin Mithra Date: Thu, 1 Aug 2019 13:53:11 -0700 Subject: dashboard/app: remove duplicate code inside bug.html template * Introduce "bisect_results" inside templates.html to take in a uiJob and shows its contents. * Modify bug.html to use "bisect_results" to show BisectCause and BisectFix uiJob. --- dashboard/app/bug.html | 71 ++------------------------------------------ dashboard/app/templates.html | 51 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 69 deletions(-) diff --git a/dashboard/app/bug.html b/dashboard/app/bug.html index 2efb75a8c..829c0b172 100644 --- a/dashboard/app/bug.html +++ b/dashboard/app/bug.html @@ -25,75 +25,8 @@ Page with details about a single bug. {{end}} First crash: {{formatLateness $.Now $.Bug.FirstTime}}, last: {{formatLateness $.Now $.Bug.LastTime}}
- {{with $bisect := .BisectCause}}
- {{if $bisect.ErrorLink}} - Bisection: {{link $bisect.ErrorLink "error"}} - ({{link $bisect.LogLink "bisect log"}})
- {{else if $bisect.Commit}}{{with $com := $bisect.Commit}} - Bisection: introduced by - ({{link $bisect.LogLink "bisect log"}}):
-
- commit {{$com.Hash}}
- Author: {{$com.Author}}
- Date: {{formatKernelTime $com.Date}}
-
-   {{$com.Title}}
-

- {{end}}{{else if $bisect.Commits}}{{with $bisect.Commits}} - Bisection: the first bad commit could be any of - ({{link $bisect.LogLink "bisect log"}}):
-
- {{range $com := $bisect.Commits}} -   {{formatTagHash $com.Hash}} {{$com.Title}}
- {{end}} -

- {{end}}{{else}} - Bisection: the bug happens on the oldest tested release - ({{link $bisect.LogLink "bisect log"}})
- {{end}} - Tree: {{$bisect.KernelAlias}}
- {{if $bisect.CrashLogLink}} - Crash: {{link $bisect.CrashReportLink $bisect.CrashTitle}} ({{link $bisect.CrashLogLink "log"}})
- {{end}} - Repro: {{optlink $bisect.Crash.ReproCLink "C"}} - {{optlink $bisect.Crash.ReproSyzLink "syz"}} - {{optlink $bisect.Crash.KernelConfigLink ".config"}}
- {{end}} - - {{with $bisect := .BisectFix}}
- {{if $bisect.ErrorLink}} - Bisection: {{link $bisect.ErrorLink "error"}} - ({{link $bisect.LogLink "bisect log"}})
- {{else if $bisect.Commit}}{{with $com := $bisect.Commit}} - Bisection: fixed by - ({{link $bisect.LogLink "bisect log"}}):
-
- commit {{$com.Hash}}
- Author: {{$com.Author}}
- Date: {{formatKernelTime $com.Date}}
-
-   {{$com.Title}}
-

- {{end}}{{else if $bisect.Commits}}{{with $bisect.Commits}} - Bisection: the fix commit could be any of - ({{link $bisect.LogLink "bisect log"}}):
-
- {{range $com := $bisect.Commits}} -   {{formatTagHash $com.Hash}} {{$com.Title}}
- {{end}} -

- {{end}}{{else}} - Bisection: the bug occurs on the newest tested release - ({{link $bisect.LogLink "bisect log"}})
- {{end}} - Tree: {{$bisect.KernelAlias}}
- {{if $bisect.CrashLogLink}} - Crash: {{link $bisect.CrashReportLink $bisect.CrashTitle}} ({{link $bisect.CrashLogLink "log"}})
- {{end}} - Repro: {{optlink $bisect.Crash.ReproCLink "C"}} - {{optlink $bisect.Crash.ReproSyzLink "syz"}} - {{optlink $bisect.Crash.KernelConfigLink ".config"}}
- {{end}} + {{template "bisect_results" .BisectCause}} + {{template "bisect_results" .BisectFix}} {{template "bug_list" .DupOf}} {{template "bug_list" .Dups}} diff --git a/dashboard/app/templates.html b/dashboard/app/templates.html index 8c95831c9..9ab19d680 100644 --- a/dashboard/app/templates.html +++ b/dashboard/app/templates.html @@ -223,3 +223,54 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the {{end}} {{end}} + +{{/* Show bisection results */}} +{{define "bisect_results"}} +{{if .}} + {{$causeJob := 1}} + {{$fixJob := 2}} + {{if .ErrorLink}} + Bisection: {{link .ErrorLink "error"}} + ({{link .LogLink "bisect log"}})
+ {{else if .Commit}} + {{if eq .Type $causeJob}} + Bisection: introduced by + {{else if eq .Type $fixJob}} + Bisection: fixed by + {{end}} + ({{link .LogLink "bisect log"}}):
+
+ commit {{.Commit.Hash}}
+ Author: {{.Commit.Author}}
+ Date: {{formatKernelTime .Commit.Date}}
+
+   {{.Commit.Title}}
+

+ {{else if .Commits}} + {{if eq .Type $causeJob}} + Bisection: the cause commit could be any of + {{else if eq .Type $fixJob}} + Bisection: the fix commit could be any of + {{end}} + ({{link .LogLink "bisect log"}}):
+
+ {{range $com := .Commits}} +   {{formatTagHash $com.Hash}} {{$com.Title}}
+ {{end}} + {{else}} + {{if eq .Type $causeJob}} + Bisection: the bug happens on the oldest tested release + {{else if eq .Type $fixJob}} + Bisection: the fix commit could be any of + {{end}} +

+ {{end}} + Tree: {{.KernelAlias}}
+ {{if .CrashLogLink}} + Crash: {{link .CrashReportLink .CrashTitle}} ({{link .CrashLogLink "log"}})
+ Repro: {{optlink .Crash.ReproCLink "C"}} + {{optlink .Crash.ReproSyzLink "syz"}} + {{optlink .Crash.KernelConfigLink ".config"}}
+ {{end}} +{{end}} +{{end}} \ No newline at end of file -- cgit mrf-deployment