azdo-cli 0.5.0-029-pr-comment-reply.516 → 0.5.0-029-pr-comment-reply.519
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.js +84 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,6 +62,11 @@ azdo pr status # PR checks (status + branch policies +
|
|
|
62
62
|
azdo pr comment-resolve 17 --pr-number 64 # idempotent: exit 0 even when already resolved
|
|
63
63
|
azdo pr comment-reopen 17 --pr-number 64
|
|
64
64
|
|
|
65
|
+
# Reply to a PR comment thread
|
|
66
|
+
azdo pr comments reply 148 "Great suggestion, I'll address it." # human-readable output
|
|
67
|
+
azdo pr comments reply 148 "Done." --pr-number 64 --json # JSON: { pullRequestId, threadId, commentId, content }
|
|
68
|
+
azdo pr comment-reply 148 "Done." --pr-number 64 # flat alias, identical behaviour
|
|
69
|
+
|
|
65
70
|
# Pipelines — list, inspect runs, wait (exit code = result), start
|
|
66
71
|
azdo pipeline list --filter ci
|
|
67
72
|
azdo pipeline get-runs 12 --branch develop --limit 1
|
package/dist/index.js
CHANGED
|
@@ -3188,6 +3188,30 @@ async function getPullRequestThreads(context, repo, cred, prId) {
|
|
|
3188
3188
|
const data = await readJsonResponse(response);
|
|
3189
3189
|
return data.value.map(mapThread).filter((thread) => thread !== null);
|
|
3190
3190
|
}
|
|
3191
|
+
function buildThreadCommentUrl(context, repo, prId, threadId) {
|
|
3192
|
+
const url = new URL(
|
|
3193
|
+
`https://dev.azure.com/${encodeURIComponent(context.org)}/${encodeURIComponent(context.project)}/_apis/git/repositories/${encodeURIComponent(repo)}/pullRequests/${prId}/threads/${threadId}/comments`
|
|
3194
|
+
);
|
|
3195
|
+
url.searchParams.set("api-version", "7.1");
|
|
3196
|
+
return url;
|
|
3197
|
+
}
|
|
3198
|
+
async function postThreadComment(context, repo, cred, prId, threadId, content) {
|
|
3199
|
+
const response = await fetchWithErrors(buildThreadCommentUrl(context, repo, prId, threadId).toString(), {
|
|
3200
|
+
method: "POST",
|
|
3201
|
+
headers: {
|
|
3202
|
+
...authHeaders(cred),
|
|
3203
|
+
"Content-Type": "application/json"
|
|
3204
|
+
},
|
|
3205
|
+
body: JSON.stringify({ content, parentCommentId: 0, commentType: 1 })
|
|
3206
|
+
});
|
|
3207
|
+
const data = await readJsonResponse(response);
|
|
3208
|
+
return {
|
|
3209
|
+
id: data.id,
|
|
3210
|
+
author: data.author?.displayName ?? null,
|
|
3211
|
+
content: data.content ?? content,
|
|
3212
|
+
publishedAt: data.publishedDate ?? null
|
|
3213
|
+
};
|
|
3214
|
+
}
|
|
3191
3215
|
|
|
3192
3216
|
// src/commands/pr.ts
|
|
3193
3217
|
function parsePositivePrNumber(raw) {
|
|
@@ -3538,6 +3562,7 @@ function createPrCommentsCommand() {
|
|
|
3538
3562
|
handlePrCommandError(err, context, "read");
|
|
3539
3563
|
}
|
|
3540
3564
|
});
|
|
3565
|
+
command.addCommand(createPrCommentsReplyCommand());
|
|
3541
3566
|
return command;
|
|
3542
3567
|
}
|
|
3543
3568
|
async function resolveThreadTarget(threadIdRaw, options) {
|
|
@@ -3656,6 +3681,64 @@ function createPrCommentReopenCommand() {
|
|
|
3656
3681
|
});
|
|
3657
3682
|
return command;
|
|
3658
3683
|
}
|
|
3684
|
+
async function runCommentReply(threadIdRaw, text, options) {
|
|
3685
|
+
let context;
|
|
3686
|
+
try {
|
|
3687
|
+
const trimmedText = text.trim();
|
|
3688
|
+
if (!trimmedText) {
|
|
3689
|
+
writeError("Reply text must not be empty.");
|
|
3690
|
+
return;
|
|
3691
|
+
}
|
|
3692
|
+
const target = await resolveThreadTarget(threadIdRaw, options);
|
|
3693
|
+
if (target === null) {
|
|
3694
|
+
return;
|
|
3695
|
+
}
|
|
3696
|
+
context = target.context;
|
|
3697
|
+
const threads = await getPullRequestThreads(target.context, target.repo, target.pat, target.pullRequest.id);
|
|
3698
|
+
const thread = threads.find((t) => t.id === target.threadId);
|
|
3699
|
+
if (!thread) {
|
|
3700
|
+
writeError(`Thread #${target.threadId} not found on pull request #${target.pullRequest.id}.`);
|
|
3701
|
+
return;
|
|
3702
|
+
}
|
|
3703
|
+
const posted = await postThreadComment(
|
|
3704
|
+
target.context,
|
|
3705
|
+
target.repo,
|
|
3706
|
+
target.pat,
|
|
3707
|
+
target.pullRequest.id,
|
|
3708
|
+
target.threadId,
|
|
3709
|
+
trimmedText
|
|
3710
|
+
);
|
|
3711
|
+
const result = {
|
|
3712
|
+
pullRequestId: target.pullRequest.id,
|
|
3713
|
+
threadId: target.threadId,
|
|
3714
|
+
commentId: posted.id,
|
|
3715
|
+
content: posted.content
|
|
3716
|
+
};
|
|
3717
|
+
if (options.json) {
|
|
3718
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}
|
|
3719
|
+
`);
|
|
3720
|
+
return;
|
|
3721
|
+
}
|
|
3722
|
+
process.stdout.write(`Reply posted to thread #${target.threadId} on pull request #${target.pullRequest.id}.
|
|
3723
|
+
`);
|
|
3724
|
+
} catch (err) {
|
|
3725
|
+
handlePrCommandError(err, context, "write");
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
function createPrCommentsReplyCommand() {
|
|
3729
|
+
const command = new Command12("reply");
|
|
3730
|
+
configureUnwrappedHelp(command).description("Post a reply to a pull request comment thread").argument("<threadId>", "numeric id of the thread to reply to").argument("<text>", "text of the reply").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", PR_NUMBER_HELP).option("--json", "output JSON").action(async (threadIdRaw, text, options) => {
|
|
3731
|
+
await runCommentReply(threadIdRaw, text, options);
|
|
3732
|
+
});
|
|
3733
|
+
return command;
|
|
3734
|
+
}
|
|
3735
|
+
function createPrCommentReplyCommand() {
|
|
3736
|
+
const command = new Command12("comment-reply");
|
|
3737
|
+
configureUnwrappedHelp(command).description('Post a reply to a pull request comment thread (alias of "azdo pr comments reply")').argument("<threadId>", "numeric id of the thread to reply to").argument("<text>", "text of the reply").option("--org <org>", "Azure DevOps organization").option("--project <project>", "Azure DevOps project").option("--pr-number <N>", PR_NUMBER_HELP).option("--json", "output JSON").action(async (threadIdRaw, text, options) => {
|
|
3738
|
+
await runCommentReply(threadIdRaw, text, options);
|
|
3739
|
+
});
|
|
3740
|
+
return command;
|
|
3741
|
+
}
|
|
3659
3742
|
function createPrCommand() {
|
|
3660
3743
|
const command = new Command12("pr");
|
|
3661
3744
|
command.description("Manage Azure DevOps pull requests");
|
|
@@ -3664,6 +3747,7 @@ function createPrCommand() {
|
|
|
3664
3747
|
command.addCommand(createPrCommentsCommand());
|
|
3665
3748
|
command.addCommand(createPrCommentResolveCommand());
|
|
3666
3749
|
command.addCommand(createPrCommentReopenCommand());
|
|
3750
|
+
command.addCommand(createPrCommentReplyCommand());
|
|
3667
3751
|
return command;
|
|
3668
3752
|
}
|
|
3669
3753
|
|