Skip to content

Commit 95c7b0a

Browse files
Add missing milestone to create_issue (#88)
1 parent ccaedb6 commit 95c7b0a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pkg/github/issues.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t
261261
},
262262
),
263263
),
264+
mcp.WithNumber("milestone",
265+
mcp.Description("Milestone number"),
266+
),
264267
),
265268
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
266269
owner, err := requiredParam[string](request, "owner")
@@ -294,12 +297,24 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t
294297
return mcp.NewToolResultError(err.Error()), nil
295298
}
296299

300+
// Get optional milestone
301+
milestone, err := optionalIntParam(request, "milestone")
302+
if err != nil {
303+
return mcp.NewToolResultError(err.Error()), nil
304+
}
305+
306+
var milestoneNum *int
307+
if milestone != 0 {
308+
milestoneNum = &milestone
309+
}
310+
297311
// Create the issue request
298312
issueRequest := &github.IssueRequest{
299313
Title: github.Ptr(title),
300314
Body: github.Ptr(body),
301315
Assignees: &assignees,
302316
Labels: &labels,
317+
Milestone: milestoneNum,
303318
}
304319

305320
issue, resp, err := client.Issues.Create(ctx, owner, repo, issueRequest)

pkg/github/issues_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ func Test_CreateIssue(t *testing.T) {
392392
assert.Contains(t, tool.InputSchema.Properties, "body")
393393
assert.Contains(t, tool.InputSchema.Properties, "assignees")
394394
assert.Contains(t, tool.InputSchema.Properties, "labels")
395+
assert.Contains(t, tool.InputSchema.Properties, "milestone")
395396
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "title"})
396397

397398
// Setup mock issue for success case
@@ -403,6 +404,7 @@ func Test_CreateIssue(t *testing.T) {
403404
HTMLURL: github.Ptr("https://github.com/owner/repo/issues/123"),
404405
Assignees: []*github.User{{Login: github.Ptr("user1")}, {Login: github.Ptr("user2")}},
405406
Labels: []*github.Label{{Name: github.Ptr("bug")}, {Name: github.Ptr("help wanted")}},
407+
Milestone: &github.Milestone{Number: github.Ptr(5)},
406408
}
407409

408410
tests := []struct {
@@ -423,6 +425,7 @@ func Test_CreateIssue(t *testing.T) {
423425
"body": "This is a test issue",
424426
"labels": []any{"bug", "help wanted"},
425427
"assignees": []any{"user1", "user2"},
428+
"milestone": float64(5),
426429
}).andThen(
427430
mockResponse(t, http.StatusCreated, mockIssue),
428431
),
@@ -435,6 +438,7 @@ func Test_CreateIssue(t *testing.T) {
435438
"body": "This is a test issue",
436439
"assignees": []string{"user1", "user2"},
437440
"labels": []string{"bug", "help wanted"},
441+
"milestone": float64(5),
438442
},
439443
expectError: false,
440444
expectedIssue: mockIssue,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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