| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 //go:generate stringer -type=Verbosity | 5 //go:generate stringer -type=Verbosity |
| 6 //go:generate stringer -type=ComponentType | 6 //go:generate stringer -type=ComponentType |
| 7 | 7 |
| 8 package resp | 8 package resp |
| 9 | 9 |
| 10 import ( | 10 import ( |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 Alt string `json:",omitempty"` | 250 Alt string `json:",omitempty"` |
| 251 | 251 |
| 252 // Alias, if true, means that this link is an [alias link]. | 252 // Alias, if true, means that this link is an [alias link]. |
| 253 Alias bool `json:",omitempty"` | 253 Alias bool `json:",omitempty"` |
| 254 } | 254 } |
| 255 | 255 |
| 256 // NewLink does just about what you'd expect. | 256 // NewLink does just about what you'd expect. |
| 257 func NewLink(label, url string) *Link { | 257 func NewLink(label, url string) *Link { |
| 258 return &Link{Link: model.Link{Label: label, URL: url}} | 258 return &Link{Link: model.Link{Label: label, URL: url}} |
| 259 } | 259 } |
| 260 |
| 261 func (comp *BuildComponent) toModelSummary() model.Summary { |
| 262 return model.Summary{ |
| 263 Status: comp.Status, |
| 264 Start: comp.Started, |
| 265 End: comp.Finished, |
| 266 Text: comp.Text, |
| 267 } |
| 268 } |
| 269 |
| 270 // SummarizeTo summarizes the data into a given model.BuildSummary. |
| 271 func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) { |
| 272 bs.Summary = rb.Summary.toModelSummary() |
| 273 if rb.Summary.Status == model.Running { |
| 274 // Assume the last step is the current step. |
| 275 if len(rb.Components) > 0 { |
| 276 cs := rb.Components[len(rb.Components)-1] |
| 277 bs.CurrentStep = cs.toModelSummary() |
| 278 } |
| 279 } |
| 280 if rb.SourceStamp != nil { |
| 281 // TODO(hinoka): This should be full manifests, but lets just us
e single |
| 282 // revisions for now. |
| 283 if rb.SourceStamp.Revision != nil { |
| 284 bs.Manifests = append(bs.Manifests, model.ManifestLink{ |
| 285 Name: "REVISION", |
| 286 ID: []byte(rb.SourceStamp.Revision.Label), |
| 287 }) |
| 288 } |
| 289 if rb.SourceStamp.Changelist != nil { |
| 290 bs.Patches = append(bs.Patches, model.PatchInfo{ |
| 291 Link: rb.SourceStamp.Changelist.Link, |
| 292 AuthorEmail: rb.SourceStamp.AuthorEmail, |
| 293 }) |
| 294 } |
| 295 } |
| 296 } |
| OLD | NEW |