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

Side by Side Diff: milo/common/model/build_summary.go

Issue 2978293002: [milo] Add an (uncached) method to get console rows. (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
1 // Copyright 2017 The LUCI Authors. 1 // Copyright 2017 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 Patches []PatchInfo 65 Patches []PatchInfo
66 66
67 // ManifestRevisionIndex has a single entry for each 67 // ManifestRevisionIndex has a single entry for each
68 // 0 ++ project ++ console ++ manifest_name ++ url ++ revision.decode( 'hex') 68 // 0 ++ project ++ console ++ manifest_name ++ url ++ revision.decode( 'hex')
69 // which matched for this build. ++ is cmpbin concatenation. 69 // which matched for this build. ++ is cmpbin concatenation.
70 // 70 //
71 // Example: 71 // Example:
72 // 0 ++ "chromium" ++ "main" ++ "UNPATCHED" ++ "https://.../src.git" + + deadbeef 72 // 0 ++ "chromium" ++ "main" ++ "UNPATCHED" ++ "https://.../src.git" + + deadbeef
73 // 73 //
74 // The list of interested consoles is compiled at build summarization ti me. 74 // The list of interested consoles is compiled at build summarization ti me.
75 ManifestRevisionIndex [][]byte 75 ManifestRevisionIndex [][]byte
Ryan Tseng 2017/07/19 08:07:58 maybe "ManifestKey" is good enough?
iannucci 2017/07/20 00:14:56 Done.
76 } 76 }
77 77
78 // AddManifestRevisionIndex adds a new entry to ManifestRevisionIndex. 78 // AddManifestRevisionIndex adds a new entry to ManifestRevisionIndex.
79 // 79 //
80 // `revision` should be the hex-decoded git revision. 80 // `revision` should be the hex-decoded git revision.
81 // 81 //
82 // It's up to the caller to ensure that entries in ManifestRevisionIndex aren't 82 // It's up to the caller to ensure that entries in ManifestRevisionIndex aren't
83 // duplicated. 83 // duplicated.
84 func (bs *BuildSummary) AddManifestRevisionIndex(project, console, manifest, rep oURL string, revision []byte) { 84 func (bs *BuildSummary) AddManifestRevisionIndex(project, console, manifest, rep oURL string, revision []byte) {
85 bs.ManifestRevisionIndex = append(bs.ManifestRevisionIndex,
86 BuildSummaryPrefix(project, console, manifest, repoURL).AddRevis ion(revision))
87 }
88
89 // ManifestRevisionIndexPrefix is a binary prefix for querying
Ryan Tseng 2017/07/19 08:07:58 Holy long names batman (not in the size of the nam
iannucci 2017/07/20 00:14:56 Done.
90 // BuildSummary.ManifestRevisionIndex obtained from BuildSummaryPrefix.
91 type ManifestRevisionIndexPrefix []byte
92
93 // AddRevision appends a git revision (as bytes) to the
94 // ManifestRevisionIndexPrefix, returning a full index value.
95 func (m ManifestRevisionIndexPrefix) AddRevision(revision []byte) []byte {
96 var buf bytes.Buffer
97 buf.Write(m)
98 cmpbin.WriteBytes(&buf, revision)
99 return buf.Bytes()
100 }
101
102 // BuildSummaryPrefix generates a ManifestRevisionIndex prefix corresponding to
103 // the given parameters.
104 func BuildSummaryPrefix(project, console, manifest, repoURL string) ManifestRevi sionIndexPrefix {
85 var buf bytes.Buffer 105 var buf bytes.Buffer
86 cmpbin.WriteUint(&buf, 0) // version 106 cmpbin.WriteUint(&buf, 0) // version
87 cmpbin.WriteString(&buf, project) 107 cmpbin.WriteString(&buf, project)
88 cmpbin.WriteString(&buf, console) 108 cmpbin.WriteString(&buf, console)
89 cmpbin.WriteString(&buf, manifest) 109 cmpbin.WriteString(&buf, manifest)
90 cmpbin.WriteString(&buf, repoURL) 110 cmpbin.WriteString(&buf, repoURL)
91 » cmpbin.WriteBytes(&buf, revision) 111 » return ManifestRevisionIndexPrefix(buf.Bytes())
92 » bs.ManifestRevisionIndex = append(bs.ManifestRevisionIndex, buf.Bytes())
93 } 112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698