Chromium Code Reviews| Index: milo/api/resp/build.go |
| diff --git a/milo/api/resp/build.go b/milo/api/resp/build.go |
| index 582f4df6234a72f20f08476d90631db6e8664fcc..4e5cc084de0376879b3da16b11ddf98be12ea8cf 100644 |
| --- a/milo/api/resp/build.go |
| +++ b/milo/api/resp/build.go |
| @@ -18,9 +18,14 @@ |
| package resp |
| import ( |
| + "encoding/hex" |
| "encoding/json" |
| "time" |
| + "golang.org/x/net/context" |
| + |
| + "github.com/luci/luci-go/common/logging" |
| + "github.com/luci/luci-go/milo/common" |
| "github.com/luci/luci-go/milo/common/model" |
| ) |
| @@ -278,7 +283,7 @@ func (comp *BuildComponent) toModelSummary() model.Summary { |
| } |
| // SummarizeTo summarizes the data into a given model.BuildSummary. |
| -func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) { |
| +func (rb *MiloBuild) SummarizeTo(c context.Context, bs *model.BuildSummary) error { |
| bs.Summary = rb.Summary.toModelSummary() |
| if rb.Summary.Status == model.Running { |
| // Assume the last step is the current step. |
| @@ -288,13 +293,31 @@ func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) { |
| } |
| } |
| if rb.SourceStamp != nil { |
| - // TODO(hinoka): This should be full manifests, but lets just use single |
| - // revisions for now. |
| + // TODO(hinoka, iannucci): This should be full manifests, but lets just use |
| + // single revisions for now. HACKS! |
| if rb.SourceStamp.Revision != nil { |
| - bs.Manifests = append(bs.Manifests, model.ManifestLink{ |
| - Name: "REVISION", |
| - ID: []byte(rb.SourceStamp.Revision.Label), |
| - }) |
| + revisionBytes, err := hex.DecodeString(rb.SourceStamp.Revision.Label) |
| + if err != nil { |
| + logging.WithError(err).Warningf(c, "bad revision (not hex-decodable)") |
|
Ryan Tseng
2017/07/19 00:29:38
return here, forgo the else.
iannucci
2017/07/19 00:38:16
no, I actually want the rest of the function here
Ryan Tseng
2017/07/19 00:45:55
oh merp i forgot the stuff before ::wishes there w
|
| + } else { |
| + bs.Manifests = append(bs.Manifests, model.ManifestLink{ |
| + Name: "REVISION", |
| + ID: []byte(rb.SourceStamp.Revision.Label), |
| + }) |
| + projs, err := common.GetAllProjects(c) |
|
Ryan Tseng
2017/07/19 00:29:38
just make a common.GetConsolesForBuilder(c)
iannucci
2017/07/19 00:38:16
Done.
|
| + if err != nil { |
| + return err |
| + } |
| + for _, p := range projs { |
| + for _, cons := range p.Consoles { |
| + for _, b := range cons.Builders { |
| + if b.Name == bs.BuilderID { |
| + bs.AddManifestRevisionIndex(cons.Name, "REVISION", revisionBytes) |
| + } |
| + } |
| + } |
| + } |
| + } |
| } |
| if rb.SourceStamp.Changelist != nil { |
| bs.Patches = append(bs.Patches, model.PatchInfo{ |
| @@ -303,4 +326,5 @@ func (rb *MiloBuild) SummarizeTo(bs *model.BuildSummary) { |
| }) |
| } |
| } |
| + return nil |
| } |