From 9b8a49c34edc6075aad7213da5b8efc87809dcb1 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sun, 18 Aug 2024 21:26:03 +0200 Subject: [PATCH] fix: prevent accidental branch backport duplication --- src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index fb3f796..ce76700 100644 --- a/src/index.ts +++ b/src/index.ts @@ -543,13 +543,14 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => { name: 'backport to branch', command: /^run backport-to (([^,]*)(, ?([^,]*))*)/, execute: async (targetBranches: string) => { - const branches = targetBranches.split(',').map((b) => b.trim()); + const branches = new Set( + targetBranches.split(',').map((b) => b.trim()), + ); for (const branch of branches) { robot.log( `Initiating backport to \`${branch}\` from 'backport-to' comment`, ); - if (!branch.trim()) continue; const pr = ( await context.octokit.pulls.get( context.repo({ pull_number: issue.number }),