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

Unified Diff: go/util/util.go

Issue 1849283002: AutoRolls include Chromium bug links (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: ... Created 4 years, 9 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
« no previous file with comments | « autoroll/go/repo_manager/repo_manager.go ('k') | go/util/util_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/util/util.go
diff --git a/go/util/util.go b/go/util/util.go
index be684a1aaf1a780555f5f8374665cbb84ee870e5..4e99e96491e071424d8869cfbbb463e0cf82ce8b 100644
--- a/go/util/util.go
+++ b/go/util/util.go
@@ -28,6 +28,10 @@ const (
TB
PB
+ PROJECT_CHROMIUM = "chromium"
+ BUG_DEFAULT_PROJECT = PROJECT_CHROMIUM
+ BUGS_PATTERN = "(?m)^BUG=(.+)$"
+
SECONDS_TO_MILLIS = int64(time.Second / time.Millisecond)
MILLIS_TO_NANOS = int64(time.Millisecond / time.Nanosecond)
@@ -39,6 +43,8 @@ const (
)
var (
+ BUGS_REGEX = regexp.MustCompile(BUGS_PATTERN)
+
// randomNameAdj is a list of adjectives for building random names.
randomNameAdj = []string{
"autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
@@ -604,3 +610,28 @@ func ChunkIter(s []int, chunkSize int, fn func([]int) error) error {
}
return nil
}
+
+// BugsFromCommitMsg parses BUG= tags from a commit message and returns them.
+func BugsFromCommitMsg(msg string) map[string][]string {
+ rv := map[string][]string{}
+ m := BUGS_REGEX.FindStringSubmatch(msg)
+ if len(m) > 1 {
+ bugs := strings.Split(m[1], ",")
+ for _, b := range bugs {
+ b = strings.Trim(b, " ")
+ split := strings.SplitN(strings.Trim(b, " "), ":", 2)
+ project := BUG_DEFAULT_PROJECT
+ bug := split[0]
+ if len(split) > 1 {
+ project = split[0]
+ bug = split[1]
+ }
+ if rv[project] == nil {
+ rv[project] = []string{}
+ }
+ rv[project] = append(rv[project], bug)
+ }
+ }
+ glog.Errorf("%v", rv)
+ return rv
rmistry 2016/04/04 12:45:09 Why return a dictionary of projects to bugs? It wo
borenet 2016/04/04 15:50:07 The autoroller only wants to specify chromium bugs
+}
« no previous file with comments | « autoroll/go/repo_manager/repo_manager.go ('k') | go/util/util_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698