Chromium Code Reviews| Index: milo/appengine/buildbot/build.go |
| diff --git a/milo/appengine/buildbot/build.go b/milo/appengine/buildbot/build.go |
| index bc658f35475ca0af3c336ab70cfca7c5449e5e96..952abb315c08e0da2298ea4a21e1e0370d310690 100644 |
| --- a/milo/appengine/buildbot/build.go |
| +++ b/milo/appengine/buildbot/build.go |
| @@ -515,8 +515,25 @@ func build(c context.Context, master, builder string, buildNum int) (*resp.MiloB |
| func updatePostProcessBuild(b *buildbotBuild) { |
| // If this is a LogDog-only build, we want to promote the LogDog links. |
| if loc, ok := b.getPropertyValue("log_location").(string); ok && strings.HasPrefix(loc, "logdog://") { |
| + linkMap := make(map[string]string) |
|
hinoka
2017/03/27 23:40:29
nit: map[string]string{} will do.
dnj
2017/03/27 23:44:51
Done.
|
| for sidx := range b.Steps { |
| - promoteLogDogLinks(&b.Steps[sidx], sidx == 0) |
| + promoteLogDogLinks(&b.Steps[sidx], sidx == 0, linkMap) |
| + } |
| + |
| + // Update "Logs". This field is part of BuildBot, and is the amalgamation |
| + // of all logs in the build's steps. Since each log is out of context of its |
| + // original step, we can't apply the promotion logic; instead, we will use |
| + // the link map to map any old URLs that were matched in "promoteLogDogLnks" |
| + // to their new URLs. |
| + for _, link := range b.Logs { |
| + // "link" is in the form: [NAME, URL] |
| + if len(link) != 2 { |
| + continue |
| + } |
| + |
| + if newURL, ok := linkMap[link[1]]; ok { |
| + link[1] = newURL |
| + } |
| } |
| } |
| } |
| @@ -535,7 +552,10 @@ func updatePostProcessBuild(b *buildbotBuild) { |
| // we want to do is remove the original junk links and replace them with their |
| // alias counterparts, so that the "natural" BuildBot links are actually LogDog |
| // links. |
| -func promoteLogDogLinks(s *buildbotStep, isInitialStep bool) { |
| +// |
| +// As URLs are re-mapped, the supplied "linkMap" will be updated to map the old |
| +// URLs to the new ones. |
| +func promoteLogDogLinks(s *buildbotStep, isInitialStep bool, linkMap map[string]string) { |
| type stepLog struct { |
| label string |
| url string |
| @@ -580,6 +600,12 @@ func promoteLogDogLinks(s *buildbotStep, isInitialStep bool) { |
| result[i] = &aliasStepLog |
| } |
| + |
| + // If we performed mapping, add the OLD -> NEW URL mapping to linkMap. |
| + if len(result) > 0 { |
|
hinoka
2017/03/27 23:40:29
Add comment about why this chooses the last result
dnj
2017/03/27 23:44:51
Done.
|
| + linkMap[sl.url] = result[len(result)-1].url |
| + } |
| + |
| return result |
| } |