Skip to content

Commit 60213e6

Browse files
committed
consolidate response further
1 parent c82651f commit 60213e6

File tree

9 files changed

+29
-84
lines changed

9 files changed

+29
-84
lines changed

pkg/github/gists.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,8 @@ func CreateGist(getClient GetClientFn, t translations.TranslationHelperFunc) (to
165165
return mcp.NewToolResultError(fmt.Sprintf("failed to create gist: %s", string(body))), nil
166166
}
167167

168-
minimalResponse := MinimalGistResponse{
169-
URL: createdGist.GetHTMLURL(),
170-
ID: createdGist.GetID(),
171-
Description: createdGist.GetDescription(),
172-
Public: createdGist.GetPublic(),
168+
minimalResponse := MinimalResponse{
169+
URL: createdGist.GetHTMLURL(),
173170
}
174171

175172
r, err := json.Marshal(minimalResponse)
@@ -256,9 +253,8 @@ func UpdateGist(getClient GetClientFn, t translations.TranslationHelperFunc) (to
256253
return mcp.NewToolResultError(fmt.Sprintf("failed to update gist: %s", string(body))), nil
257254
}
258255

259-
minimalResponse := MinimalUpdateResponse{
260-
URL: updatedGist.GetHTMLURL(),
261-
Updated: true,
256+
minimalResponse := MinimalResponse{
257+
URL: updatedGist.GetHTMLURL(),
262258
}
263259

264260
r, err := json.Marshal(minimalResponse)

pkg/github/gists_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,10 @@ func Test_CreateGist(t *testing.T) {
322322
textContent := getTextResult(t, result)
323323

324324
// Unmarshal and verify the minimal result
325-
var gist MinimalGistResponse
325+
var gist MinimalResponse
326326
err = json.Unmarshal([]byte(textContent.Text), &gist)
327327
require.NoError(t, err)
328328

329-
assert.Equal(t, tc.expectedGist.GetID(), gist.ID)
330329
assert.Equal(t, tc.expectedGist.GetHTMLURL(), gist.URL)
331330
})
332331
}
@@ -477,12 +476,11 @@ func Test_UpdateGist(t *testing.T) {
477476
textContent := getTextResult(t, result)
478477

479478
// Unmarshal and verify the minimal result
480-
var updateResp MinimalUpdateResponse
479+
var updateResp MinimalResponse
481480
err = json.Unmarshal([]byte(textContent.Text), &updateResp)
482481
require.NoError(t, err)
483482

484483
assert.Equal(t, tc.expectedGist.GetHTMLURL(), updateResp.URL)
485-
assert.Equal(t, true, updateResp.Updated)
486484
})
487485
}
488486
}

pkg/github/issues.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,8 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
873873
}
874874

875875
// Return minimal response with just essential information
876-
minimalResponse := MinimalResourceResponse{
877-
URL: issue.GetHTMLURL(),
878-
Number: issue.GetNumber(),
879-
State: issue.GetState(),
880-
Title: issue.GetTitle(),
876+
minimalResponse := MinimalResponse{
877+
URL: issue.GetHTMLURL(),
881878
}
882879

883880
r, err := json.Marshal(minimalResponse)
@@ -1251,9 +1248,8 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
12511248
}
12521249

12531250
// Return minimal response with just essential information
1254-
minimalResponse := MinimalUpdateResponse{
1255-
URL: updatedIssue.GetHTMLURL(),
1256-
Updated: true,
1251+
minimalResponse := MinimalResponse{
1252+
URL: updatedIssue.GetHTMLURL(),
12571253
}
12581254

12591255
r, err := json.Marshal(minimalResponse)

pkg/github/issues_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,13 +713,10 @@ func Test_CreateIssue(t *testing.T) {
713713
textContent := getTextResult(t, result)
714714

715715
// Unmarshal and verify the minimal result
716-
var returnedIssue MinimalResourceResponse
716+
var returnedIssue MinimalResponse
717717
err = json.Unmarshal([]byte(textContent.Text), &returnedIssue)
718718
require.NoError(t, err)
719719

720-
assert.Equal(t, tc.expectedIssue.GetNumber(), returnedIssue.Number)
721-
assert.Equal(t, tc.expectedIssue.GetTitle(), returnedIssue.Title)
722-
assert.Equal(t, tc.expectedIssue.GetState(), returnedIssue.State)
723720
assert.Equal(t, tc.expectedIssue.GetHTMLURL(), returnedIssue.URL)
724721
})
725722
}
@@ -1210,12 +1207,11 @@ func Test_UpdateIssue(t *testing.T) {
12101207
textContent := getTextResult(t, result)
12111208

12121209
// Unmarshal and verify the minimal result
1213-
var updateResp MinimalUpdateResponse
1210+
var updateResp MinimalResponse
12141211
err = json.Unmarshal([]byte(textContent.Text), &updateResp)
12151212
require.NoError(t, err)
12161213

12171214
assert.Equal(t, tc.expectedIssue.GetHTMLURL(), updateResp.URL)
1218-
assert.Equal(t, true, updateResp.Updated)
12191215
})
12201216
}
12211217
}

pkg/github/minimal_types.go

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,34 +107,11 @@ type MinimalBranch struct {
107107
Protected bool `json:"protected"`
108108
}
109109

110-
// MinimalResourceResponse represents a minimal response for numbered resource operations (issues, pull requests).
111-
type MinimalResourceResponse struct {
112-
URL string `json:"url"`
113-
Number int `json:"number"`
114-
State string `json:"state"`
115-
Title string `json:"title,omitempty"`
116-
}
117-
118-
// MinimalRepositoryResponse represents a minimal response for repository operations.
119-
type MinimalRepositoryResponse struct {
120-
URL string `json:"url"`
121-
CloneURL string `json:"clone_url"`
122-
Name string `json:"name"`
123-
FullName string `json:"full_name"`
124-
}
125-
126-
// MinimalUpdateResponse represents a minimal response for update operations.
127-
type MinimalUpdateResponse struct {
128-
URL string `json:"url"`
129-
Updated bool `json:"updated"`
130-
}
131-
132-
// MinimalGistResponse represents a minimal response for gist operations.
133-
type MinimalGistResponse struct {
134-
URL string `json:"url"`
135-
ID string `json:"id"`
136-
Description string `json:"description,omitempty"`
137-
Public bool `json:"public"`
110+
// MinimalResponse represents a minimal response for all CRUD operations.
111+
// Success is implicit in the HTTP response status, and all other information
112+
// can be derived from the URL or fetched separately if needed.
113+
type MinimalResponse struct {
114+
URL string `json:"url"`
138115
}
139116

140117
// Helper functions

pkg/github/pullrequests.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,8 @@ func CreatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
194194
}
195195

196196
// Return minimal response with just essential information
197-
minimalResponse := MinimalResourceResponse{
198-
URL: pr.GetHTMLURL(),
199-
Number: pr.GetNumber(),
200-
State: pr.GetState(),
201-
Title: pr.GetTitle(),
197+
minimalResponse := MinimalResponse{
198+
URL: pr.GetHTMLURL(),
202199
}
203200

204201
r, err := json.Marshal(minimalResponse)
@@ -473,9 +470,8 @@ func UpdatePullRequest(getClient GetClientFn, getGQLClient GetGQLClientFn, t tra
473470
}()
474471

475472
// Return minimal response with just essential information
476-
minimalResponse := MinimalUpdateResponse{
477-
URL: finalPR.GetHTMLURL(),
478-
Updated: true,
473+
minimalResponse := MinimalResponse{
474+
URL: finalPR.GetHTMLURL(),
479475
}
480476

481477
r, err := json.Marshal(minimalResponse)

pkg/github/pullrequests_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,10 @@ func Test_UpdatePullRequest(t *testing.T) {
382382
textContent := getTextResult(t, result)
383383

384384
// Unmarshal and verify the minimal result
385-
var updateResp MinimalUpdateResponse
385+
var updateResp MinimalResponse
386386
err = json.Unmarshal([]byte(textContent.Text), &updateResp)
387387
require.NoError(t, err)
388388
assert.Equal(t, tc.expectedPR.GetHTMLURL(), updateResp.URL)
389-
assert.Equal(t, true, updateResp.Updated)
390389
})
391390
}
392391
}
@@ -565,11 +564,10 @@ func Test_UpdatePullRequest_Draft(t *testing.T) {
565564
textContent := getTextResult(t, result)
566565

567566
// Unmarshal and verify the minimal result
568-
var updateResp MinimalUpdateResponse
567+
var updateResp MinimalResponse
569568
err = json.Unmarshal([]byte(textContent.Text), &updateResp)
570569
require.NoError(t, err)
571570
assert.Equal(t, tc.expectedPR.GetHTMLURL(), updateResp.URL)
572-
assert.Equal(t, true, updateResp.Updated)
573571
})
574572
}
575573
}
@@ -1955,12 +1953,9 @@ func Test_CreatePullRequest(t *testing.T) {
19551953
textContent := getTextResult(t, result)
19561954

19571955
// Unmarshal and verify the minimal result
1958-
var returnedPR MinimalResourceResponse
1956+
var returnedPR MinimalResponse
19591957
err = json.Unmarshal([]byte(textContent.Text), &returnedPR)
19601958
require.NoError(t, err)
1961-
assert.Equal(t, tc.expectedPR.GetNumber(), returnedPR.Number)
1962-
assert.Equal(t, tc.expectedPR.GetTitle(), returnedPR.Title)
1963-
assert.Equal(t, tc.expectedPR.GetState(), returnedPR.State)
19641959
assert.Equal(t, tc.expectedPR.GetHTMLURL(), returnedPR.URL)
19651960
})
19661961
}

pkg/github/repositories.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,8 @@ func CreateRepository(getClient GetClientFn, t translations.TranslationHelperFun
459459
}
460460

461461
// Return minimal response with just essential information
462-
minimalResponse := MinimalRepositoryResponse{
463-
URL: createdRepo.GetHTMLURL(),
464-
CloneURL: createdRepo.GetCloneURL(),
465-
Name: createdRepo.GetName(),
466-
FullName: createdRepo.GetFullName(),
462+
minimalResponse := MinimalResponse{
463+
URL: createdRepo.GetHTMLURL(),
467464
}
468465

469466
r, err := json.Marshal(minimalResponse)
@@ -738,11 +735,8 @@ func ForkRepository(getClient GetClientFn, t translations.TranslationHelperFunc)
738735
}
739736

740737
// Return minimal response with just essential information
741-
minimalResponse := MinimalRepositoryResponse{
742-
URL: forkedRepo.GetHTMLURL(),
743-
CloneURL: forkedRepo.GetCloneURL(),
744-
Name: forkedRepo.GetName(),
745-
FullName: forkedRepo.GetFullName(),
738+
minimalResponse := MinimalResponse{
739+
URL: forkedRepo.GetHTMLURL(),
746740
}
747741

748742
r, err := json.Marshal(minimalResponse)

pkg/github/repositories_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,15 +1241,12 @@ func Test_CreateRepository(t *testing.T) {
12411241
textContent := getTextResult(t, result)
12421242

12431243
// Unmarshal and verify the minimal result
1244-
var returnedRepo MinimalRepositoryResponse
1244+
var returnedRepo MinimalResponse
12451245
err = json.Unmarshal([]byte(textContent.Text), &returnedRepo)
12461246
assert.NoError(t, err)
12471247

12481248
// Verify repository details
1249-
assert.Equal(t, tc.expectedRepo.GetName(), returnedRepo.Name)
12501249
assert.Equal(t, tc.expectedRepo.GetHTMLURL(), returnedRepo.URL)
1251-
assert.Equal(t, tc.expectedRepo.GetCloneURL(), returnedRepo.CloneURL)
1252-
assert.Equal(t, tc.expectedRepo.GetFullName(), returnedRepo.FullName)
12531250
})
12541251
}
12551252
}

0 commit comments

Comments
 (0)