Skip to content

Commit 5ba2c5d

Browse files
fix(server): an Azure DevOps pull request list no longer stops other hosts' creates from linking
AI-assisted; verified with the tests and tools listed above.
1 parent dece8d5 commit 5ba2c5d

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,12 @@ describe("PullRequestSyncReactor", () => {
17781778
output: AZURE_PULL_REQUEST_CREATED,
17791779
linked: [],
17801780
},
1781+
{
1782+
name: "a GitHub pull request created after listing Azure DevOps pull requests",
1783+
input: "az repos pr list --top 1 && gh pr create --fill",
1784+
output: `[\n${AZURE_PULL_REQUEST_CREATED}\n]\nhttps://github.com/owner/repository/pull/124\n`,
1785+
linked: [124],
1786+
},
17811787
{
17821788
name: "an Azure DevOps pull request after a push",
17831789
input:

‎apps/server/src/orchestration-v2/PullRequestSyncReactor.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const QUOTED_OR_COMMENT = /'[^']*'|"(?:\\[\s\S]|[^"\\])*"|(?<=^|[\s;&|(])#[^\n]*
8484
const COMMAND_SEPARATOR = /&&|\|\||[;|\n]/u;
8585
// Commands that print other change requests' URLs, so output beside them proves nothing.
8686
const LISTS_CHANGE_REQUESTS =
87-
/\b(?:gh\s+(?:pr\s+(?:list|status)|search\s+prs|api)|glab\s+(?:mr\s+list|api)|az\s+repos\s+pr\s+list)\b/u;
87+
/\b(?:gh\s+(?:pr\s+(?:list|status)|search\s+prs|api)|glab\s+(?:mr\s+list|api))\b/u;
8888
const URL_LINE = /^[ \t]*(https?:\/\/\S+)[ \t]*$/gmu;
8989

9090
/** The script a shell input runs, unwrapped from Codex's `sh -lc`. */
@@ -158,7 +158,8 @@ export function changeRequestsCreatedBy(input: string, output: string) {
158158
.join("\n");
159159
const created = new Map<string, ThreadPullRequestKey & { readonly url: string }>();
160160
for (const { definition, run } of CREATE_COMMANDS) {
161-
if (code.match(run) === null) continue;
161+
if (code.match(run) === null || definition.changeRequestListCommand?.test(otherCommands))
162+
continue;
162163
const printed =
163164
definition.changeRequestCreateOutputUrls?.(output) ??
164165
Array.from(output.matchAll(URL_LINE), ([, url = ""]) => url);

‎packages/source-control-azure-devops/src/shared/definition.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export const definition = defineSourceControl({
118118
changeRequestCloseCommand:
119119
/\baz\s+repos\s+pr\s+update\b[^;&|]*--status[\s=]+["']?(?:completed|abandoned)\b/u,
120120
changeRequestCreateCommand: /\baz\s+repos\s+pr\s+create\b/u,
121+
changeRequestListCommand: /\baz\s+repos\s+pr\s+list\b/u,
121122
// `az` prints the new pull request as JSON whose `url` is its REST API address.
122123
changeRequestCreateOutputUrls: azureDevOpsCreatedPullRequestUrls,
123124
authorProfileUrl: () => null,

‎packages/source-control-core/src/shared/definition.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ export interface SourceControlDefinition {
280280
* with no such CLI.
281281
*/
282282
readonly changeRequestCreateCommand?: RegExp;
283+
/**
284+
* Matches a shell command that prints this host's existing change requests in the form its
285+
* create command does, so output beside it proves nothing about what a create opened.
286+
*/
287+
readonly changeRequestListCommand?: RegExp;
283288
/**
284289
* The change request URLs the create command's output names, for a CLI that does not print each
285290
* on a line of its own. Absent means those lines.

0 commit comments

Comments
 (0)