Open History to see the last commit
1import * as Context from "effect/Context";
2import * as Effect from "effect/Effect";
3import * as Layer from "effect/Layer";
4import * as Result from "effect/Result";
5import * as Schema from "effect/Schema";
6import type {
7 PullRequestAction,
8 PullRequestComment,
9 PullRequestInvolvement,
10 PullRequestListState,
11 PullRequestMergeMethod,
12} from "@t3tools/contracts";
13
14import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
15import {
16 decodeItemContentJson,
17 decodeIterationChangesJson,
18 decodeIterationsJson,
19 decodePullRequestJson,
20 decodePullRequestListJson,
21 decodeThreadsJson,
22 decodeViewerJson,
23 type AzureDevOpsChangeEntry,
24 type AzureDevOpsItemContent,
25 type AzureDevOpsIteration,
26 type AzureDevOpsPullRequest,
27 type AzureDevOpsRepositoryLocation,
28} from "./azureDevOpsPullRequestJson.ts";
29import type { ProviderListCursor } from "@t3tools/source-control-core/server/PullRequestProvider";
30
31export class AzureDevOpsPullRequestReadError extends Schema.TaggedError<AzureDevOpsPullRequestReadError>()(
32 "AzureDevOpsPullRequestReadError",
33 {
34 command: Schema.Literal("az"),
35 cwd: Schema.String,
36 operation: Schema.String,
37 cause: Schema.Defect(),
38 },
39) {
40 get detail(): string {
41 return `Azure CLI returned an unreadable ${this.operation} response.`;
42 }
43
44 override get message(): string {
45 return `Azure CLI failed in ${this.operation}: ${this.detail}`;
46 }
47}
48
49export class AzureDevOpsViewerUnavailableError extends Schema.TaggedError<AzureDevOpsViewerUnavailableError>()(
50 "AzureDevOpsViewerUnavailableError",
51 {
52 command: Schema.Literal("az"),
53 cwd: Schema.String,
54 },
55) {
56 get detail(): string {
57 return "Azure CLI could not name the signed-in account. Run `az login` and retry.";
58 }
59
60 override get message(): string {
61 return `Azure CLI failed in getViewer: ${this.detail}`;
62 }
63}
64
65export class AzureDevOpsPullRequestIncompleteError extends Schema.TaggedError<AzureDevOpsPullRequestIncompleteError>()(
66 "AzureDevOpsPullRequestIncompleteError",
67 {
68 command: Schema.Literal("az"),
69 cwd: Schema.String,
70 number: Schema.Int,
71 },
72) {
73 get detail(): string {
74 return "Azure DevOps returned no branch or link for the pull request.";
75 }
76
77 override get message(): string {
78 return `Azure CLI failed in getPullRequest: ${this.detail}`;
79 }
80}
81
82export class AzureDevOpsReviewerNameError extends Schema.TaggedError<AzureDevOpsReviewerNameError>()(
83 "AzureDevOpsReviewerNameError",
84 {
85 command: Schema.Literal("az"),
86 cwd: Schema.String,
87 },
88) {
89 get detail(): string {
90 return "A reviewer is named by an email address or an identity id.";
91 }
92
93 override get message(): string {
94 return `Azure CLI failed in setPullRequestReviewers: ${this.detail}`;
95 }
96}
97
98export type AzureDevOpsPullRequestCliError =
99 | AzureDevOpsCli.AzureDevOpsCliError
100 | AzureDevOpsPullRequestReadError
101 | AzureDevOpsPullRequestIncompleteError
102 | AzureDevOpsReviewerNameError
103 | AzureDevOpsViewerUnavailableError;
104
105const REST_API_VERSION = "7.1";
106const PULL_REQUEST_LIST_MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
107/**
108 * A full page of change entries is two thousand files, each carrying its path, its url and
109 * several object ids, which is past the megabyte a read is given by default.
110 */
111const CHANGE_ENTRIES_MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
112/**
113 * Four times the megabyte of file the other hosts hand over, because Azure has no route that
114 * serves the bytes themselves: the file arrives inside a JSON envelope, escaped if it is text and
115 * base64 if it is not, and both are larger than the file they carry.
116 */
117const ITEM_CONTENT_MAX_OUTPUT_BYTES = 4 * 1024 * 1024;
118/**
119 * Neither route pages, so each answers with the whole of it at once and grows with how
120 * long the review ran rather than with how large the change is.
121 */
122const REVIEW_HISTORY_MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
123
124/** Azure's own ceiling for one page of an iteration's changes. */
125const CHANGE_ENTRIES_PER_PAGE = 2000;
126
127/**
128 * Where following the pages stops, counted in the entries Azure was asked to skip rather than in
129 * the files that survived decoding: a page can be entirely folders and other entries a review has
130 * nothing to show for, and bounding on what was kept would follow such a change forever.
131 */
132const MAX_CHANGE_ENTRIES = 10_000;
133
134export interface AzureDevOpsIterationChanges {
135 readonly changes: ReadonlyArray<AzureDevOpsChangeEntry>;
136 readonly truncated: boolean;
137}
138
139export class AzureDevOpsPullRequestCli extends Context.Service<
140 AzureDevOpsPullRequestCli,
141 {
142 readonly getViewer: (input: {
143 readonly cwd: string;
144 }) => Effect.Effect<string, AzureDevOpsPullRequestCliError>;
145
146 readonly listPullRequests: (input: {
147 readonly cwd: string;
148 readonly repository: string;
149 readonly state: PullRequestListState;
150 readonly involvement: PullRequestInvolvement;
151 readonly viewer: string;
152 readonly limit: number;
153 /**
154 * Where to carry on from. Azure has no date filter for a pull request listing, so the only
155 * part of a cursor it can use is how many rows have already been handed over.
156 */
157 readonly cursor?: ProviderListCursor | undefined;
158 }) => Effect.Effect<
159 {
160 readonly items: ReadonlyArray<AzureDevOpsPullRequest>;
161 readonly truncated: boolean;
162 readonly cursorAdvance: number;
163 },
164 AzureDevOpsPullRequestCliError
165 >;
166
167 readonly getPullRequest: (input: {
168 readonly cwd: string;
169 readonly number: number;
170 }) => Effect.Effect<AzureDevOpsPullRequest, AzureDevOpsPullRequestCliError>;
171
172 /** Threads are not reachable through `az repos pr`, so they come from the REST API. */
173 readonly listThreads: (input: {
174 readonly cwd: string;
175 readonly location: AzureDevOpsRepositoryLocation;
176 readonly number: number;
177 }) => Effect.Effect<ReadonlyArray<PullRequestComment>, AzureDevOpsPullRequestCliError>;
178
179 /**
180 * Azure hangs the changed files off an iteration rather than off the pull
181 * request, so reading a diff starts here.
182 */
183 readonly listIterations: (input: {
184 readonly cwd: string;
185 readonly location: AzureDevOpsRepositoryLocation;
186 readonly number: number;
187 }) => Effect.Effect<ReadonlyArray<AzureDevOpsIteration>, AzureDevOpsPullRequestCliError>;
188
189 /**
190 * What one iteration changed, against the merge base rather than against the previous push,
191 * which is the whole of the pull request rather than the latest slice of it.
192 */
193 readonly listIterationChanges: (input: {
194 readonly cwd: string;
195 readonly location: AzureDevOpsRepositoryLocation;
196 readonly number: number;
197 readonly iterationId: number;
198 }) => Effect.Effect<AzureDevOpsIterationChanges, AzureDevOpsPullRequestCliError>;
199
200 /**
201 * One file's text at one commit. Azure has no diff route that carries content, so both sides
202 * of every changed file are read this way and the patch is made from them here.
203 */
204 readonly readItemContent: (input: {
205 readonly cwd: string;
206 readonly location: AzureDevOpsRepositoryLocation;
207 readonly path: string;
208 readonly commit: string;
209 }) => Effect.Effect<AzureDevOpsItemContent, AzureDevOpsPullRequestCliError>;
210
211 readonly runPullRequestAction: (input: {
212 readonly cwd: string;
213 readonly number: number;
214 readonly action: PullRequestAction;
215 readonly mergeMethod?: PullRequestMergeMethod;
216 }) => Effect.Effect<void, AzureDevOpsPullRequestCliError>;
217
218 readonly updatePullRequest: (input: {
219 readonly cwd: string;
220 readonly number: number;
221 readonly title?: string | undefined;
222 readonly body?: string | undefined;
223 }) => Effect.Effect<void, AzureDevOpsPullRequestCliError>;
224
225 /**
226 * `az repos pr reviewer` is the whole of what Azure offers here: it adds and removes named
227 * identities, and has no counterpart that says who could be named.
228 */
229 readonly setPullRequestReviewers: (input: {
230 readonly cwd: string;
231 readonly number: number;
232 readonly reviewers: ReadonlyArray<string>;
233 readonly requested: boolean;
234 }) => Effect.Effect<void, AzureDevOpsPullRequestCliError>;
235 }
236>()("@t3tools/source-control-azure-devops/server/AzureDevOpsPullRequestCli") {}
237
238function statusArgs(state: PullRequestListState): ReadonlyArray<string> {
239 switch (state) {
240 case "open":
241 return ["--status", "active"];
242 case "merged":
243 return ["--status", "completed"];
244 case "closed":
245 return ["--status", "abandoned"];
246 case "all":
247 return ["--status", "all"];
248 }
249}
250
251function involvementArgs(input: {
252 readonly involvement: PullRequestInvolvement;
253 readonly viewer: string;
254}): ReadonlyArray<string> {
255 switch (input.involvement) {
256 case "authored":
257 return ["--creator", input.viewer];
258 case "reviewing":
259 return ["--reviewer", input.viewer];
260 case "all":
261 return [];
262 }
263}
264
265function actionArgs(
266 action: PullRequestAction,
267 mergeMethod: PullRequestMergeMethod | undefined,
268): ReadonlyArray<string> {
269 switch (action) {
270 case "merge":
271 return ["--status", "completed", "--squash", mergeMethod === "squash" ? "true" : "false"];
272 case "enable-auto-merge":
273 return [
274 "--auto-complete",
275 "true",
276 ...(mergeMethod === undefined
277 ? []
278 : ["--squash", mergeMethod === "squash" ? "true" : "false"]),
279 ];
280 case "disable-auto-merge":
281 return ["--auto-complete", "false"];
282 case "ready":
283 return ["--draft", "false"];
284 case "draft":
285 return ["--draft", "true"];
286 case "close":
287 return ["--status", "abandoned"];
288 case "update-branch":
289 return [];
290 case "reopen":
291 return ["--status", "active"];
292 case "revert":
293 case "approve-workflows":
294 case "delete-branch":
295 throw new Error(`Azure DevOps pull request action ${action} is unsupported`);
296 }
297}
298
299/**
300 * The dash is the whole point — these are argv, and a value that looks like a
301 * flag stops being a value.
302 */
303function isReviewerName(value: string): boolean {
304 const name = value.trim();
305 return name.length > 0 && !name.startsWith("-");
306}
307
308/** @public Service construction is part of the canonical Effect module API. */
309export const make = Effect.gen(function* () {
310 const azure = yield* AzureDevOpsCli.AzureDevOpsCli;
311
312 // The remote takes three shapes and only `az` knows how to read all of them.
313 const detectArgs = ["--detect", "true"] as const;
314
315 const executeJson = (input: {
316 readonly cwd: string;
317 readonly args: ReadonlyArray<string>;
318 readonly maxOutputBytes?: number;
319 }) =>
320 azure.execute({
321 cwd: input.cwd,
322 args: [...input.args, "--only-show-errors", "--output", "json"],
323 ...(input.maxOutputBytes === undefined ? {} : { maxOutputBytes: input.maxOutputBytes }),
324 });
325
326 /**
327 * Used in place of `az rest` because it signs in the way the azure-devops extension does: `az
328 * rest` mints its own token against the tenant `az` defaults to, and an organisation in any
329 * other tenant answers that with a sign-in page, which arrives here as unreadable output
330 * rather than as a failure.
331 */
332 const invoke = <A>(input: {
333 readonly cwd: string;
334 readonly operation: string;
335 readonly resource: string;
336 readonly routeParameters: ReadonlyArray<string>;
337 readonly queryParameters?: ReadonlyArray<string>;
338 readonly maxOutputBytes?: number;
339 readonly decode: (raw: string) => Result.Result<A, unknown>;
340 }): Effect.Effect<A, AzureDevOpsPullRequestCliError> =>
341 executeJson({
342 cwd: input.cwd,
343 ...(input.maxOutputBytes === undefined ? {} : { maxOutputBytes: input.maxOutputBytes }),
344 args: [
345 "devops",
346 "invoke",
347 ...detectArgs,
348 "--area",
349 "git",
350 "--resource",
351 input.resource,
352 "--api-version",
353 REST_API_VERSION,
354 "--route-parameters",
355 ...input.routeParameters,
356 ...(input.queryParameters === undefined
357 ? []
358 : ["--query-parameters", ...input.queryParameters]),
359 ],
360 }).pipe(
361 Effect.flatMap((result) => {
362 const decoded = input.decode(result.stdout.trim());
363 return Result.isSuccess(decoded)
364 ? Effect.succeed(decoded.success)
365 : Effect.fail(
366 new AzureDevOpsPullRequestReadError({
367 command: "az",
368 cwd: input.cwd,
369 operation: input.operation,
370 cause: decoded.failure,
371 }),
372 );
373 }),
374 );
375
376 /**
377 * Azure names its own items with a leading slash, which the repository paths carried around
378 * here have had taken off so they match the patch and the viewed mark. Put it back on the way
379 * out, because the items route is documented in Azure's own spelling.
380 */
381 const toItemPath = (path: string) => (path.startsWith("/") ? path : `/${path}`);
382
383 const repositoryRoute = (location: AzureDevOpsRepositoryLocation): ReadonlyArray<string> => [
384 `project=${location.project}`,
385 `repositoryId=${location.repository}`,
386 ];
387
388 const pullRequestRoute = (input: {
389 readonly location: AzureDevOpsRepositoryLocation;
390 readonly number: number;
391 }): ReadonlyArray<string> => [
392 ...repositoryRoute(input.location),
393 `pullRequestId=${input.number}`,
394 ];
395
396 /**
397 * Azure pages by raw offset. Keep reading when malformed rows leave the decoded page short, and
398 * retain the raw count so the next public cursor skips every row this walk consumed.
399 */
400 const listPullRequestPage = (input: {
401 readonly cwd: string;
402 readonly repository: string;
403 readonly state: PullRequestListState;
404 readonly involvement: PullRequestInvolvement;
405 readonly viewer: string;
406 readonly limit: number;
407 readonly skip: number;
408 readonly cursorAdvance: number;
409 readonly items: ReadonlyArray<AzureDevOpsPullRequest>;
410 }): Effect.Effect<
411 {
412 readonly items: ReadonlyArray<AzureDevOpsPullRequest>;
413 readonly truncated: boolean;
414 readonly cursorAdvance: number;
415 },
416 AzureDevOpsPullRequestCliError
417 > => {
418 const remaining = input.limit - input.items.length;
419 const top = remaining + 1;
420 return executeJson({
421 cwd: input.cwd,
422 maxOutputBytes: PULL_REQUEST_LIST_MAX_OUTPUT_BYTES,
423 args: [
424 "repos",
425 "pr",
426 "list",
427 ...detectArgs,
428 "--repository",
429 input.repository,
430 ...statusArgs(input.state),
431 ...involvementArgs(input),
432 "--include-links",
433 ...(input.skip === 0 ? [] : ["--skip", String(input.skip)]),
434 "--top",
435 String(top),
436 ],
437 }).pipe(
438 Effect.flatMap((result) => {
439 const raw = result.stdout.trim();
440 if (raw.length === 0) {
441 return Effect.succeed({
442 items: input.items,
443 truncated: false,
444 cursorAdvance: input.cursorAdvance,
445 });
446 }
447 const decoded = decodePullRequestListJson(raw);
448 if (!Result.isSuccess(decoded)) {
449 return Effect.fail(
450 new AzureDevOpsPullRequestReadError({
451 command: "az",
452 cwd: input.cwd,
453 operation: "listPullRequests",
454 cause: decoded.failure,
455 }),
456 );
457 }
458
459 const lastItemIndex = decoded.success.rawIndexes[remaining - 1];
460 if (lastItemIndex !== undefined) {
461 const consumed = lastItemIndex + 1;
462 return Effect.succeed({
463 items: [...input.items, ...decoded.success.items.slice(0, remaining)],
464 truncated: consumed < decoded.success.rawCount || decoded.success.rawCount === top,
465 cursorAdvance: input.cursorAdvance + consumed,
466 });
467 }
468
469 const items = [...input.items, ...decoded.success.items];
470 if (decoded.success.rawCount < top) {
471 return Effect.succeed({
472 items,
473 truncated: false,
474 cursorAdvance: input.cursorAdvance + decoded.success.rawCount,
475 });
476 }
477 return listPullRequestPage({
478 ...input,
479 skip: input.skip + decoded.success.rawCount,
480 cursorAdvance: input.cursorAdvance + decoded.success.rawCount,
481 items,
482 });
483 }),
484 );
485 };
486
487 return AzureDevOpsPullRequestCli.of({
488 getViewer: (input) =>
489 executeJson({ cwd: input.cwd, args: ["account", "show", "--query", "user"] }).pipe(
490 Effect.flatMap((result): Effect.Effect<string, AzureDevOpsPullRequestCliError> => {
491 const decoded = decodeViewerJson(`{"user":${result.stdout.trim() || "null"}}`);
492 if (!Result.isSuccess(decoded)) {
493 return Effect.fail(
494 new AzureDevOpsPullRequestReadError({
495 command: "az",
496 cwd: input.cwd,
497 operation: "getViewer",
498 cause: decoded.failure,
499 }),
500 );
501 }
502 return decoded.success === null
503 ? Effect.fail(new AzureDevOpsViewerUnavailableError({ command: "az", cwd: input.cwd }))
504 : Effect.succeed(decoded.success);
505 }),
506 // `az devops login` signs in with a personal access token, which `az account show` knows
507 // nothing about, and nothing in `az` prints whose token it is. `--creator me` is resolved
508 // by the extension itself, so the viewer's own pull request names them.
509 Effect.catchIf(
510 (error) => error._tag !== "AzureDevOpsCliUnavailableError",
511 () =>
512 executeJson({
513 cwd: input.cwd,
514 args: [
515 "repos",
516 "pr",
517 "list",
518 ...detectArgs,
519 "--creator",
520 "me",
521 "--status",
522 "all",
523 "--top",
524 "1",
525 ],
526 }).pipe(
527 Effect.flatMap((result): Effect.Effect<string, AzureDevOpsPullRequestCliError> => {
528 const decoded = decodePullRequestListJson(result.stdout.trim() || "[]");
529 const login = Result.isSuccess(decoded)
530 ? decoded.success.items[0]?.author?.login
531 : undefined;
532 return login === undefined
533 ? Effect.fail(
534 new AzureDevOpsViewerUnavailableError({ command: "az", cwd: input.cwd }),
535 )
536 : Effect.succeed(login);
537 }),
538 ),
539 ),
540 ),
541
542 listPullRequests: (input) =>
543 listPullRequestPage({
544 cwd: input.cwd,
545 repository: input.repository,
546 state: input.state,
547 involvement: input.involvement,
548 viewer: input.viewer,
549 limit: input.limit,
550 skip: input.cursor?.delivered ?? 0,
551 cursorAdvance: 0,
552 items: [],
553 }),
554
555 getPullRequest: (input) =>
556 executeJson({
557 cwd: input.cwd,
558 args: ["repos", "pr", "show", ...detectArgs, "--id", String(input.number)],
559 }).pipe(
560 Effect.flatMap(
561 (result): Effect.Effect<AzureDevOpsPullRequest, AzureDevOpsPullRequestCliError> => {
562 const decoded = decodePullRequestJson(result.stdout.trim());
563 if (!Result.isSuccess(decoded)) {
564 return Effect.fail(
565 new AzureDevOpsPullRequestReadError({
566 command: "az",
567 cwd: input.cwd,
568 operation: "getPullRequest",
569 cause: decoded.failure,
570 }),
571 );
572 }
573 return decoded.success === null
574 ? Effect.fail(
575 new AzureDevOpsPullRequestIncompleteError({
576 command: "az",
577 cwd: input.cwd,
578 number: input.number,
579 }),
580 )
581 : Effect.succeed(decoded.success);
582 },
583 ),
584 ),
585
586 listThreads: (input) =>
587 invoke({
588 cwd: input.cwd,
589 operation: "listThreads",
590 resource: "pullRequestThreads",
591 routeParameters: pullRequestRoute(input),
592 maxOutputBytes: REVIEW_HISTORY_MAX_OUTPUT_BYTES,
593 decode: decodeThreadsJson,
594 }),
595
596 listIterations: (input) =>
597 invoke({
598 cwd: input.cwd,
599 operation: "listIterations",
600 resource: "pullRequestIterations",
601 routeParameters: pullRequestRoute(input),
602 maxOutputBytes: REVIEW_HISTORY_MAX_OUTPUT_BYTES,
603 decode: decodeIterationsJson,
604 }),
605
606 listIterationChanges: (input) => {
607 const page = (skip: number) =>
608 invoke({
609 cwd: input.cwd,
610 operation: "listIterationChanges",
611 resource: "pullRequestIterationChanges",
612 routeParameters: [...pullRequestRoute(input), `iterationId=${input.iterationId}`],
613 queryParameters: [`$top=${CHANGE_ENTRIES_PER_PAGE}`, `$skip=${skip}`],
614 maxOutputBytes: CHANGE_ENTRIES_MAX_OUTPUT_BYTES,
615 decode: decodeIterationChangesJson,
616 });
617 const from = (
618 skip: number,
619 collected: ReadonlyArray<AzureDevOpsChangeEntry>,
620 ): Effect.Effect<AzureDevOpsIterationChanges, AzureDevOpsPullRequestCliError> =>
621 page(skip).pipe(
622 Effect.flatMap((answer) => {
623 const changes = [...collected, ...answer.changes];
624 if (answer.nextSkip === null) return Effect.succeed({ changes, truncated: false });
625 return answer.nextSkip <= skip || answer.nextSkip >= MAX_CHANGE_ENTRIES
626 ? Effect.succeed({ changes, truncated: true })
627 : from(answer.nextSkip, changes);
628 }),
629 );
630 return from(0, []);
631 },
632
633 readItemContent: (input) =>
634 invoke({
635 cwd: input.cwd,
636 operation: "readItemContent",
637 resource: "items",
638 routeParameters: repositoryRoute(input.location),
639 queryParameters: [
640 `path=${toItemPath(input.path)}`,
641 "versionDescriptor.versionType=commit",
642 `versionDescriptor.version=${input.commit}`,
643 "includeContent=true",
644 // Azure leaves `contentMetadata` out unless this is asked for, and with it goes its own
645 // word on whether the file is binary, which is the only reliable one, since a binary
646 // file arrives encoded rather than as the bytes it is on the host.
647 "includeContentMetadata=true",
648 // Without this Azure answers with the file's own bytes rather than with a JSON
649 // envelope, and `az devops invoke` refuses anything it cannot parse as JSON.
650 "$format=json",
651 ],
652 maxOutputBytes: ITEM_CONTENT_MAX_OUTPUT_BYTES,
653 decode: decodeItemContentJson,
654 }),
655
656 setPullRequestReviewers: (input) =>
657 input.reviewers.some((reviewer) => !isReviewerName(reviewer))
658 ? Effect.fail(new AzureDevOpsReviewerNameError({ command: "az", cwd: input.cwd }))
659 : azure
660 .execute({
661 cwd: input.cwd,
662 args: [
663 "repos",
664 "pr",
665 "reviewer",
666 input.requested ? "add" : "remove",
667 ...detectArgs,
668 "--id",
669 String(input.number),
670 // One `--reviewers` takes them all, because az reads the flag as a list and a
671 // second one would replace the first rather than add to it.
672 "--reviewers",
673 ...input.reviewers,
674 "--only-show-errors",
675 "--output",
676 "json",
677 ],
678 })
679 .pipe(Effect.asVoid),
680
681 runPullRequestAction: (input) =>
682 azure
683 .execute({
684 cwd: input.cwd,
685 args: [
686 "repos",
687 "pr",
688 "update",
689 ...detectArgs,
690 "--id",
691 String(input.number),
692 ...actionArgs(input.action, input.mergeMethod),
693 "--only-show-errors",
694 "--output",
695 "json",
696 ],
697 })
698 .pipe(Effect.asVoid),
699
700 updatePullRequest: (input) =>
701 azure
702 .execute({
703 cwd: input.cwd,
704 args: [
705 "repos",
706 "pr",
707 "update",
708 ...detectArgs,
709 "--id",
710 String(input.number),
711 // One argument rather than a flag and a value beside it: a description usually opens
712 // with a bullet, and az reads a dash in the next argv slot as a flag of its own.
713 // `--description` also takes several strings, and this keeps the whole text as one.
714 ...(input.title === undefined ? [] : [`--title=${input.title}`]),
715 ...(input.body === undefined ? [] : [`--description=${input.body}`]),
716 "--only-show-errors",
717 "--output",
718 "json",
719 ],
720 })
721 .pipe(Effect.asVoid),
722 });
723});
724
725export const layer = Layer.effect(AzureDevOpsPullRequestCli, make);