Skip to content

Commit 18c6a7d

Browse files
author
Simon Engledew
committed
fix another edge case
1 parent 1dc40ba commit 18c6a7d

6 files changed

Lines changed: 38 additions & 8 deletions

File tree

lib/actions-util.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions-util.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,20 @@ test("validateWorkflow() for a range of malformed workflows", (t) => {
285285
t.deepEqual(actionsutil.validateWorkflow(1 as any), [
286286
actionsutil.WorkflowErrors.MissingHooks,
287287
]);
288+
289+
t.deepEqual(
290+
actionsutil.validateWorkflow({
291+
on: {
292+
push: {
293+
branches: 1,
294+
},
295+
pull_request: {
296+
branches: 1,
297+
},
298+
},
299+
} as any),
300+
[]
301+
);
288302
});
289303

290304
test("validateWorkflow() when on.pull_request for every branch but push specifies branches", (t) => {

src/actions-util.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,13 @@ function branchesToArray(branches?: string | null | string[]): string[] | "**" {
168168
if (typeof branches === "string") {
169169
return [branches];
170170
}
171-
if (!branches || branches.length === 0) {
172-
return "**";
171+
if (Array.isArray(branches)) {
172+
if (branches.length === 0) {
173+
return "**";
174+
}
175+
return branches;
173176
}
174-
return branches;
177+
return "**";
175178
}
176179

177180
enum MissingTriggers {

0 commit comments

Comments
 (0)