aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-10-29 10:33:41 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-10-29 18:02:20 +0100
commit5fa26ec9b5e628709d1cc0217a0c5e0a43590191 (patch)
treec254e9e5d3e73e99be8f385a3ae800d58c09f5f7 /pkg
parent1c1aefffdaaaea2acc1c36145b0a26c4593a2a41 (diff)
tools/syz-kconf: detect -rcN tags
We currently detect v5.10-rc1 as v5.9 because we ignore -rc tags. This makes it impossible to enable configs that were already added for v5.10. Treat v5.10-rc1 as v5.10 already.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/vcs/git.go12
-rw-r--r--pkg/vcs/git_test.go33
-rw-r--r--pkg/vcs/git_test_util.go2
-rw-r--r--pkg/vcs/linux.go31
-rw-r--r--pkg/vcs/testos.go2
-rw-r--r--pkg/vcs/vcs.go2
6 files changed, 63 insertions, 19 deletions
diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go
index aeb9d734d..5b1efa33a 100644
--- a/pkg/vcs/git.go
+++ b/pkg/vcs/git.go
@@ -503,7 +503,7 @@ func (git *git) bisectInconclusive(output []byte) ([]*Commit, error) {
}
func (git *git) ReleaseTag(commit string) (string, error) {
- tags, err := git.previousReleaseTags(commit, true, true)
+ tags, err := git.previousReleaseTags(commit, true, true, true)
if err != nil {
return "", err
}
@@ -513,14 +513,14 @@ func (git *git) ReleaseTag(commit string) (string, error) {
return tags[0], nil
}
-func (git *git) previousReleaseTags(commit string, self, onlyTop bool) ([]string, error) {
+func (git *git) previousReleaseTags(commit string, self, onlyTop, includeRC bool) ([]string, error) {
var tags []string
if self {
output, err := git.git("tag", "--list", "--points-at", commit, "--merged", commit, "v*.*")
if err != nil {
return nil, err
}
- tags = gitParseReleaseTags(output)
+ tags = gitParseReleaseTags(output, includeRC)
if onlyTop && len(tags) != 0 {
return tags, nil
}
@@ -529,7 +529,7 @@ func (git *git) previousReleaseTags(commit string, self, onlyTop bool) ([]string
if err != nil {
return nil, err
}
- tags1 := gitParseReleaseTags(output)
+ tags1 := gitParseReleaseTags(output, includeRC)
tags = append(tags, tags1...)
if len(tags) == 0 {
return nil, fmt.Errorf("no release tags found for commit %v", commit)
@@ -538,11 +538,11 @@ func (git *git) previousReleaseTags(commit string, self, onlyTop bool) ([]string
}
func (git *git) IsRelease(commit string) (bool, error) {
- tags1, err := git.previousReleaseTags(commit, true, false)
+ tags1, err := git.previousReleaseTags(commit, true, false, false)
if err != nil {
return false, err
}
- tags2, err := git.previousReleaseTags(commit, false, false)
+ tags2, err := git.previousReleaseTags(commit, false, false, false)
if err != nil {
return false, err
}
diff --git a/pkg/vcs/git_test.go b/pkg/vcs/git_test.go
index 4648f04f1..25893d3fc 100644
--- a/pkg/vcs/git_test.go
+++ b/pkg/vcs/git_test.go
@@ -97,11 +97,18 @@ v3.11
v3.19
v3.9
v3.2
+v4.9-rc1
v4.9
+v4.9-rc3
+v4.9-rc2
v2.6.32
v4.0
+vv4.1
+v2.6-rc5
+v4.1foo
voo
v1.foo
+v2.6-rc2
v10.2.foo
v1.2.
v1.
@@ -121,8 +128,32 @@ v1.
"v2.6.13",
"v2.6.12",
}
- got := gitParseReleaseTags([]byte(input))
+ got := gitParseReleaseTags([]byte(input), false)
if !reflect.DeepEqual(got, want) {
t.Fatalf("got bad tags\ngot: %+v\nwant: %+v", got, want)
}
+ wantRC := []string{
+ "v4.9",
+ "v4.9-rc3",
+ "v4.9-rc2",
+ "v4.9-rc1",
+ "v4.0",
+ "v3.19",
+ "v3.11",
+ "v3.10",
+ "v3.9",
+ "v3.2",
+ "v3.1",
+ "v3.0",
+ "v2.6.39",
+ "v2.6.32",
+ "v2.6.13",
+ "v2.6.12",
+ "v2.6-rc5",
+ "v2.6-rc2",
+ }
+ gotRC := gitParseReleaseTags([]byte(input), true)
+ if !reflect.DeepEqual(gotRC, wantRC) {
+ t.Fatalf("got bad tags\ngot: %+v\nwant: %+v", gotRC, wantRC)
+ }
}
diff --git a/pkg/vcs/git_test_util.go b/pkg/vcs/git_test_util.go
index a1dbf0dd9..3d3de8907 100644
--- a/pkg/vcs/git_test_util.go
+++ b/pkg/vcs/git_test_util.go
@@ -90,7 +90,7 @@ func (repo *TestRepo) SetTag(tag string) {
func (repo *TestRepo) SupportsBisection() bool {
// Detect too old git binary. --no-contains appeared in git 2.13.
- _, err := repo.repo.previousReleaseTags("HEAD", true, false)
+ _, err := repo.repo.previousReleaseTags("HEAD", true, false, false)
return err == nil ||
!strings.Contains(err.Error(), "usage: git tag") &&
!strings.Contains(err.Error(), "error: unknown option")
diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go
index b3c22e0d6..93a6ca910 100644
--- a/pkg/vcs/linux.go
+++ b/pkg/vcs/linux.go
@@ -39,7 +39,7 @@ func newLinux(dir string, opts []RepoOpt) *linux {
}
func (ctx *linux) PreviousReleaseTags(commit string) ([]string, error) {
- tags, err := ctx.git.previousReleaseTags(commit, false, false)
+ tags, err := ctx.git.previousReleaseTags(commit, false, false, false)
if err != nil {
return nil, err
}
@@ -71,21 +71,24 @@ func (ctx *linux) PreviousReleaseTags(commit string) ([]string, error) {
return tags, nil
}
-func gitParseReleaseTags(output []byte) []string {
+func gitParseReleaseTags(output []byte, includeRC bool) []string {
var tags []string
for _, tag := range bytes.Split(output, []byte{'\n'}) {
- if releaseTagRe.Match(tag) && gitReleaseTagToInt(string(tag)) != 0 {
+ if gitReleaseTagToInt(string(tag), includeRC) != 0 {
tags = append(tags, string(tag))
}
}
sort.Slice(tags, func(i, j int) bool {
- return gitReleaseTagToInt(tags[i]) > gitReleaseTagToInt(tags[j])
+ return gitReleaseTagToInt(tags[i], includeRC) > gitReleaseTagToInt(tags[j], includeRC)
})
return tags
}
-func gitReleaseTagToInt(tag string) uint64 {
+func gitReleaseTagToInt(tag string, includeRC bool) uint64 {
matches := releaseTagRe.FindStringSubmatchIndex(tag)
+ if matches == nil {
+ return 0
+ }
v1, err := strconv.ParseUint(tag[matches[2]:matches[3]], 10, 64)
if err != nil {
return 0
@@ -94,18 +97,28 @@ func gitReleaseTagToInt(tag string) uint64 {
if err != nil {
return 0
}
- var v3 uint64
+ rc := uint64(999)
if matches[6] != -1 {
- v3, err = strconv.ParseUint(tag[matches[6]:matches[7]], 10, 64)
+ 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
}
}
- return v1*1e6 + v2*1e3 + v3
+ return v1*1e9 + v2*1e6 + rc*1e3 + v3
}
func (ctx *linux) EnvForCommit(binDir, commit string, kernelConfig []byte) (*BisectEnv, error) {
- tagList, err := ctx.previousReleaseTags(commit, true, false)
+ tagList, err := ctx.previousReleaseTags(commit, true, false, false)
if err != nil {
return nil, err
}
diff --git a/pkg/vcs/testos.go b/pkg/vcs/testos.go
index ccabcf5f2..732192398 100644
--- a/pkg/vcs/testos.go
+++ b/pkg/vcs/testos.go
@@ -21,7 +21,7 @@ func newTestos(dir string, opts []RepoOpt) *testos {
}
func (ctx *testos) PreviousReleaseTags(commit string) ([]string, error) {
- return ctx.git.previousReleaseTags(commit, false, false)
+ return ctx.git.previousReleaseTags(commit, false, false, false)
}
func (ctx *testos) EnvForCommit(binDir, commit string, kernelConfig []byte) (*BisectEnv, error) {
diff --git a/pkg/vcs/vcs.go b/pkg/vcs/vcs.go
index df3099225..e79d1c18f 100644
--- a/pkg/vcs/vcs.go
+++ b/pkg/vcs/vcs.go
@@ -261,7 +261,7 @@ var (
gitSSHRepoRe = regexp.MustCompile(`^(git|ssh|http|https|ftp|ftps)@[a-zA-Z0-9-_]+(\.[a-zA-Z0-9-_]+)+(:[a-zA-Z0-9-_]+)?(/[a-zA-Z0-9-_./]+)?(/)?$`)
gitBranchRe = regexp.MustCompile("^[a-zA-Z0-9-_/.]{2,200}$")
gitHashRe = regexp.MustCompile("^[a-f0-9]{8,40}$")
- releaseTagRe = regexp.MustCompile(`^v([0-9]+).([0-9]+)(?:\.([0-9]+))?$`)
+ releaseTagRe = regexp.MustCompile(`^v([0-9]+).([0-9]+)(?:-rc([0-9]+))?(?:\.([0-9]+))?$`)
// CC: is intentionally not on this list, see #1441.
ccRes = []*regexp.Regexp{
regexp.MustCompile(`^Reviewed\-.*: (.*)$`),