fix(node): trim spaces from expected version

resolves #3583
This commit is contained in:
Jan De Dobbeleer 2023-03-13 21:57:56 +01:00 committed by Jan De Dobbeleer
parent 71f81a0b79
commit 8dbdc160db
2 changed files with 3 additions and 1 deletions

View file

@ -76,7 +76,8 @@ func (n *Node) matchesVersionFile() (string, bool) {
n.language.version.Patch,
)
version := strings.TrimPrefix(fileVersion, "v")
version := strings.TrimSpace(fileVersion)
version = strings.TrimPrefix(version, "v")
return version, regex.MatchString(re, fileVersion)
}

View file

@ -24,6 +24,7 @@ func TestNodeMatchesVersionFile(t *testing.T) {
}{
{Case: "no file context", Expected: true, RCVersion: ""},
{Case: "version match", Expected: true, ExpectedVersion: "1.2.3", RCVersion: "1.2.3"},
{Case: "version match with newline", Expected: true, ExpectedVersion: "1.2.3", RCVersion: "1.2.3\n"},
{Case: "version mismatch", Expected: false, ExpectedVersion: "3.2.1", RCVersion: "3.2.1"},
{Case: "version match in other format", Expected: true, ExpectedVersion: "1.2.3", RCVersion: "v1.2.3"},
{Case: "version match without patch", Expected: true, ExpectedVersion: "1.2", RCVersion: "1.2"},