Skip to content

MCP: Fix the commit outcome typing #8388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/mcp/src/shared/entities/stacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const RejectedChangesSchema = z.tuple([
]);

export const CreateCommitOutcomeSchema = z.object({
newCommitId: z
newCommit: z
.string({
description: 'The commit ID of the new commit. Null if the commit failed to be created.'
})
Expand Down
8 changes: 4 additions & 4 deletions packages/mcp/src/tools/client/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ type CreateCommitOutcome = z.infer<typeof CreateCommitOutcomeSchema>;

function interpretOutcome(outcome: CreateCommitOutcome, action: 'created' | 'amend'): string {
// Success
if (outcome.newCommitId !== null && outcome.pathsToRejectedChanges.length === 0) {
return `Commit successfully ${action} with ID ${outcome.newCommitId}`;
if (outcome.newCommit !== null && outcome.pathsToRejectedChanges.length === 0) {
return `Commit successfully ${action} with ID ${outcome.newCommit}`;
}

// Created commit but some changes were rejected
if (outcome.newCommitId !== null && outcome.pathsToRejectedChanges.length > 0) {
if (outcome.newCommit !== null && outcome.pathsToRejectedChanges.length > 0) {
const rejectionMessages = createRejectionSummary(outcome);

return `Commit successfully ${amendCommit} with ID ${outcome.newCommitId}, but some changes were rejected: ${rejectionMessages}`;
return `Commit successfully ${amendCommit} with ID ${outcome.newCommit}, but some changes were rejected: ${rejectionMessages}`;
}

// No commit created
Expand Down
Loading