Fix for numerical branch names

This commit is contained in:
Simon Engledew 2020-12-17 19:18:09 +00:00
parent 9f7bdecc04
commit 2d00e8c6f7
No known key found for this signature in database
GPG key ID: 84302E7B02FE8BCE
6 changed files with 60 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import test from "ava";
import * as yaml from "js-yaml";
import sinon from "sinon";
import * as actionsutil from "./actions-util";
@ -400,3 +401,34 @@ test("patternIsSuperset()", (t) => {
)
);
});
test("validateWorkflow() when branches contain dots", (t) => {
const errors = actionsutil.validateWorkflow(
yaml.safeLoad(`
on:
push:
branches: [4.1, master]
pull_request:
# The branches below must be a subset of the branches above
branches: [4.1, master]
`)
);
t.deepEqual(errors, []);
});
test("validateWorkflow() when on.push has a trailing comma", (t) => {
const errors = actionsutil.validateWorkflow(
yaml.safeLoad(`
name: "CodeQL"
on:
push:
branches: [master, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
`)
);
t.deepEqual(errors, []);
});

View file

@ -143,6 +143,7 @@ function escapeRegExp(string) {
function patternToRegExp(value) {
return new RegExp(
`^${value
.toString()
.split(GLOB_PATTERN)
.reduce(function (arr, cur) {
if (cur === "**") {