@@ -304,6 +304,11 @@ func UpdatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
304
304
return mcp .NewToolResultError (err .Error ()), nil
305
305
}
306
306
307
+ // If no updates and no reviewers, return error early
308
+ if ! updateNeeded && len (reviewers ) == 0 {
309
+ return mcp .NewToolResultError ("No update parameters provided" ), nil
310
+ }
311
+
307
312
// Create the GitHub client
308
313
client , err := getClient (ctx )
309
314
if err != nil {
@@ -313,7 +318,7 @@ func UpdatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
313
318
var pr * github.PullRequest
314
319
var resp * http.Response
315
320
316
- // First, update the PR if needed
321
+ // Update the PR if needed
317
322
if updateNeeded {
318
323
var ghResp * github.Response
319
324
pr , ghResp , err = client .PullRequests .Edit (ctx , owner , repo , pullNumber , update )
@@ -338,31 +343,6 @@ func UpdatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
338
343
}
339
344
return mcp .NewToolResultError (fmt .Sprintf ("failed to update pull request: %s" , string (body ))), nil
340
345
}
341
- } else {
342
- // If no update needed, just get the current PR
343
- var ghResp * github.Response
344
- pr , ghResp , err = client .PullRequests .Get (ctx , owner , repo , pullNumber )
345
- if err != nil {
346
- return ghErrors .NewGitHubAPIErrorResponse (ctx ,
347
- "failed to get pull request" ,
348
- ghResp ,
349
- err ,
350
- ), nil
351
- }
352
- resp = ghResp .Response
353
- defer func () {
354
- if resp != nil && resp .Body != nil {
355
- _ = resp .Body .Close ()
356
- }
357
- }()
358
-
359
- if resp .StatusCode != http .StatusOK {
360
- body , err := io .ReadAll (resp .Body )
361
- if err != nil {
362
- return nil , fmt .Errorf ("failed to read response body: %w" , err )
363
- }
364
- return mcp .NewToolResultError (fmt .Sprintf ("failed to get pull request: %s" , string (body ))), nil
365
- }
366
346
}
367
347
368
348
// Add reviewers if specified
@@ -398,11 +378,6 @@ func UpdatePullRequest(getClient GetClientFn, t translations.TranslationHelperFu
398
378
pr = updatedPR
399
379
}
400
380
401
- // If no updates and no reviewers, return error
402
- if ! updateNeeded && len (reviewers ) == 0 {
403
- return mcp .NewToolResultError ("No update parameters provided" ), nil
404
- }
405
-
406
381
r , err := json .Marshal (pr )
407
382
if err != nil {
408
383
return nil , fmt .Errorf ("failed to marshal response: %w" , err )
0 commit comments