Skip to content

Commit 118aac5

Browse files
authored
Special case queries for copilot (#6817)
Fixes #6741
1 parent 1e61bd4 commit 118aac5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/github/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,14 +1447,16 @@ function computeSinceValue(sinceValue: string | undefined): string {
14471447
return `${date.getFullYear()}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
14481448
}
14491449

1450+
const COPILOT_PATTERN = /\:(Copilot|copilot)(\s|$)/g;
1451+
14501452
const VARIABLE_PATTERN = /\$\{([^-]*?)(-.*?)?\}/g;
14511453
export async function variableSubstitution(
14521454
value: string,
14531455
issueModel?: IssueModel,
14541456
defaults?: PullRequestDefaults,
14551457
user?: string,
14561458
): Promise<string> {
1457-
return value.replace(VARIABLE_PATTERN, (match: string, variable: string, extra: string) => {
1459+
const withVariables = value.replace(VARIABLE_PATTERN, (match: string, variable: string, extra: string) => {
14581460
let result: string;
14591461
switch (variable) {
14601462
case 'user':
@@ -1491,6 +1493,12 @@ export async function variableSubstitution(
14911493
Logger.debug(`${match} -> ${result}`, 'VariableSubstitution');
14921494
return result;
14931495
});
1496+
1497+
// not a variable, but still a substitution that needs to be done
1498+
const withCopilot = withVariables.replace(COPILOT_PATTERN, () => {
1499+
return `:copilot-swe-agent[bot]`;
1500+
});
1501+
return withCopilot;
14941502
}
14951503

14961504
export function getIssueNumberLabel(issue: IssueModel, repo?: PullRequestDefaults) {

0 commit comments

Comments
 (0)