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

Side by Side 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, 8 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
« no previous file with comments | « autoroll/go/repo_manager/repo_manager.go ('k') | go/util/util_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package util 1 package util
2 2
3 import ( 3 import (
4 "crypto/md5" 4 "crypto/md5"
5 "crypto/rand" 5 "crypto/rand"
6 "crypto/sha256" 6 "crypto/sha256"
7 "fmt" 7 "fmt"
8 "io" 8 "io"
9 "math" 9 "math"
10 mathrand "math/rand" 10 mathrand "math/rand"
(...skipping 10 matching lines...) Expand all
21 ) 21 )
22 22
23 const ( 23 const (
24 _ = iota // ignore first value by assigning to blank identifier 24 _ = iota // ignore first value by assigning to blank identifier
25 KB float64 = 1 << (10 * iota) 25 KB float64 = 1 << (10 * iota)
26 MB 26 MB
27 GB 27 GB
28 TB 28 TB
29 PB 29 PB
30 30
31 PROJECT_CHROMIUM = "chromium"
32 BUG_DEFAULT_PROJECT = PROJECT_CHROMIUM
33 BUGS_PATTERN = "(?m)^BUG=(.+)$"
34
31 SECONDS_TO_MILLIS = int64(time.Second / time.Millisecond) 35 SECONDS_TO_MILLIS = int64(time.Second / time.Millisecond)
32 MILLIS_TO_NANOS = int64(time.Millisecond / time.Nanosecond) 36 MILLIS_TO_NANOS = int64(time.Millisecond / time.Nanosecond)
33 37
34 // time.RFC3339Nano only uses as many sub-second digits are required to 38 // time.RFC3339Nano only uses as many sub-second digits are required to
35 // represent the time, which makes it unsuitable for sorting. This 39 // represent the time, which makes it unsuitable for sorting. This
36 // format ensures that all 9 nanosecond digits are used, padding with 40 // format ensures that all 9 nanosecond digits are used, padding with
37 // zeroes if necessary. 41 // zeroes if necessary.
38 RFC3339NanoZeroPad = "2006-01-02T15:04:05.000000000Z07:00" 42 RFC3339NanoZeroPad = "2006-01-02T15:04:05.000000000Z07:00"
39 ) 43 )
40 44
41 var ( 45 var (
46 BUGS_REGEX = regexp.MustCompile(BUGS_PATTERN)
47
42 // randomNameAdj is a list of adjectives for building random names. 48 // randomNameAdj is a list of adjectives for building random names.
43 randomNameAdj = []string{ 49 randomNameAdj = []string{
44 "autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark", 50 "autumn", "hidden", "bitter", "misty", "silent", "empty", "dry", "dark",
45 "summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter", 51 "summer", "icy", "delicate", "quiet", "white", "cool", "spring", "winter",
46 "patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue", 52 "patient", "twilight", "dawn", "crimson", "wispy", "weathered", "blue",
47 "billowing", "broken", "cold", "damp", "falling", "frosty", "gre en", 53 "billowing", "broken", "cold", "damp", "falling", "frosty", "gre en",
48 "long", "late", "lingering", "bold", "little", "morning", "muddy ", "old", 54 "long", "late", "lingering", "bold", "little", "morning", "muddy ", "old",
49 "red", "rough", "still", "small", "sparkling", "throbbing", "shy ", 55 "red", "rough", "still", "small", "sparkling", "throbbing", "shy ",
50 "wandering", "withered", "wild", "black", "young", "holy", "soli tary", 56 "wandering", "withered", "wild", "black", "young", "holy", "soli tary",
51 "fragrant", "aged", "snowy", "proud", "floral", "restless", "div ine", 57 "fragrant", "aged", "snowy", "proud", "floral", "restless", "div ine",
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 if chunkSize < 1 { 603 if chunkSize < 1 {
598 return fmt.Errorf("Chunk size may not be less than 1.") 604 return fmt.Errorf("Chunk size may not be less than 1.")
599 } 605 }
600 for c, r := s[:MinInt(chunkSize, len(s))], s[MinInt(chunkSize, len(s)):] ; len(c) > 0; c, r = r[:MinInt(chunkSize, len(r))], r[MinInt(chunkSize, len(r)): ] { 606 for c, r := s[:MinInt(chunkSize, len(s))], s[MinInt(chunkSize, len(s)):] ; len(c) > 0; c, r = r[:MinInt(chunkSize, len(r))], r[MinInt(chunkSize, len(r)): ] {
601 if err := fn(c); err != nil { 607 if err := fn(c); err != nil {
602 return err 608 return err
603 } 609 }
604 } 610 }
605 return nil 611 return nil
606 } 612 }
613
614 // BugsFromCommitMsg parses BUG= tags from a commit message and returns them.
615 func BugsFromCommitMsg(msg string) map[string][]string {
616 rv := map[string][]string{}
617 m := BUGS_REGEX.FindStringSubmatch(msg)
618 if len(m) > 1 {
619 bugs := strings.Split(m[1], ",")
620 for _, b := range bugs {
621 b = strings.Trim(b, " ")
622 split := strings.SplitN(strings.Trim(b, " "), ":", 2)
623 project := BUG_DEFAULT_PROJECT
624 bug := split[0]
625 if len(split) > 1 {
626 project = split[0]
627 bug = split[1]
628 }
629 if rv[project] == nil {
630 rv[project] = []string{}
631 }
632 rv[project] = append(rv[project], bug)
633 }
634 }
635 glog.Errorf("%v", rv)
636 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
637 }
OLDNEW
« 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