Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/github/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,14 +1447,16 @@ 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,
issueModel?: IssueModel,
defaults?: PullRequestDefaults,
user?: string,
): Promise<string> {
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':
Expand Down Expand Up @@ -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) {
Expand Down