Skip to content

Commit 88d16d2

Browse files
Merge branch 'main' into actions-job-log-buffer
2 parents b128e44 + a70cd1b commit 88d16d2

File tree

6 files changed

+94
-36
lines changed

6 files changed

+94
-36
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ updates:
1313
directory: "/"
1414
schedule:
1515
interval: "weekly"
16+
- package-ecosystem: "github-actions"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ The following sets of tools are available (all are on by default):
533533
- `owner`: Repository owner (string, required)
534534
- `repo`: Repository name (string, required)
535535
- `title`: Issue title (string, required)
536+
- `type`: Type of this issue (string, optional)
536537

537538
- **get_issue** - Get issue details
538539
- `issue_number`: The number of the issue (number, required)
@@ -600,6 +601,7 @@ The following sets of tools are available (all are on by default):
600601
- `repo`: Repository name (string, required)
601602
- `state`: New state (string, optional)
602603
- `title`: New title (string, optional)
604+
- `type`: New issue type (string, optional)
603605

604606
</details>
605607

pkg/github/__toolsnaps__/create_issue.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
"title": {
4040
"description": "Issue title",
4141
"type": "string"
42+
},
43+
"type": {
44+
"description": "Type of this issue",
45+
"type": "string"
4246
}
4347
},
4448
"required": [

pkg/github/__toolsnaps__/update_issue.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
"title": {
5252
"description": "New title",
5353
"type": "string"
54+
},
55+
"type": {
56+
"description": "New issue type",
57+
"type": "string"
5458
}
5559
},
5660
"required": [

pkg/github/issues.go

Lines changed: 58 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -553,39 +553,39 @@ func RemoveSubIssue(getClient GetClientFn, t translations.TranslationHelperFunc)
553553
}
554554

555555
client, err := getClient(ctx)
556-
if err != nil {
557-
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
558-
}
559-
560-
subIssueRequest := github.SubIssueRequest{
561-
SubIssueID: int64(subIssueID),
562-
}
563-
564-
subIssue, resp, err := client.SubIssue.Remove(ctx, owner, repo, int64(issueNumber), subIssueRequest)
565-
if err != nil {
566-
return ghErrors.NewGitHubAPIErrorResponse(ctx,
567-
"failed to remove sub-issue",
568-
resp,
569-
err,
570-
), nil
571-
}
572-
defer func() { _ = resp.Body.Close() }()
573-
574-
if resp.StatusCode != http.StatusOK {
575-
body, err := io.ReadAll(resp.Body)
576-
if err != nil {
577-
return nil, fmt.Errorf("failed to read response body: %w", err)
578-
}
579-
return mcp.NewToolResultError(fmt.Sprintf("failed to remove sub-issue: %s", string(body))), nil
580-
}
581-
582-
r, err := json.Marshal(subIssue)
583-
if err != nil {
584-
return nil, fmt.Errorf("failed to marshal response: %w", err)
585-
}
586-
587-
return mcp.NewToolResultText(string(r)), nil
588-
}
556+
if err != nil {
557+
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
558+
}
559+
560+
subIssueRequest := github.SubIssueRequest{
561+
SubIssueID: int64(subIssueID),
562+
}
563+
564+
subIssue, resp, err := client.SubIssue.Remove(ctx, owner, repo, int64(issueNumber), subIssueRequest)
565+
if err != nil {
566+
return ghErrors.NewGitHubAPIErrorResponse(ctx,
567+
"failed to remove sub-issue",
568+
resp,
569+
err,
570+
), nil
571+
}
572+
defer func() { _ = resp.Body.Close() }()
573+
574+
if resp.StatusCode != http.StatusOK {
575+
body, err := io.ReadAll(resp.Body)
576+
if err != nil {
577+
return nil, fmt.Errorf("failed to read response body: %w", err)
578+
}
579+
return mcp.NewToolResultError(fmt.Sprintf("failed to remove sub-issue: %s", string(body))), nil
580+
}
581+
582+
r, err := json.Marshal(subIssue)
583+
if err != nil {
584+
return nil, fmt.Errorf("failed to marshal response: %w", err)
585+
}
586+
587+
return mcp.NewToolResultText(string(r)), nil
588+
}
589589
}
590590

591591
// ReprioritizeSubIssue creates a tool to reprioritize a sub-issue to a different position in the parent list.
@@ -788,6 +788,9 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
788788
mcp.WithNumber("milestone",
789789
mcp.Description("Milestone number"),
790790
),
791+
mcp.WithString("type",
792+
mcp.Description("Type of this issue"),
793+
),
791794
),
792795
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
793796
owner, err := RequiredParam[string](request, "owner")
@@ -832,6 +835,12 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
832835
milestoneNum = &milestone
833836
}
834837

838+
// Get optional type
839+
issueType, err := OptionalParam[string](request, "type")
840+
if err != nil {
841+
return mcp.NewToolResultError(err.Error()), nil
842+
}
843+
835844
// Create the issue request
836845
issueRequest := &github.IssueRequest{
837846
Title: github.Ptr(title),
@@ -841,6 +850,10 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
841850
Milestone: milestoneNum,
842851
}
843852

853+
if issueType != "" {
854+
issueRequest.Type = github.Ptr(issueType)
855+
}
856+
844857
client, err := getClient(ctx)
845858
if err != nil {
846859
return nil, fmt.Errorf("failed to get GitHub client: %w", err)
@@ -1129,6 +1142,9 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
11291142
mcp.WithNumber("milestone",
11301143
mcp.Description("New milestone number"),
11311144
),
1145+
mcp.WithString("type",
1146+
mcp.Description("New issue type"),
1147+
),
11321148
),
11331149
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
11341150
owner, err := RequiredParam[string](request, "owner")
@@ -1199,6 +1215,15 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
11991215
issueRequest.Milestone = &milestoneNum
12001216
}
12011217

1218+
// Get issue type
1219+
issueType, err := OptionalParam[string](request, "type")
1220+
if err != nil {
1221+
return mcp.NewToolResultError(err.Error()), nil
1222+
}
1223+
if issueType != "" {
1224+
issueRequest.Type = github.Ptr(issueType)
1225+
}
1226+
12021227
client, err := getClient(ctx)
12031228
if err != nil {
12041229
return nil, fmt.Errorf("failed to get GitHub client: %w", err)

pkg/github/issues_test.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ func Test_CreateIssue(t *testing.T) {
581581
assert.Contains(t, tool.InputSchema.Properties, "assignees")
582582
assert.Contains(t, tool.InputSchema.Properties, "labels")
583583
assert.Contains(t, tool.InputSchema.Properties, "milestone")
584+
assert.Contains(t, tool.InputSchema.Properties, "type")
584585
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "title"})
585586

586587
// Setup mock issue for success case
@@ -593,6 +594,7 @@ func Test_CreateIssue(t *testing.T) {
593594
Assignees: []*github.User{{Login: github.Ptr("user1")}, {Login: github.Ptr("user2")}},
594595
Labels: []*github.Label{{Name: github.Ptr("bug")}, {Name: github.Ptr("help wanted")}},
595596
Milestone: &github.Milestone{Number: github.Ptr(5)},
597+
Type: &github.IssueType{Name: github.Ptr("Bug")},
596598
}
597599

598600
tests := []struct {
@@ -614,6 +616,7 @@ func Test_CreateIssue(t *testing.T) {
614616
"labels": []any{"bug", "help wanted"},
615617
"assignees": []any{"user1", "user2"},
616618
"milestone": float64(5),
619+
"type": "Bug",
617620
}).andThen(
618621
mockResponse(t, http.StatusCreated, mockIssue),
619622
),
@@ -627,6 +630,7 @@ func Test_CreateIssue(t *testing.T) {
627630
"assignees": []any{"user1", "user2"},
628631
"labels": []any{"bug", "help wanted"},
629632
"milestone": float64(5),
633+
"type": "Bug",
630634
},
631635
expectError: false,
632636
expectedIssue: mockIssue,
@@ -722,6 +726,10 @@ func Test_CreateIssue(t *testing.T) {
722726
assert.Equal(t, *tc.expectedIssue.Body, *returnedIssue.Body)
723727
}
724728

729+
if tc.expectedIssue.Type != nil {
730+
assert.Equal(t, *tc.expectedIssue.Type.Name, *returnedIssue.Type.Name)
731+
}
732+
725733
// Check assignees if expected
726734
if len(tc.expectedIssue.Assignees) > 0 {
727735
assert.Equal(t, len(tc.expectedIssue.Assignees), len(returnedIssue.Assignees))
@@ -1066,6 +1074,7 @@ func Test_UpdateIssue(t *testing.T) {
10661074
assert.Contains(t, tool.InputSchema.Properties, "labels")
10671075
assert.Contains(t, tool.InputSchema.Properties, "assignees")
10681076
assert.Contains(t, tool.InputSchema.Properties, "milestone")
1077+
assert.Contains(t, tool.InputSchema.Properties, "type")
10691078
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "issue_number"})
10701079

10711080
// Setup mock issue for success case
@@ -1078,6 +1087,7 @@ func Test_UpdateIssue(t *testing.T) {
10781087
Assignees: []*github.User{{Login: github.Ptr("assignee1")}, {Login: github.Ptr("assignee2")}},
10791088
Labels: []*github.Label{{Name: github.Ptr("bug")}, {Name: github.Ptr("priority")}},
10801089
Milestone: &github.Milestone{Number: github.Ptr(5)},
1090+
Type: &github.IssueType{Name: github.Ptr("Bug")},
10811091
}
10821092

10831093
tests := []struct {
@@ -1100,6 +1110,7 @@ func Test_UpdateIssue(t *testing.T) {
11001110
"labels": []any{"bug", "priority"},
11011111
"assignees": []any{"assignee1", "assignee2"},
11021112
"milestone": float64(5),
1113+
"type": "Bug",
11031114
}).andThen(
11041115
mockResponse(t, http.StatusOK, mockIssue),
11051116
),
@@ -1115,6 +1126,7 @@ func Test_UpdateIssue(t *testing.T) {
11151126
"labels": []any{"bug", "priority"},
11161127
"assignees": []any{"assignee1", "assignee2"},
11171128
"milestone": float64(5),
1129+
"type": "Bug",
11181130
},
11191131
expectError: false,
11201132
expectedIssue: mockIssue,
@@ -1126,24 +1138,27 @@ func Test_UpdateIssue(t *testing.T) {
11261138
mock.PatchReposIssuesByOwnerByRepoByIssueNumber,
11271139
mockResponse(t, http.StatusOK, &github.Issue{
11281140
Number: github.Ptr(123),
1129-
Title: github.Ptr("Only Title Updated"),
1141+
Title: github.Ptr("Updated Issue Title"),
11301142
HTMLURL: github.Ptr("https://github.com/owner/repo/issues/123"),
11311143
State: github.Ptr("open"),
1144+
Type: &github.IssueType{Name: github.Ptr("Feature")},
11321145
}),
11331146
),
11341147
),
11351148
requestArgs: map[string]interface{}{
11361149
"owner": "owner",
11371150
"repo": "repo",
11381151
"issue_number": float64(123),
1139-
"title": "Only Title Updated",
1152+
"title": "Updated Issue Title",
1153+
"type": "Feature",
11401154
},
11411155
expectError: false,
11421156
expectedIssue: &github.Issue{
11431157
Number: github.Ptr(123),
1144-
Title: github.Ptr("Only Title Updated"),
1158+
Title: github.Ptr("Updated Issue Title"),
11451159
HTMLURL: github.Ptr("https://github.com/owner/repo/issues/123"),
11461160
State: github.Ptr("open"),
1161+
Type: &github.IssueType{Name: github.Ptr("Feature")},
11471162
},
11481163
},
11491164
{
@@ -1232,6 +1247,10 @@ func Test_UpdateIssue(t *testing.T) {
12321247
assert.Equal(t, *tc.expectedIssue.Body, *returnedIssue.Body)
12331248
}
12341249

1250+
if tc.expectedIssue.Type != nil {
1251+
assert.Equal(t, *tc.expectedIssue.Type.Name, *returnedIssue.Type.Name)
1252+
}
1253+
12351254
// Check assignees if expected
12361255
if len(tc.expectedIssue.Assignees) > 0 {
12371256
assert.Len(t, returnedIssue.Assignees, len(tc.expectedIssue.Assignees))

0 commit comments

Comments
 (0)