| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. | 1 // Copyright 2015 The LUCI Authors. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 // Alias, if true, means that this link is an [alias link]. | 278 // Alias, if true, means that this link is an [alias link]. |
| 279 Alias bool `json:",omitempty"` | 279 Alias bool `json:",omitempty"` |
| 280 } | 280 } |
| 281 | 281 |
| 282 // NewLink does just about what you'd expect. | 282 // NewLink does just about what you'd expect. |
| 283 func NewLink(label, url string) *Link { | 283 func NewLink(label, url string) *Link { |
| 284 return &Link{Link: model.Link{Label: label, URL: url}} | 284 return &Link{Link: model.Link{Label: label, URL: url}} |
| 285 } | 285 } |
| 286 | 286 |
| 287 func (comp *BuildComponent) toModelSummary() model.Summary { | 287 func (comp *BuildComponent) toModelSummary() model.Summary { |
| 288 text := comp.Text |
| 289 // Max length for a datastore text field is 1500 char, but for summary p
urposes |
| 290 // we don't really need anything much longer than 256 char or so. |
| 291 const maxTextLen = 256 |
| 292 sliceIdx := 0 |
| 293 // Make sure we don't cut off characters inbetween runes. |
| 294 for idx := range text { |
| 295 if idx > maxTextLen { |
| 296 break |
| 297 } |
| 298 sliceIdx = idx |
| 299 } |
| 300 text = text[:sliceIdx] |
| 288 return model.Summary{ | 301 return model.Summary{ |
| 289 Status: comp.Status, | 302 Status: comp.Status, |
| 290 Start: comp.Started, | 303 Start: comp.Started, |
| 291 End: comp.Finished, | 304 End: comp.Finished, |
| 292 » » Text: comp.Text, | 305 » » Text: text, |
| 293 } | 306 } |
| 294 } | 307 } |
| 295 | 308 |
| 296 // SummarizeTo summarizes the data into a given model.BuildSummary. | 309 // SummarizeTo summarizes the data into a given model.BuildSummary. |
| 297 func (rb *MiloBuild) SummarizeTo(c context.Context, bs *model.BuildSummary) erro
r { | 310 func (rb *MiloBuild) SummarizeTo(c context.Context, bs *model.BuildSummary) erro
r { |
| 298 bs.Summary = rb.Summary.toModelSummary() | 311 bs.Summary = rb.Summary.toModelSummary() |
| 299 if rb.Summary.Status == model.Running { | 312 if rb.Summary.Status == model.Running { |
| 300 // Assume the last step is the current step. | 313 // Assume the last step is the current step. |
| 301 if len(rb.Components) > 0 { | 314 if len(rb.Components) > 0 { |
| 302 cs := rb.Components[len(rb.Components)-1] | 315 cs := rb.Components[len(rb.Components)-1] |
| (...skipping 27 matching lines...) Expand all Loading... |
| 330 } | 343 } |
| 331 if rb.SourceStamp.Changelist != nil { | 344 if rb.SourceStamp.Changelist != nil { |
| 332 bs.Patches = append(bs.Patches, model.PatchInfo{ | 345 bs.Patches = append(bs.Patches, model.PatchInfo{ |
| 333 Link: rb.SourceStamp.Changelist.Link, | 346 Link: rb.SourceStamp.Changelist.Link, |
| 334 AuthorEmail: rb.SourceStamp.AuthorEmail, | 347 AuthorEmail: rb.SourceStamp.AuthorEmail, |
| 335 }) | 348 }) |
| 336 } | 349 } |
| 337 } | 350 } |
| 338 return nil | 351 return nil |
| 339 } | 352 } |
| OLD | NEW |