Skip to content

Commit b9f088b

Browse files
update how release branches are identified (#5512) (#5518)
Now we also need to account for the 8.x branch, therefore the process to identify release branches were updated to account for the 8.x (cherry picked from commit 34a9830) Co-authored-by: Anderson Queiroz <anderson.queiroz@elastic.co>
1 parent c671456 commit b9f088b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/testing/tools/git/git.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
var (
1919
ErrNotReleaseBranch = errors.New("this is not a release branch")
20-
releaseBranchRegexp = regexp.MustCompile(`.*(\d+\.\d+)$`)
20+
releaseBranchRegexp = regexp.MustCompile(`.*(\d+\.(\d+|x))$`)
2121
)
2222

2323
type outputReader func(io.Reader) error
@@ -26,7 +26,7 @@ type outputReader func(io.Reader) error
2626
// current repository ordered descending by creation date.
2727
// e.g. 8.13, 8.12, etc.
2828
func GetReleaseBranches(ctx context.Context) ([]string, error) {
29-
c := exec.CommandContext(ctx, "git", "branch", "-r", "--list", "*/[0-9]*.*[0-9]", "--sort=-creatordate")
29+
c := exec.CommandContext(ctx, "git", "branch", "-r", "--list", "*/[0-9]*.*[0-9x]", "--sort=-creatordate")
3030

3131
branchList := []string{}
3232
err := runCommand(c, releaseBranchReader(&branchList))
@@ -99,8 +99,8 @@ func extractReleaseBranch(branch string) (string, error) {
9999
}
100100

101101
matches := releaseBranchRegexp.FindStringSubmatch(branch)
102-
if len(matches) != 2 {
103-
return "", fmt.Errorf("failed to process branch %q: expected 2 matches, got %d", branch, len(matches))
102+
if len(matches) != 3 {
103+
return "", fmt.Errorf("failed to process branch %q: expected 3 matches, got %d", branch, len(matches))
104104
}
105105
return matches[1], nil
106106
}

0 commit comments

Comments
 (0)