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

Unified Diff: milo/appengine/job_source/buildbot/build.go

Issue 2915923002: Milo: Fix Gerrit/Rietveld link for buildbot builds. (Closed)
Patch Set: Rebase fix Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: milo/appengine/job_source/buildbot/build.go
diff --git a/milo/appengine/job_source/buildbot/build.go b/milo/appengine/job_source/buildbot/build.go
index 52bc2e64b8ade8d3db254a86b398b9f284461a20..54114572ca70699e6a686ade491f72cd3945301d 100644
--- a/milo/appengine/job_source/buildbot/build.go
+++ b/milo/appengine/job_source/buildbot/build.go
@@ -13,6 +13,7 @@ import (
"path/filepath"
"regexp"
"sort"
+ "strconv"
"strings"
"time"
@@ -395,10 +396,10 @@ func blame(b *buildbotBuild) (result []*resp.Commit) {
func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp {
ss := &resp.SourceStamp{}
rietveld := ""
+ gerrit := ""
got_revision := ""
repository := ""
issue := int64(-1)
- // TODO(hinoka): Gerrit URLs.
for _, prop := range b.Properties {
switch prop.Name {
case "rietveld":
@@ -408,10 +409,17 @@ func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp {
logging.Warningf(c, "Field rietveld is not a string: %#v", prop.Value)
}
case "issue":
+ // Sometime this is a number (float), sometime it is a string.
if v, ok := prop.Value.(float64); ok {
issue = int64(v)
+ } else if v, ok := prop.Value.(string); ok {
+ if vi, err := strconv.ParseInt(v, 10, 64); err == nil {
+ issue = int64(vi)
+ } else {
+ logging.Warningf(c, "Could not decode field issue: %q - %s", prop.Value, err)
+ }
} else {
- logging.Warningf(c, "Field issue is not a float: %#v", prop.Value)
+ logging.Warningf(c, "Field issue is not a string or float: %#v", prop.Value)
}
case "got_revision":
@@ -421,6 +429,20 @@ func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp {
logging.Warningf(c, "Field got_revision is not a string: %#v", prop.Value)
}
+ case "patch_issue":
+ if v, ok := prop.Value.(float64); ok {
+ issue = int64(v)
+ } else {
+ logging.Warningf(c, "Field patch_issue is not a float: %#v", prop.Value)
+ }
+
+ case "patch_gerrit_url":
+ if v, ok := prop.Value.(string); ok {
+ gerrit = v
+ } else {
+ logging.Warningf(c, "Field gerrit is not a string: %#v", prop.Value)
+ }
+
case "repository":
if v, ok := prop.Value.(string); ok {
repository = v
@@ -428,16 +450,20 @@ func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp {
}
}
if issue != -1 {
- if rietveld != "" {
+ switch {
+ case rietveld != "":
rietveld = strings.TrimRight(rietveld, "/")
ss.Changelist = resp.NewLink(
- fmt.Sprintf("Issue %d", issue),
- fmt.Sprintf("%s/%d", rietveld, issue),
- )
- } else {
- logging.Warningf(c, "Found issue but not rietveld property.")
+ fmt.Sprintf("Rietveld CL %d", issue),
+ fmt.Sprintf("%s/%d", rietveld, issue))
+ case gerrit != "":
+ gerrit = strings.TrimRight(gerrit, "/")
+ ss.Changelist = resp.NewLink(
+ fmt.Sprintf("Gerrit CL %d", issue),
+ fmt.Sprintf("%s/c/%d", gerrit, issue))
}
}
+
if got_revision != "" {
ss.Revision = resp.NewLink(got_revision, "")
if repository != "" {

Powered by Google App Engine
This is Rietveld 408576698