pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/github/github-mcp-server/commit/c0ba3edceed207fc243536ce75a1a97badde6178

tps://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> use minimal types (#2066) · github/github-mcp-server@c0ba3ed · GitHub
Skip to content

Commit c0ba3ed

Browse files
authored
use minimal types (#2066)
1 parent 3ffc06b commit c0ba3ed

3 files changed

Lines changed: 40 additions & 10 deletions

File tree

pkg/github/minimal_types.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,38 @@ type MinimalProjectStatusUpdate struct {
272272
Creator *MinimalUser `json:"creator,omitempty"`
273273
}
274274

275+
// MinimalPullRequestReview is the trimmed output type for pull request review objects to reduce verbosity.
276+
type MinimalPullRequestReview struct {
277+
ID int64 `json:"id"`
278+
State string `json:"state"`
279+
Body string `json:"body,omitempty"`
280+
HTMLURL string `json:"html_url"`
281+
User *MinimalUser `json:"user,omitempty"`
282+
CommitID string `json:"commit_id,omitempty"`
283+
SubmittedAt string `json:"submitted_at,omitempty"`
284+
AuthorAssociation string `json:"author_association,omitempty"`
285+
}
286+
275287
// Helper functions
276288

289+
func convertToMinimalPullRequestReview(review *github.PullRequestReview) MinimalPullRequestReview {
290+
m := MinimalPullRequestReview{
291+
ID: review.GetID(),
292+
State: review.GetState(),
293+
Body: review.GetBody(),
294+
HTMLURL: review.GetHTMLURL(),
295+
User: convertToMinimalUser(review.GetUser()),
296+
CommitID: review.GetCommitID(),
297+
AuthorAssociation: review.GetAuthorAssociation(),
298+
}
299+
300+
if review.SubmittedAt != nil {
301+
m.SubmittedAt = review.SubmittedAt.Format(time.RFC3339)
302+
}
303+
304+
return m
305+
}
306+
277307
func convertToMinimalIssue(issue *github.Issue) MinimalIssue {
278308
m := MinimalIssue{
279309
Number: issue.GetNumber(),

pkg/github/pullrequests.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,12 @@ func GetPullRequestReviews(ctx context.Context, client *github.Client, deps Tool
454454
}
455455
}
456456

457-
r, err := json.Marshal(reviews)
458-
if err != nil {
459-
return nil, fmt.Errorf("failed to marshal response: %w", err)
457+
minimalReviews := make([]MinimalPullRequestReview, 0, len(reviews))
458+
for _, review := range reviews {
459+
minimalReviews = append(minimalReviews, convertToMinimalPullRequestReview(review))
460460
}
461461

462-
return utils.NewToolResultText(string(r)), nil
462+
return MarshalledTextResult(minimalReviews), nil
463463
}
464464

465465
// PullRequestWriteUIResourceURI is the URI for the create_pull_request tool's MCP App UI resource.

pkg/github/pullrequests_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,18 +1990,18 @@ func Test_GetPullRequestReviews(t *testing.T) {
19901990
textContent := getTextResult(t, result)
19911991

19921992
// Unmarshal and verify the result
1993-
var returnedReviews []*github.PullRequestReview
1993+
var returnedReviews []MinimalPullRequestReview
19941994
err = json.Unmarshal([]byte(textContent.Text), &returnedReviews)
19951995
require.NoError(t, err)
19961996
assert.Len(t, returnedReviews, len(tc.expectedReviews))
19971997
for i, review := range returnedReviews {
1998+
assert.Equal(t, tc.expectedReviews[i].GetID(), review.ID)
1999+
assert.Equal(t, tc.expectedReviews[i].GetState(), review.State)
2000+
assert.Equal(t, tc.expectedReviews[i].GetBody(), review.Body)
19982001
require.NotNil(t, tc.expectedReviews[i].User)
19992002
require.NotNil(t, review.User)
2000-
assert.Equal(t, tc.expectedReviews[i].GetID(), review.GetID())
2001-
assert.Equal(t, tc.expectedReviews[i].GetState(), review.GetState())
2002-
assert.Equal(t, tc.expectedReviews[i].GetBody(), review.GetBody())
2003-
assert.Equal(t, tc.expectedReviews[i].GetUser().GetLogin(), review.GetUser().GetLogin())
2004-
assert.Equal(t, tc.expectedReviews[i].GetHTMLURL(), review.GetHTMLURL())
2003+
assert.Equal(t, tc.expectedReviews[i].GetUser().GetLogin(), review.User.Login)
2004+
assert.Equal(t, tc.expectedReviews[i].GetHTMLURL(), review.HTMLURL)
20052005
}
20062006
})
20072007
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy