aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-07-03 12:32:55 +0200
committerTaras Madan <tarasmadan@google.com>2023-07-04 07:24:44 +0000
commit07d54a36cb61c452b838befe3b09a2787b4e52fe (patch)
tree65c7c0897acfd14ec090a8f3c35a58e8f02a3871
parent6f968005cfbedc23e8ce67b2042a1f203252bb81 (diff)
dashboard/app: export fix commits repo + branch as json
-rw-r--r--dashboard/app/getjson_test.go8
-rw-r--r--dashboard/app/main.go8
-rw-r--r--dashboard/app/public_json_api.go32
3 files changed, 25 insertions, 23 deletions
diff --git a/dashboard/app/getjson_test.go b/dashboard/app/getjson_test.go
index e2d529c64..da611b7d6 100644
--- a/dashboard/app/getjson_test.go
+++ b/dashboard/app/getjson_test.go
@@ -132,10 +132,14 @@ func TestJSONAPIFixCommits(t *testing.T) {
"fix-commits": [
{
"title": "foo: fix1",
- "hash": "hash1"
+ "hash": "hash1",
+ "repo": "git://syzkaller.org",
+ "branch": "branch10"
},
{
- "title": "foo: fix2"
+ "title": "foo: fix2",
+ "repo": "git://syzkaller.org",
+ "branch": "branch10"
}
],
"crashes": [
diff --git a/dashboard/app/main.go b/dashboard/app/main.go
index 1c0b3ca27..2b481b254 100644
--- a/dashboard/app/main.go
+++ b/dashboard/app/main.go
@@ -1586,9 +1586,11 @@ func createUIBug(c context.Context, bug *Bug, state *ReportingState, managers []
cfg := config.Namespaces[bug.Namespace]
info := bug.getCommitInfo(i)
uiBug.Commits = append(uiBug.Commits, &uiCommit{
- Hash: info.Hash,
- Title: com,
- Link: vcs.CommitLink(cfg.Repos[0].URL, info.Hash),
+ Hash: info.Hash,
+ Title: com,
+ Link: vcs.CommitLink(cfg.Repos[0].URL, info.Hash),
+ Repo: cfg.Repos[0].URL,
+ Branch: cfg.Repos[0].Branch,
})
}
for _, mgr := range managers {
diff --git a/dashboard/app/public_json_api.go b/dashboard/app/public_json_api.go
index f4e83f857..a1ac660e3 100644
--- a/dashboard/app/public_json_api.go
+++ b/dashboard/app/public_json_api.go
@@ -5,8 +5,6 @@ package main
import (
"encoding/json"
-
- "github.com/google/syzkaller/dashboard/dashapi"
)
// publicApiBugDescription is used to serve the /bug HTTP requests
@@ -29,16 +27,6 @@ type vcsCommit struct {
Branch string `json:"branch,omitempty"`
}
-func makeVCSCommit(commit *dashapi.Commit, repo, branch string) *vcsCommit {
- return &vcsCommit{
- Title: commit.Title,
- Link: commit.Link,
- Hash: commit.Hash,
- Repo: repo,
- Branch: branch,
- }
-}
-
type publicAPICrashDescription struct {
Title string `json:"title"`
SyzReproducer string `json:"syz-reproducer,omitempty"`
@@ -68,9 +56,13 @@ func getExtAPIDescrForBugPage(bugPage *uiBugPage) *publicAPIBugDescription {
}
var res []vcsCommit
for _, commit := range bugPage.Bug.Commits {
- // TODO: add repoName and branchName to CommitInfo and
- // forward it here as commit.Repo + commit.Branch.
- res = append(res, *makeVCSCommit(commit, "", ""))
+ res = append(res, vcsCommit{
+ Title: commit.Title,
+ Link: commit.Link,
+ Hash: commit.Hash,
+ Repo: commit.Repo,
+ Branch: commit.Branch,
+ })
}
return res
}(),
@@ -78,9 +70,13 @@ func getExtAPIDescrForBugPage(bugPage *uiBugPage) *publicAPIBugDescription {
if bugPage.BisectCause == nil || bugPage.BisectCause.Commit == nil {
return nil
}
- return makeVCSCommit(bugPage.BisectCause.Commit,
- bugPage.BisectCause.KernelRepo,
- bugPage.BisectCause.KernelBranch)
+ bisectCause := bugPage.BisectCause
+ return &vcsCommit{
+ Title: bisectCause.Commit.Title,
+ Link: bisectCause.Commit.Link,
+ Hash: bisectCause.Commit.Hash,
+ Repo: bisectCause.KernelRepo,
+ Branch: bisectCause.KernelBranch}
}(),
Crashes: func() []publicAPICrashDescription {
var res []publicAPICrashDescription