Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/github/projects.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"time"

ghErrors "github.com/github/github-mcp-server/pkg/errors"
Expand DownExpand Up@@ -1125,7 +1126,8 @@ func addProjectItem(ctx context.Context, gqlClient *githubv4.Client, owner, owne
var mutation struct {
AddProjectV2ItemByID struct {
Item struct {
ID githubv4.ID
ID githubv4.ID
FullDatabaseID string `graphql:"fullDatabaseId"`
}
} `graphql:"addProjectV2ItemById(input: $input)"`
}
Expand All@@ -1151,6 +1153,12 @@ func addProjectItem(ctx context.Context, gqlClient *githubv4.Client, owner, owne
"id": mutation.AddProjectV2ItemByID.Item.ID,
"message": fmt.Sprintf("Successfully added %s %s/%s#%d to project %s/%d", itemType, itemOwner, itemRepo, itemNumber, owner, projectNumber),
}
if fullDatabaseID := mutation.AddProjectV2ItemByID.Item.FullDatabaseID; fullDatabaseID != "" {
result["full_database_id"] = fullDatabaseID
if itemID, err := strconv.ParseInt(fullDatabaseID, 10, 64); err == nil {
result["item_id"] = itemID
}
}

r, err := json.Marshal(result)
if err != nil {
Expand Down
16 changes: 12 additions & 4 deletions pkg/github/projects_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -630,7 +630,8 @@ func Test_ProjectsWrite_AddProjectItem(t *testing.T) {
struct {
AddProjectV2ItemByID struct {
Item struct {
ID githubv4.ID
ID githubv4.ID
FullDatabaseID string `graphql:"fullDatabaseId"`
}
} `graphql:"addProjectV2ItemById(input: $input)"`
}{},
Expand All@@ -642,7 +643,8 @@ func Test_ProjectsWrite_AddProjectItem(t *testing.T) {
githubv4mock.DataResponse(map[string]any{
"addProjectV2ItemById": map[string]any{
"item": map[string]any{
"id": "PVTI_item1",
"id": "PVTI_item1",
"fullDatabaseId": "1001",
},
},
}),
Expand DownExpand Up@@ -674,6 +676,8 @@ func Test_ProjectsWrite_AddProjectItem(t *testing.T) {
err = json.Unmarshal([]byte(textContent.Text), &response)
require.NoError(t, err)
assert.NotNil(t, response["id"])
assert.Equal(t, float64(1001), response["item_id"])
assert.Equal(t, "1001", response["full_database_id"])
assert.Contains(t, response["message"], "Successfully added")
})

Expand DownExpand Up@@ -727,7 +731,8 @@ func Test_ProjectsWrite_AddProjectItem(t *testing.T) {
struct {
AddProjectV2ItemByID struct {
Item struct {
ID githubv4.ID
ID githubv4.ID
FullDatabaseID string `graphql:"fullDatabaseId"`
}
} `graphql:"addProjectV2ItemById(input: $input)"`
}{},
Expand All@@ -739,7 +744,8 @@ func Test_ProjectsWrite_AddProjectItem(t *testing.T) {
githubv4mock.DataResponse(map[string]any{
"addProjectV2ItemById": map[string]any{
"item": map[string]any{
"id": "PVTI_item2",
"id": "PVTI_item2",
"fullDatabaseId": "1002",
},
},
}),
Expand DownExpand Up@@ -771,6 +777,8 @@ func Test_ProjectsWrite_AddProjectItem(t *testing.T) {
err = json.Unmarshal([]byte(textContent.Text), &response)
require.NoError(t, err)
assert.NotNil(t, response["id"])
assert.Equal(t, float64(1002), response["item_id"])
assert.Equal(t, "1002", response["full_database_id"])
assert.Contains(t, response["message"], "Successfully added")
})

Expand Down
Loading