diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-08-24 18:24:04 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2023-08-25 08:51:53 +0000 |
| commit | 03d9c195daed8fca30b642783f35657aa7e32209 (patch) | |
| tree | a4aea26606a03b4113be4b54a1edbcdd7021bbc3 /pkg/vcs | |
| parent | 49be837e029feccab241a98641b01a146890b66f (diff) | |
pkg/bisect: test a subset of releases
For older bugs (or for bugs on stable trees), our cause bisection
strategy times out while trying to iterate over all reachable tags.
Try to be smarter and only take a subset of them, thus limiting the time
we spend detecting the bug-free release.
Closes #3376.
Diffstat (limited to 'pkg/vcs')
| -rw-r--r-- | pkg/vcs/linux.go | 32 | ||||
| -rw-r--r-- | pkg/vcs/vcs.go | 26 |
2 files changed, 34 insertions, 24 deletions
diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go index 270240da7..62319096d 100644 --- a/pkg/vcs/linux.go +++ b/pkg/vcs/linux.go @@ -10,7 +10,6 @@ import ( "path/filepath" "regexp" "sort" - "strconv" "strings" "time" @@ -105,36 +104,21 @@ func gitParseReleaseTags(output []byte, includeRC bool) []string { } func gitReleaseTagToInt(tag string, includeRC bool) uint64 { - matches := releaseTagRe.FindStringSubmatchIndex(tag) - if matches == nil { + v1, v2, rc, v3 := ParseReleaseTag(tag) + if v1 < 0 { return 0 } - v1, err := strconv.ParseUint(tag[matches[2]:matches[3]], 10, 64) - if err != nil { - return 0 + if v3 < 0 { + v3 = 0 } - v2, err := strconv.ParseUint(tag[matches[4]:matches[5]], 10, 64) - if err != nil { - return 0 - } - rc := uint64(999) - if matches[6] != -1 { + if rc >= 0 { if !includeRC { return 0 } - rc, err = strconv.ParseUint(tag[matches[6]:matches[7]], 10, 64) - if err != nil { - return 0 - } - } - var v3 uint64 - if matches[8] != -1 { - v3, err = strconv.ParseUint(tag[matches[8]:matches[9]], 10, 64) - if err != nil { - return 0 - } + } else { + rc = 999 } - return v1*1e9 + v2*1e6 + rc*1e3 + v3 + return uint64(v1)*1e9 + uint64(v2)*1e6 + uint64(rc)*1e3 + uint64(v3) } func (ctx *linux) EnvForCommit( diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go index ae2b34174..26665bda3 100644 --- a/pkg/vcs/vcs.go +++ b/pkg/vcs/vcs.go @@ -10,6 +10,7 @@ import ( "net/mail" "regexp" "sort" + "strconv" "strings" "time" @@ -268,6 +269,31 @@ func CheckCommitHash(hash string) bool { return gitHashRe.MatchString(hash) } +func ParseReleaseTag(tag string) (v1, v2, rc, v3 int) { + invalid := func() { + v1, v2, rc, v3 = -1, -1, -1, -1 + } + invalid() + matches := releaseTagRe.FindStringSubmatch(tag) + if matches == nil { + return + } + for ptr, idx := range map[*int]int{ + &v1: 1, &v2: 2, &rc: 3, &v3: 4, + } { + if matches[idx] == "" { + continue + } + var err error + *ptr, err = strconv.Atoi(matches[idx]) + if err != nil { + invalid() + return + } + } + return +} + func runSandboxed(dir, command string, args ...string) ([]byte, error) { cmd := osutil.Command(command, args...) cmd.Dir = dir |
