in vsts/src/utils.ts [411:437]
async function findCommentByTag(tag: string): Promise<{
thread: GitInterfaces.CommentThread | undefined
comment: GitInterfaces.Comment | undefined
}> {
try {
const gitApi = await getGitApi()
const project = getVariable('System.TeamProject')
const repoId = getVariable('Build.Repository.Id')
const pullRequestId = parseInt(
getVariable('System.PullRequest.PullRequestId'),
10
)
const threads = await gitApi.getThreads(repoId, pullRequestId, project)
for (const thread of threads) {
const comment = thread.comments?.find(comment =>
comment.content?.includes(tag)
)
if (comment != undefined) {
return {thread: thread, comment: comment}
}
}
return {thread: undefined, comment: undefined}
} catch (error) {
tl.debug(`Failed to find comment by tag – ${(error as Error).message}`)
return {thread: undefined, comment: undefined}
}
}