The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 11:00 UTC
fix(azure-devops): pull request titles like `@notes.txt` are saved as typed (#37110)
Julius Marminge committed
Nov 15, 2026 at 02:54 UTC
70abb6c002c093ddb44beb0ccba4424f446e3f71
4 files changed
+115
-27
packages/source-control-azure-devops/src/server/AzureDevOpsCli.test.ts
+30
@@ -287,6 +287,36 @@ describe("AzureDevOpsCli.layer", () => {
287
}).pipe(Effect.provide(layer)),
288
);
289
290
+ it.effect("sends a title that looks like `@path` as text, not as a file for az to read", () =>
291
+ Effect.gen(function* () {
292
+ const az = yield* AzureDevOpsCli.AzureDevOpsCli;
293
+ for (const title of ["@notes.txt", "a=@notes.txt"]) {
294
+ mockRun.mockReturnValueOnce(Effect.succeed(processOutput("{}")));
295
+ yield* az.createPullRequest({
296
+ cwd: "/somewhere",
297
+ baseBranch: "main",
298
+ headSelector: "feature",
299
+ title,
300
+ bodyFile: "/tmp/body.md",
301
+ });
302
+
303
+ // az replaces an argument that starts with `@`, or whose text after the first `=` does, with that file's contents.
304
+ const fileReads = (mockRun.mock.calls.at(-1)?.[0].args ?? []).flatMap((arg) => {
305
+ const value = arg.startsWith("@") ? arg : arg.slice(arg.indexOf("=") + 1);
306
+ return (arg.startsWith("@") || arg.includes("=")) && value.startsWith("@")
307
+ ? [value.slice(1)]
308
+ : [];
309
+ });
310
+ expect(fileReads).not.toContain("notes.txt");
311
+ expect(mockRun.mock.calls.at(-1)?.[0].stdin).toBe(
312
+ title.startsWith("@") ? title : undefined,
313
+ );
314
+ // az expands a separate `@file` value a second time, so a body of `@notes.txt` read notes.txt.
315
+ expect(mockRun.mock.calls.at(-1)?.[0].args).toContain("--description=@/tmp/body.md");
316
+ }
317
+ }).pipe(Effect.provide(layer)),
318
+ );
319
+
320
it.effect("preserves VCS causes without copying upstream details into messages", () =>
321
Effect.gen(function* () {
322
const cause = new VcsProcessExitError({
packages/source-control-azure-devops/src/server/AzureDevOpsCli.ts
+20
-8
@@ -223,6 +223,7 @@ export class AzureDevOpsCli extends Context.Service<
223
readonly maxOutputBytes?: number;
224
/** The remote T3 selected; without one, the checkout's primary remote scopes the command. */
225
readonly remoteUrl?: string;
226
+ readonly stdin?: string;
227
}) => Effect.Effect<SourceControlHost.SourceControlProcessOutput, AzureDevOpsCliError>;
228
229
readonly listPullRequests: (input: {
@@ -507,6 +508,15 @@ export const azureCliInvocation = Effect.fn("AzureDevOpsCli.invocation")(functio
508
} satisfies AzureCliInvocation);
509
});
510
511
+/**
512
+ * `--option=value` for free text. az replaces a value starting with `@` by that file's
513
+ * contents; `@-` reads it from stdin instead, which reaches az wherever it runs (WSL included).
514
+ */
515
+export const textOption = (option: string, value: string) =>
516
+ value.startsWith("@")
517
+ ? { arg: `${option}=@-`, stdin: value }
518
+ : { arg: `${option}=${value}`, stdin: undefined };
519
+
520
/** @public */
521
export const make = Effect.gen(function* () {
522
const { process } = yield* SourceControlHost.SourceControlHost;
@@ -554,6 +564,7 @@ export const make = Effect.gen(function* () {
564
args: [...invocation.args, ...args],
565
cwd: input.cwd,
566
...(invocation.env === undefined ? {} : { env: invocation.env }),
567
+ ...(input.stdin === undefined ? {} : { stdin: input.stdin }),
568
classifyFailure: classifyAzFailure,
569
notFoundDetail: "Pull request not found.",
570
timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS,
@@ -717,6 +728,9 @@ export const make = Effect.gen(function* () {
728
);
729
}),
730
createPullRequest: Effect.fn("AzureDevOpsCli.createPullRequest")(function (input) {
731
+ // A full ref keeps a branch named `@...` from reading as a file; az accepts either form.
732
+ const branch = (name: string) => (name.startsWith("@") ? `refs/heads/${name}` : name);
733
+ const title = textOption("--title", input.title);
734
return execute({
735
cwd: input.cwd,
736
...remoteOf(input),
@@ -727,15 +741,13 @@ export const make = Effect.gen(function* () {
741
"--only-show-errors",
742
"--detect",
743
"true",
730
- "--target-branch",
731
- input.target?.refName ?? input.baseBranch,
732
- "--source-branch",
733
- SourceControlProvider.sourceBranch(input),
734
- "--title",
735
- input.title,
736
- "--description",
737
- `@${input.bodyFile}`,
744
+ `--target-branch=${branch(input.target?.refName ?? input.baseBranch)}`,
745
+ `--source-branch=${branch(SourceControlProvider.sourceBranch(input))}`,
746
+ title.arg,
747
+ // Joined: az expands a separate `@file` value again, so a body of `@path` read that file.
748
+ `--description=@${input.bodyFile}`,
749
],
750
+ ...(title.stdin === undefined ? {} : { stdin: title.stdin }),
751
}).pipe(Effect.asVoid);
752
}),
753
getDefaultBranch: Effect.fn("AzureDevOpsCli.getDefaultBranch")(function (input) {
packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestCli.test.ts
+30
@@ -447,6 +447,36 @@ layer("AzureDevOpsPullRequestCli.layer", (it) => {
447
}),
448
);
449
450
+ it.effect(
451
+ "sends a title or description that looks like `@path` as text, not as a file for az to read",
452
+ () =>
453
+ Effect.gen(function* () {
454
+ mockedExecute.mockReturnValue(Effect.succeed(output("{}")));
455
+ const cli = yield* AzureDevOpsPullRequestCli.AzureDevOpsPullRequestCli;
456
+
457
+ yield* cli.updatePullRequest({
458
+ cwd: "/w",
459
+ number: 42,
460
+ title: "@notes.txt",
461
+ body: "@notes.txt",
462
+ });
463
+
464
+ // az replaces an argument that starts with `@`, or whose text after the first `=` does, with that file's contents.
465
+ const fileReads = argsOfCall(0).flatMap((arg) => {
466
+ const value = arg.startsWith("@") ? arg : arg.slice(arg.indexOf("=") + 1);
467
+ return (arg.startsWith("@") || arg.includes("=")) && value.startsWith("@")
468
+ ? [value.slice(1)]
469
+ : [];
470
+ });
471
+ expect(fileReads).not.toContain("notes.txt");
472
+ // Each `@` value goes over stdin, which reaches az wherever it runs; one per call.
473
+ expect(mockedExecute.mock.calls.map(([call]) => call.stdin)).toEqual([
474
+ "@notes.txt",
475
+ "@notes.txt",
476
+ ]);
477
+ }),
478
+ );
479
+
480
it.effect("names the head's blob as what a cleared file was cleared at", () =>
481
Effect.gen(function* () {
482
mockedExecute
packages/source-control-azure-devops/src/server/AzureDevOpsPullRequestCli.ts
+35
-19
@@ -818,25 +818,41 @@ export const make = Effect.gen(function* () {
818
),
819
820
updatePullRequest: Effect.fn("AzureDevOpsPullRequestCli.updatePullRequest")(function (input) {
821
- return azure
822
- .execute({
823
- cwd: input.cwd,
824
- args: [
825
- "repos",
826
- "pr",
827
- "update",
828
- ...detectArgs,
829
- "--id",
830
- String(input.number),
831
- // One argv entry preserves leading dashes and multi-string descriptions.
832
- ...(input.title === undefined ? [] : [`--title=${input.title}`]),
833
- ...(input.body === undefined ? [] : [`--description=${input.body}`]),
834
- "--only-show-errors",
835
- "--output",
836
- "json",
837
- ],
838
- })
839
- .pipe(Effect.asVoid);
821
+ // One argv entry preserves leading dashes and multi-string descriptions.
822
+ const fields = [
823
+ ...(input.title === undefined ? [] : [AzureDevOpsCli.textOption("--title", input.title)]),
824
+ ...(input.body === undefined
825
+ ? []
826
+ : [AzureDevOpsCli.textOption("--description", input.body)]),
827
+ ];
828
+ // az has one stdin, so each value read from it needs its own call.
829
+ const batches =
830
+ fields.filter((field) => field.stdin !== undefined).length > 1
831
+ ? fields.map((field) => [field])
832
+ : [fields];
833
+ return Effect.forEach(
834
+ batches,
835
+ (batch) => {
836
+ const stdin = batch.find((field) => field.stdin !== undefined)?.stdin;
837
+ return azure.execute({
838
+ cwd: input.cwd,
839
+ args: [
840
+ "repos",
841
+ "pr",
842
+ "update",
843
+ ...detectArgs,
844
+ "--id",
845
+ String(input.number),
846
+ ...batch.map((field) => field.arg),
847
+ "--only-show-errors",
848
+ "--output",
849
+ "json",
850
+ ],
851
+ ...(stdin === undefined ? {} : { stdin }),
852
+ });
853
+ },
854
+ { discard: true },
855
+ );
856
}),
857
});
858
});