From 70f9a26015fdcac74b9c0f22460890cfa4af5be4 Mon Sep 17 00:00:00 2001 From: Alex Ross <38270282+alexr00@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:17:26 +0200 Subject: [PATCH] Special case queries for copilot Fixes #6741 --- src/github/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/github/utils.ts b/src/github/utils.ts index 9703c019b1..accdd9c5d3 100644 --- a/src/github/utils.ts +++ b/src/github/utils.ts @@ -1447,6 +1447,8 @@ function computeSinceValue(sinceValue: string | undefined): string { return `${date.getFullYear()}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`; } +const COPILOT_PATTERN = /\:(Copilot|copilot)(\s|$)/g; + const VARIABLE_PATTERN = /\$\{([^-]*?)(-.*?)?\}/g; export async function variableSubstitution( value: string, @@ -1454,7 +1456,7 @@ export async function variableSubstitution( defaults?: PullRequestDefaults, user?: string, ): Promise { - return value.replace(VARIABLE_PATTERN, (match: string, variable: string, extra: string) => { + const withVariables = value.replace(VARIABLE_PATTERN, (match: string, variable: string, extra: string) => { let result: string; switch (variable) { case 'user': @@ -1491,6 +1493,12 @@ export async function variableSubstitution( Logger.debug(`${match} -> ${result}`, 'VariableSubstitution'); return result; }); + + // not a variable, but still a substitution that needs to be done + const withCopilot = withVariables.replace(COPILOT_PATTERN, () => { + return `:copilot-swe-agent[bot]`; + }); + return withCopilot; } export function getIssueNumberLabel(issue: IssueModel, repo?: PullRequestDefaults) {