Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: milo/api/resp/build.go

Issue 2991383002: Milo: Actually shorten step text (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 288 » text := strings.Join(comp.Text, "\n")
289 // Max length for a datastore text field is 1500 char, but for summary p urposes 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. 290 // we don't really need anything much longer than 256 char or so.
291 const maxTextLen = 256 291 const maxTextLen = 256
292 sliceIdx := 0 292 sliceIdx := 0
293 // Make sure we don't cut off characters inbetween runes. 293 // Make sure we don't cut off characters inbetween runes.
294 for idx := range text { 294 for idx := range text {
295 if idx > maxTextLen { 295 if idx > maxTextLen {
296 break 296 break
297 } 297 }
298 sliceIdx = idx 298 sliceIdx = idx
299 } 299 }
300 text = text[:sliceIdx] 300 text = text[:sliceIdx]
301 return model.Summary{ 301 return model.Summary{
302 Status: comp.Status, 302 Status: comp.Status,
303 Start: comp.Started, 303 Start: comp.Started,
304 End: comp.Finished, 304 End: comp.Finished,
305 » » Text: text, 305 » » Text: strings.Split(text, "\n"),
306 } 306 }
307 } 307 }
308 308
309 // SummarizeTo summarizes the data into a given model.BuildSummary. 309 // SummarizeTo summarizes the data into a given model.BuildSummary.
310 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 {
311 bs.Summary = rb.Summary.toModelSummary() 311 bs.Summary = rb.Summary.toModelSummary()
312 if rb.Summary.Status == model.Running { 312 if rb.Summary.Status == model.Running {
313 // Assume the last step is the current step. 313 // Assume the last step is the current step.
314 if len(rb.Components) > 0 { 314 if len(rb.Components) > 0 {
315 cs := rb.Components[len(rb.Components)-1] 315 cs := rb.Components[len(rb.Components)-1]
(...skipping 27 matching lines...) Expand all
343 } 343 }
344 if rb.SourceStamp.Changelist != nil { 344 if rb.SourceStamp.Changelist != nil {
345 bs.Patches = append(bs.Patches, model.PatchInfo{ 345 bs.Patches = append(bs.Patches, model.PatchInfo{
346 Link: rb.SourceStamp.Changelist.Link, 346 Link: rb.SourceStamp.Changelist.Link,
347 AuthorEmail: rb.SourceStamp.AuthorEmail, 347 AuthorEmail: rb.SourceStamp.AuthorEmail,
348 }) 348 })
349 } 349 }
350 } 350 }
351 return nil 351 return nil
352 } 352 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698