| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 package console | 5 package console |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "strings" | 10 "strings" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 if err != nil { | 63 if err != nil { |
| 64 return nil, err | 64 return nil, err |
| 65 } | 65 } |
| 66 commits, err := git.GetCommits(c, def.RepoURL, def.Branch, 25) | 66 commits, err := git.GetCommits(c, def.RepoURL, def.Branch, 25) |
| 67 if err != nil { | 67 if err != nil { |
| 68 return nil, err | 68 return nil, err |
| 69 } | 69 } |
| 70 tGitiles := clock.Now(c) | 70 tGitiles := clock.Now(c) |
| 71 logging.Debugf(c, "Loading commits took %s.", tGitiles.Sub(tStart)) | 71 logging.Debugf(c, "Loading commits took %s.", tGitiles.Sub(tStart)) |
| 72 commitNames := make([]string, len(commits)) | 72 commitNames := make([]string, len(commits)) |
| 73 commitLinks := make([]*resp.Link, len(commits)) |
| 73 for i, commit := range commits { | 74 for i, commit := range commits { |
| 74 » » commitNames[i] = commit.Revision | 75 » » commitNames[i] = commit.Revision.Label |
| 76 » » commitLinks[i] = commit.Revision |
| 75 } | 77 } |
| 76 | 78 |
| 77 // HACK(hinoka): This only supports buildbot.... | 79 // HACK(hinoka): This only supports buildbot.... |
| 78 builders := make([]resp.BuilderRef, len(def.Builders)) | 80 builders := make([]resp.BuilderRef, len(def.Builders)) |
| 79 for i, b := range def.Builders { | 81 for i, b := range def.Builders { |
| 80 builders[i] = resp.BuilderRef{ | 82 builders[i] = resp.BuilderRef{ |
| 81 b.Module, b.Name, strings.Split(b.Category, "|"), b.Shor
tName, | 83 b.Module, b.Name, strings.Split(b.Category, "|"), b.Shor
tName, |
| 82 } | 84 } |
| 83 } | 85 } |
| 84 cb, err := GetConsoleBuilds(c, "buildbot", builders, commitNames) | 86 cb, err := GetConsoleBuilds(c, "buildbot", builders, commitNames) |
| 85 tConsole := clock.Now(c) | 87 tConsole := clock.Now(c) |
| 86 logging.Debugf(c, "Loading the console took a total of %s.", tConsole.Su
b(tGitiles)) | 88 logging.Debugf(c, "Loading the console took a total of %s.", tConsole.Su
b(tGitiles)) |
| 87 if err != nil { | 89 if err != nil { |
| 88 return nil, err | 90 return nil, err |
| 89 } | 91 } |
| 90 ccb := make([]resp.CommitBuild, len(commits)) | 92 ccb := make([]resp.CommitBuild, len(commits)) |
| 91 » for i, commit := range commitNames { | 93 » for i, commit := range commitLinks { |
| 92 // TODO(hinoka): Not like this | 94 // TODO(hinoka): Not like this |
| 93 ccb[i].Commit = resp.Commit{Revision: commit} | 95 ccb[i].Commit = resp.Commit{Revision: commit} |
| 94 ccb[i].Build = cb[i] | 96 ccb[i].Build = cb[i] |
| 95 } | 97 } |
| 96 | 98 |
| 97 cs := &resp.Console{ | 99 cs := &resp.Console{ |
| 98 Name: def.Name, | 100 Name: def.Name, |
| 99 Commit: ccb, | 101 Commit: ccb, |
| 100 BuilderRef: builders, | 102 BuilderRef: builders, |
| 101 } | 103 } |
| 102 | 104 |
| 103 return cs, nil | 105 return cs, nil |
| 104 } | 106 } |
| OLD | NEW |