- Notifications
You must be signed in to change notification settings - Fork1.4k
Commit0568187
Always include SHA in get_file_contents responses (#676)
* fix: Add SHA to get_file_contents while preserving MCP behavior (#595)Enhance get_file_contents to include SHA information without changingthe existing MCP server response format.Changes:- Add Contents API call to retrieve SHA before fetching raw content- Include SHA in resourceURI (repo://owner/repo/sha/{SHA}/contents/path)- Add SHA to success messages- Update tests to verify SHA inclusion- Maintain original behavior: text files return raw text, binaries return base64This preserves backward compatibility while providing SHA informationfor better file versioning support.Closes#595* fix: Improve error handling for Contents API responseEnsure response body is properly closed even when an error occurs by movingthe defer statement before the error check. This prevents potential resourceleaks when the Contents API returns an error with a non-nil response.Changes:- Move defer respContents.Body.Close() before error checking- Rename errContents to err for consistency- Add nil check for respContents before attempting to close bodyThis follows Go best practices for handling HTTP responses and preventspotential goroutine/memory leaks.* revert changes to resource URI* use GraphQL API to get file SHA* refactor: mock GQL client instead of getFileSHA function to follow conventions* lint* revert GraphQL---------Co-authored-by: LuluBeatson <lulubeatson@github.com>1 parentbe91795 commit0568187
2 files changed
+60
-4
lines changedLines changed: 32 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
507 | 507 |
| |
508 | 508 |
| |
509 | 509 |
| |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
510 | 528 |
| |
511 | 529 |
| |
512 | 530 |
| |
| |||
548 | 566 |
| |
549 | 567 |
| |
550 | 568 |
| |
551 |
| - | |
| 569 | + | |
552 | 570 |
| |
553 | 571 |
| |
554 | 572 |
| |
555 |
| - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
556 | 579 |
| |
557 | 580 |
| |
558 |
| - | |
| 581 | + | |
559 | 582 |
| |
560 | 583 |
| |
561 | 584 |
| |
562 |
| - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
563 | 591 |
| |
564 | 592 |
| |
565 | 593 |
| |
|
Lines changed: 28 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
79 | 93 |
| |
80 | 94 |
| |
81 | 95 |
| |
| |||
107 | 121 |
| |
108 | 122 |
| |
109 | 123 |
| |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
110 | 138 |
| |
111 | 139 |
| |
112 | 140 |
| |
|
0 commit comments
Comments
(0)