From 332ef8d2423f7c8c17dc8afb27a6391e8107d6ed Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Tue, 1 Dec 2020 17:05:55 -0500 Subject: [PATCH] Fix version parser regex for packaging (#22581) This fixes the version parser regex to allow it to handle double digit major/minor/patch values. It fixes the FileVersion added to Windows exe files. (cherry picked from commit bb481b499a418412f0867a1ad7505b6849a1a068) --- CHANGELOG.next.asciidoc | 2 ++ dev-tools/mage/common.go | 2 +- dev-tools/mage/common_test.go | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 1171c8a3f217..02eb465bbc27 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -153,12 +153,14 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fix memory leak and events duplication in docker autodiscover and add_docker_metadata. {pull}21851[21851] - Fix parsing of expired licences. {issue}21112[21112] {pull}22180[22180] - Fix duplicated pod events in kubernetes autodiscover for pods with init or ephemeral containers. {pull}22438[22438] +- Fix FileVersion contained in Windows exe files. {pull}22581[22581] - Fix index template loading when the new index format is selected. {issue}22482[22482] {pull}22682[22682] - Log debug message if the Kibana dashboard can not be imported from the archive because of the invalid archive directory structure {issue}12211[12211], {pull}13387[13387] - Periodic metrics in logs will now report `libbeat.output.events.active` and `beat.memstats.rss` as gauges (rather than counters). {pull}22877[22877] - Use PROGRAMDATA environment variable instead of C:\ProgramData for windows install service {pull}22874[22874] + *Auditbeat* - system/socket: Fixed compatibility issue with kernel 5.x. {pull}15771[15771] diff --git a/dev-tools/mage/common.go b/dev-tools/mage/common.go index e4b93625b75c..dd0a2fd56c2c 100644 --- a/dev-tools/mage/common.go +++ b/dev-tools/mage/common.go @@ -782,7 +782,7 @@ func binaryExtension(goos string) string { return "" } -var parseVersionRegex = regexp.MustCompile(`(?m)^[^\d]*(?P\d)+\.(?P\d)+(?:\.(?P\d)+.*)?$`) +var parseVersionRegex = regexp.MustCompile(`(?m)^[^\d]*(?P\d+)\.(?P\d+)(?:\.(?P\d+).*)?$`) // ParseVersion extracts the major, minor, and optional patch number from a // version string. diff --git a/dev-tools/mage/common_test.go b/dev-tools/mage/common_test.go index e4ce81505ad0..8b6ac8bd7323 100644 --- a/dev-tools/mage/common_test.go +++ b/dev-tools/mage/common_test.go @@ -33,6 +33,8 @@ func TestParseVersion(t *testing.T) { {"1.2.3-SNAPSHOT", 1, 2, 3}, {"1.2.3rc1", 1, 2, 3}, {"1.2", 1, 2, 0}, + {"7.10.0", 7, 10, 0}, + {"10.01.22", 10, 1, 22}, } for _, tc := range tests {