Skip to content

Commit 6043bec

Browse files
authored
Cleanup (#628)
* Remove unused function and add test script * Call test from the workflow
1 parent 39109b3 commit 6043bec

File tree

4 files changed

+4
-52
lines changed

4 files changed

+4
-52
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: go mod download
2727

2828
- name: Run unit tests
29-
run: go test -race ./...
29+
run: script/test
3030

3131
- name: Build
3232
run: go build -v ./cmd/github-mcp-server

pkg/github/discussions.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,56 +13,6 @@ import (
1313
"github.com/shurcooL/githubv4"
1414
)
1515

16-
// GetAllDiscussionCategories retrieves all discussion categories for a repository
17-
// by paginating through all pages and returns them as a map where the key is the
18-
// category name and the value is the category ID.
19-
func GetAllDiscussionCategories(ctx context.Context, client *githubv4.Client, owner, repo string) (map[string]string, error) {
20-
categories := make(map[string]string)
21-
var after string
22-
hasNextPage := true
23-
24-
for hasNextPage {
25-
// Prepare GraphQL query with pagination
26-
var q struct {
27-
Repository struct {
28-
DiscussionCategories struct {
29-
Nodes []struct {
30-
ID githubv4.ID
31-
Name githubv4.String
32-
}
33-
PageInfo struct {
34-
HasNextPage githubv4.Boolean
35-
EndCursor githubv4.String
36-
}
37-
} `graphql:"discussionCategories(first: 100, after: $after)"`
38-
} `graphql:"repository(owner: $owner, name: $repo)"`
39-
}
40-
41-
vars := map[string]interface{}{
42-
"owner": githubv4.String(owner),
43-
"repo": githubv4.String(repo),
44-
"after": githubv4.String(after),
45-
}
46-
47-
if err := client.Query(ctx, &q, vars); err != nil {
48-
return nil, fmt.Errorf("failed to query discussion categories: %w", err)
49-
}
50-
51-
// Add categories to the map
52-
for _, category := range q.Repository.DiscussionCategories.Nodes {
53-
categories[string(category.Name)] = fmt.Sprint(category.ID)
54-
}
55-
56-
// Check if there are more pages
57-
hasNextPage = bool(q.Repository.DiscussionCategories.PageInfo.HasNextPage)
58-
if hasNextPage {
59-
after = string(q.Repository.DiscussionCategories.PageInfo.EndCursor)
60-
}
61-
}
62-
63-
return categories, nil
64-
}
65-
6616
func ListDiscussions(getGQLClient GetGQLClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
6717
return mcp.NewTool("list_discussions",
6818
mcp.WithDescription(t("TOOL_LIST_DISCUSSIONS_DESCRIPTION", "List discussions for a repository")),

script/lint

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ BINDIR="$(git rev-parse --show-toplevel)"/bin
77
BINARY=$BINDIR/golangci-lint
88
GOLANGCI_LINT_VERSION=v2.2.1
99

10-
1110
if [ ! -f "$BINARY" ]; then
1211
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s "$GOLANGCI_LINT_VERSION"
1312
fi

script/test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set -eu
2+
3+
go test -race ./...

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