Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[pull] main from github:main #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ export GITHUB_MCP_TOOL_ADD_ISSUE_COMMENT_DESCRIPTION="an alternative description
- `owner`: Repository owner (string, required)
- `repo`: Repository name (string, required)
- `sha`: Branch name, tag, or commit SHA (string, optional)
- `author`: Author username or email address (string, optional)
- `path`: Only commits containing this file path (string, optional)
- `page`: Page number (number, optional)
- `perPage`: Results per page (number, optional)
Expand Down
4 changes: 4 additions & 0 deletions pkg/github/__toolsnaps__/list_commits.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"sha": {
"description": "SHA or Branch name",
"type": "string"
},
"author": {
"description": "Author username or email address",
"type": "string"
}
},
"required": [
Expand Down
10 changes: 9 additions & 1 deletion pkg/github/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ func ListCommits(getClient GetClientFn, t translations.TranslationHelperFunc) (t
mcp.WithString("sha",
mcp.Description("SHA or Branch name"),
),
mcp.WithString("author",
mcp.Description("Author username or email address"),
),
WithPagination(),
),
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
Expand All @@ -123,13 +126,18 @@ func ListCommits(getClient GetClientFn, t translations.TranslationHelperFunc) (t
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
author, err := OptionalParam[string](request, "author")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
pagination, err := OptionalPaginationParams(request)
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}

opts := &github.CommitsListOptions{
SHA: sha,
SHA: sha,
Author: author,
ListOptions: github.ListOptions{
Page: pagination.page,
PerPage: pagination.perPage,
Expand Down
10 changes: 7 additions & 3 deletions pkg/github/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ func Test_ListCommits(t *testing.T) {
assert.Contains(t, tool.InputSchema.Properties, "owner")
assert.Contains(t, tool.InputSchema.Properties, "repo")
assert.Contains(t, tool.InputSchema.Properties, "sha")
assert.Contains(t, tool.InputSchema.Properties, "author")
assert.Contains(t, tool.InputSchema.Properties, "page")
assert.Contains(t, tool.InputSchema.Properties, "perPage")
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo"})
Expand Down Expand Up @@ -713,6 +714,7 @@ func Test_ListCommits(t *testing.T) {
mock.WithRequestMatchHandler(
mock.GetReposCommitsByOwnerByRepo,
expectQueryParams(t, map[string]string{
"author": "username",
"sha": "main",
"page": "1",
"per_page": "30",
Expand All @@ -722,9 +724,10 @@ func Test_ListCommits(t *testing.T) {
),
),
requestArgs: map[string]interface{}{
"owner": "owner",
"repo": "repo",
"sha": "main",
"owner": "owner",
"repo": "repo",
"sha": "main",
"author": "username",
},
expectError: false,
expectedCommits: mockCommits,
Expand Down Expand Up @@ -801,6 +804,7 @@ func Test_ListCommits(t *testing.T) {
require.NoError(t, err)
assert.Len(t, returnedCommits, len(tc.expectedCommits))
for i, commit := range returnedCommits {
assert.Equal(t, *tc.expectedCommits[i].Author, *commit.Author)
assert.Equal(t, *tc.expectedCommits[i].SHA, *commit.SHA)
assert.Equal(t, *tc.expectedCommits[i].Commit.Message, *commit.Commit.Message)
assert.Equal(t, *tc.expectedCommits[i].Author.Login, *commit.Author.Login)
Expand Down