Chromium Code Reviews| 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 buildbot | 5 package buildbot |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "errors" | 9 "errors" |
| 10 "fmt" | 10 "fmt" |
| 11 "io/ioutil" | 11 "io/ioutil" |
| 12 "math" | 12 "math" |
| 13 "path/filepath" | 13 "path/filepath" |
| 14 "regexp" | 14 "regexp" |
| 15 "sort" | 15 "sort" |
| 16 "strconv" | |
| 16 "strings" | 17 "strings" |
| 17 "time" | 18 "time" |
| 18 | 19 |
| 19 "golang.org/x/net/context" | 20 "golang.org/x/net/context" |
| 20 | 21 |
| 21 "github.com/luci/gae/service/datastore" | 22 "github.com/luci/gae/service/datastore" |
| 22 "github.com/luci/luci-go/common/data/stringset" | 23 "github.com/luci/luci-go/common/data/stringset" |
| 23 "github.com/luci/luci-go/common/logging" | 24 "github.com/luci/luci-go/common/logging" |
| 24 "github.com/luci/luci-go/milo/api/resp" | 25 "github.com/luci/luci-go/milo/api/resp" |
| 25 "github.com/luci/luci-go/milo/appengine/common/model" | 26 "github.com/luci/luci-go/milo/appengine/common/model" |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 }) | 389 }) |
| 389 } | 390 } |
| 390 return | 391 return |
| 391 } | 392 } |
| 392 | 393 |
| 393 // sourcestamp extracts the source stamp from various parts of a buildbot build, | 394 // sourcestamp extracts the source stamp from various parts of a buildbot build, |
| 394 // including the properties. | 395 // including the properties. |
| 395 func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp { | 396 func sourcestamp(c context.Context, b *buildbotBuild) *resp.SourceStamp { |
| 396 ss := &resp.SourceStamp{} | 397 ss := &resp.SourceStamp{} |
| 397 rietveld := "" | 398 rietveld := "" |
| 399 gerrit := "" | |
| 398 got_revision := "" | 400 got_revision := "" |
| 399 repository := "" | 401 repository := "" |
| 400 issue := int64(-1) | 402 issue := int64(-1) |
| 401 // TODO(hinoka): Gerrit URLs. | 403 // TODO(hinoka): Gerrit URLs. |
|
iannucci
2017/06/21 00:00:44
rm?
Ryan Tseng
2017/06/21 00:01:28
herp derp
| |
| 402 for _, prop := range b.Properties { | 404 for _, prop := range b.Properties { |
| 403 switch prop.Name { | 405 switch prop.Name { |
| 404 case "rietveld": | 406 case "rietveld": |
| 405 if v, ok := prop.Value.(string); ok { | 407 if v, ok := prop.Value.(string); ok { |
| 406 rietveld = v | 408 rietveld = v |
| 407 } else { | 409 } else { |
| 408 logging.Warningf(c, "Field rietveld is not a str ing: %#v", prop.Value) | 410 logging.Warningf(c, "Field rietveld is not a str ing: %#v", prop.Value) |
| 409 } | 411 } |
| 410 case "issue": | 412 case "issue": |
| 413 // Sometime this is a number (float), sometime it is a s tring. | |
| 411 if v, ok := prop.Value.(float64); ok { | 414 if v, ok := prop.Value.(float64); ok { |
| 412 issue = int64(v) | 415 issue = int64(v) |
| 416 } else if v, ok := prop.Value.(string); ok { | |
| 417 if vi, err := strconv.Atoi(v); err == nil { | |
| 418 issue = int64(vi) | |
| 419 } else { | |
| 420 logging.Warningf(c, "Could not decode fi eld issue: %q - %s", prop.Value, err) | |
| 421 } | |
| 413 } else { | 422 } else { |
| 414 » » » » logging.Warningf(c, "Field issue is not a float: %#v", prop.Value) | 423 » » » » logging.Warningf(c, "Field issue is not a string or float: %#v", prop.Value) |
| 415 } | 424 } |
| 416 | 425 |
| 417 case "got_revision": | 426 case "got_revision": |
| 418 if v, ok := prop.Value.(string); ok { | 427 if v, ok := prop.Value.(string); ok { |
| 419 got_revision = v | 428 got_revision = v |
| 420 } else { | 429 } else { |
| 421 logging.Warningf(c, "Field got_revision is not a string: %#v", prop.Value) | 430 logging.Warningf(c, "Field got_revision is not a string: %#v", prop.Value) |
| 422 } | 431 } |
| 423 | 432 |
| 433 case "patch_issue": | |
| 434 if v, ok := prop.Value.(float64); ok { | |
| 435 issue = int64(v) | |
| 436 } else { | |
| 437 logging.Warningf(c, "Field patch_issue is not a float: %#v", prop.Value) | |
| 438 } | |
| 439 | |
| 440 case "patch_gerrit_url": | |
| 441 if v, ok := prop.Value.(string); ok { | |
| 442 gerrit = v | |
| 443 } else { | |
| 444 logging.Warningf(c, "Field gerrit is not a strin g: %#v", prop.Value) | |
| 445 } | |
| 446 | |
| 424 case "repository": | 447 case "repository": |
| 425 if v, ok := prop.Value.(string); ok { | 448 if v, ok := prop.Value.(string); ok { |
| 426 repository = v | 449 repository = v |
| 427 } | 450 } |
| 428 } | 451 } |
| 429 } | 452 } |
| 430 if issue != -1 { | 453 if issue != -1 { |
| 431 » » if rietveld != "" { | 454 » » switch { |
| 455 » » case rietveld != "": | |
| 432 rietveld = strings.TrimRight(rietveld, "/") | 456 rietveld = strings.TrimRight(rietveld, "/") |
| 433 ss.Changelist = resp.NewLink( | 457 ss.Changelist = resp.NewLink( |
| 434 » » » » fmt.Sprintf("Issue %d", issue), | 458 » » » » fmt.Sprintf("Rietveld CL %d", issue), |
| 435 » » » » fmt.Sprintf("%s/%d", rietveld, issue), | 459 » » » » fmt.Sprintf("%s/%d", rietveld, issue)) |
| 436 » » » ) | 460 » » case gerrit != "": |
| 437 » » } else { | 461 » » » gerrit = strings.TrimRight(gerrit, "/") |
| 438 » » » logging.Warningf(c, "Found issue but not rietveld proper ty.") | 462 » » » ss.Changelist = resp.NewLink( |
| 463 » » » » fmt.Sprintf("Gerrit CL %d", issue), | |
| 464 » » » » fmt.Sprintf("%s/c/%d", gerrit, issue)) | |
| 439 } | 465 } |
| 440 } | 466 } |
| 467 | |
| 441 if got_revision != "" { | 468 if got_revision != "" { |
| 442 ss.Revision = resp.NewLink(got_revision, "") | 469 ss.Revision = resp.NewLink(got_revision, "") |
| 443 if repository != "" { | 470 if repository != "" { |
| 444 ss.Revision.URL = repository + "/+/" + got_revision | 471 ss.Revision.URL = repository + "/+/" + got_revision |
| 445 } | 472 } |
| 446 } | 473 } |
| 447 return ss | 474 return ss |
| 448 } | 475 } |
| 449 | 476 |
| 450 func getDebugBuild(c context.Context, builder string, buildNum int) (*buildbotBu ild, error) { | 477 func getDebugBuild(c context.Context, builder string, buildNum int) (*buildbotBu ild, error) { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 var newAliases map[string][]*buildbotLinkAlias | 652 var newAliases map[string][]*buildbotLinkAlias |
| 626 if l := remainingAliases.Len(); l > 0 { | 653 if l := remainingAliases.Len(); l > 0 { |
| 627 newAliases = make(map[string][]*buildbotLinkAlias, l) | 654 newAliases = make(map[string][]*buildbotLinkAlias, l) |
| 628 remainingAliases.Iter(func(v string) bool { | 655 remainingAliases.Iter(func(v string) bool { |
| 629 newAliases[v] = s.Aliases[v] | 656 newAliases[v] = s.Aliases[v] |
| 630 return true | 657 return true |
| 631 }) | 658 }) |
| 632 } | 659 } |
| 633 s.Aliases = newAliases | 660 s.Aliases = newAliases |
| 634 } | 661 } |
| OLD | NEW |