Chromium Code Reviews| Index: appengine/cmd/milo/buildbot/build.go |
| diff --git a/appengine/cmd/milo/buildbot/build.go b/appengine/cmd/milo/buildbot/build.go |
| index 772075574d632ba24656e48420e8d9507de46da7..2404c1f50bfd698530a71e9d7c0a7c88c0ea598e 100644 |
| --- a/appengine/cmd/milo/buildbot/build.go |
| +++ b/appengine/cmd/milo/buildbot/build.go |
| @@ -341,6 +341,38 @@ func blame(b *buildbotBuild) (result []*resp.Commit) { |
| return |
| } |
| +// sourcestamp extracts the source stamp from various parts of a buildbot build, |
| +// including the properties. |
| +func sourcestamp(b *buildbotBuild) *resp.SourceStamp { |
| + ss := &resp.SourceStamp{} |
| + rietveld := "" |
| + issue := int64(-1) |
| + // TODO(hinoka): Gerrit URLs. |
| + for _, prop := range b.Properties { |
| + key := prop[0].(string) |
| + value := prop[1] |
| + switch key { |
| + case "rietveld": |
| + rietveld = value.(string) |
| + case "issue": |
| + issue = int64(value.(float64)) |
| + case "got_revision": |
| + ss.Revision = value.(string) |
| + } |
| + } |
|
nodir
2016/06/28 02:06:44
This code will panic if user input malformed, we s
Ryan Tseng
2016/06/28 21:49:31
Done.
|
| + if issue != -1 && rietveld == "" { |
| + // Default rietveld server |
| + rietveld = "https://codereview.chromium.org" |
|
nodir
2016/06/28 02:06:44
Do we have to define defaults in our code? Do we h
Ryan Tseng
2016/06/28 21:49:31
Not sure, this is just incase. I'll remove this
|
| + } |
| + if issue != -1 { |
| + ss.Changelist = &resp.Link{ |
| + Label: fmt.Sprintf("Issue %d", issue), |
| + URL: fmt.Sprintf("%s/%d", rietveld, issue), |
|
nodir
2016/06/28 02:06:44
What if rietveld ends with /
Trim it
Ryan Tseng
2016/06/28 21:49:31
Done.
|
| + } |
| + } |
| + return ss |
| +} |
| + |
| func getDebugBuild(c context.Context, builder, buildNum string) (*buildbotBuild, error) { |
| fname := fmt.Sprintf("%s.%s.json", builder, buildNum) |
| path := filepath.Join("testdata", "buildbot", fname) |
| @@ -366,6 +398,7 @@ func build(c context.Context, master, builder, buildNum string) (*resp.MiloBuild |
| } |
| return &resp.MiloBuild{ |
| + SourceStamp: sourcestamp(b), |
| Summary: summary(b), |
| Components: components(b), |
| PropertyGroup: properties(b), |