mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
prettier
This commit is contained in:
@@ -16,7 +16,7 @@ export type UpdateClaudeCommentResult = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a Claude comment on GitHub (either an issue/PR comment or a PR review comment)
|
* Updates a Claude comment on GitHub (either an issue/PR comment or a PR review comment)
|
||||||
*
|
*
|
||||||
* @param octokit - Authenticated Octokit instance
|
* @param octokit - Authenticated Octokit instance
|
||||||
* @param params - Parameters for updating the comment
|
* @param params - Parameters for updating the comment
|
||||||
* @returns The updated comment details
|
* @returns The updated comment details
|
||||||
@@ -67,4 +67,4 @@ export async function updateClaudeComment(
|
|||||||
html_url: response.data.html_url,
|
html_url: response.data.html_url,
|
||||||
updated_at: response.data.updated_at,
|
updated_at: response.data.updated_at,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export async function updateTrackingComment(
|
|||||||
// Update the existing comment with the branch link
|
// Update the existing comment with the branch link
|
||||||
try {
|
try {
|
||||||
const isPRReviewComment = isPullRequestReviewCommentEvent(context);
|
const isPRReviewComment = isPullRequestReviewCommentEvent(context);
|
||||||
|
|
||||||
await updateClaudeComment(octokit, {
|
await updateClaudeComment(octokit, {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@@ -46,7 +46,7 @@ export async function updateTrackingComment(
|
|||||||
body: updatedBody,
|
body: updatedBody,
|
||||||
isPullRequestReviewComment: isPRReviewComment,
|
isPullRequestReviewComment: isPRReviewComment,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`✅ Updated ${isPRReviewComment ? "PR review" : "issue"} comment ${commentId} with branch link`,
|
`✅ Updated ${isPRReviewComment ? "PR review" : "issue"} comment ${commentId} with branch link`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,8 +9,17 @@ type PrepareConfigParams = {
|
|||||||
claudeCommentId?: string;
|
claudeCommentId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function prepareMcpConfig(params: PrepareConfigParams): Promise<string> {
|
export async function prepareMcpConfig(
|
||||||
const { githubToken, owner, repo, branch, additionalMcpConfig, claudeCommentId } = params;
|
params: PrepareConfigParams,
|
||||||
|
): Promise<string> {
|
||||||
|
const {
|
||||||
|
githubToken,
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
branch,
|
||||||
|
additionalMcpConfig,
|
||||||
|
claudeCommentId,
|
||||||
|
} = params;
|
||||||
try {
|
try {
|
||||||
const baseMcpConfig = {
|
const baseMcpConfig = {
|
||||||
mcpServers: {
|
mcpServers: {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { Octokit } from "@octokit/rest";
|
|||||||
import {
|
import {
|
||||||
updateClaudeComment,
|
updateClaudeComment,
|
||||||
type UpdateClaudeCommentParams,
|
type UpdateClaudeCommentParams,
|
||||||
type UpdateClaudeCommentResult,
|
|
||||||
} from "../src/github/operations/comments/update-claude-comment";
|
} from "../src/github/operations/comments/update-claude-comment";
|
||||||
|
|
||||||
describe("updateClaudeComment", () => {
|
describe("updateClaudeComment", () => {
|
||||||
@@ -33,7 +32,9 @@ describe("updateClaudeComment", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.issues.updateComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.issues.updateComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -70,7 +71,9 @@ describe("updateClaudeComment", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.issues.updateComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.issues.updateComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -107,7 +110,9 @@ describe("updateClaudeComment", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.pulls.updateReviewComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.pulls.updateReviewComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -147,9 +152,13 @@ describe("updateClaudeComment", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.pulls.updateReviewComment = jest.fn().mockRejectedValue(mockError);
|
mockOctokit.rest.pulls.updateReviewComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockRejectedValue(mockError);
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.issues.updateComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.issues.updateComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -187,7 +196,9 @@ describe("updateClaudeComment", () => {
|
|||||||
mockError.status = 500;
|
mockError.status = 500;
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.pulls.updateReviewComment = jest.fn().mockRejectedValue(mockError);
|
mockOctokit.rest.pulls.updateReviewComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockRejectedValue(mockError);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -197,7 +208,9 @@ describe("updateClaudeComment", () => {
|
|||||||
isPullRequestReviewComment: true,
|
isPullRequestReviewComment: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
await expect(updateClaudeComment(mockOctokit, params)).rejects.toEqual(mockError);
|
await expect(updateClaudeComment(mockOctokit, params)).rejects.toEqual(
|
||||||
|
mockError,
|
||||||
|
);
|
||||||
|
|
||||||
expect(mockOctokit.rest.pulls.updateReviewComment).toHaveBeenCalledWith({
|
expect(mockOctokit.rest.pulls.updateReviewComment).toHaveBeenCalledWith({
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -214,7 +227,9 @@ describe("updateClaudeComment", () => {
|
|||||||
const mockError = new Error("Forbidden");
|
const mockError = new Error("Forbidden");
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.issues.updateComment = jest.fn().mockRejectedValue(mockError);
|
mockOctokit.rest.issues.updateComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockRejectedValue(mockError);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -224,7 +239,9 @@ describe("updateClaudeComment", () => {
|
|||||||
isPullRequestReviewComment: false,
|
isPullRequestReviewComment: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
await expect(updateClaudeComment(mockOctokit, params)).rejects.toEqual(mockError);
|
await expect(updateClaudeComment(mockOctokit, params)).rejects.toEqual(
|
||||||
|
mockError,
|
||||||
|
);
|
||||||
|
|
||||||
expect(mockOctokit.rest.issues.updateComment).toHaveBeenCalledWith({
|
expect(mockOctokit.rest.issues.updateComment).toHaveBeenCalledWith({
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -245,7 +262,9 @@ describe("updateClaudeComment", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.issues.updateComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.issues.updateComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -276,7 +295,9 @@ describe("updateClaudeComment", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.issues.updateComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.issues.updateComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -325,7 +346,9 @@ const code = "example";
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.issues.updateComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.issues.updateComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -366,7 +389,9 @@ const code = "example";
|
|||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error Mock implementation doesn't match full type signature
|
// @ts-expect-error Mock implementation doesn't match full type signature
|
||||||
mockOctokit.rest.pulls.updateReviewComment = jest.fn().mockResolvedValue(mockResponse);
|
mockOctokit.rest.pulls.updateReviewComment = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(mockResponse);
|
||||||
|
|
||||||
const params: UpdateClaudeCommentParams = {
|
const params: UpdateClaudeCommentParams = {
|
||||||
owner: "testowner",
|
owner: "testowner",
|
||||||
@@ -385,4 +410,4 @@ const code = "example";
|
|||||||
updated_at: "2024-01-08T12:30:45Z",
|
updated_at: "2024-01-08T12:30:45Z",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user