@@ -18,94 +18,6 @@ import (
18
18
"github.com/mark3labs/mcp-go/server"
19
19
)
20
20
21
- // convertToMinimalCommit converts a GitHub API RepositoryCommit to MinimalCommit
22
- func convertToMinimalCommit (commit * github.RepositoryCommit , includeDiffs bool ) MinimalCommit {
23
- minimalCommit := MinimalCommit {
24
- SHA : commit .GetSHA (),
25
- HTMLURL : commit .GetHTMLURL (),
26
- }
27
-
28
- if commit .Commit != nil {
29
- minimalCommit .Commit = & MinimalCommitInfo {
30
- Message : commit .Commit .GetMessage (),
31
- }
32
-
33
- if commit .Commit .Author != nil {
34
- minimalCommit .Commit .Author = & MinimalCommitAuthor {
35
- Name : commit .Commit .Author .GetName (),
36
- Email : commit .Commit .Author .GetEmail (),
37
- }
38
- if commit .Commit .Author .Date != nil {
39
- minimalCommit .Commit .Author .Date = commit .Commit .Author .Date .Format ("2006-01-02T15:04:05Z" )
40
- }
41
- }
42
-
43
- if commit .Commit .Committer != nil {
44
- minimalCommit .Commit .Committer = & MinimalCommitAuthor {
45
- Name : commit .Commit .Committer .GetName (),
46
- Email : commit .Commit .Committer .GetEmail (),
47
- }
48
- if commit .Commit .Committer .Date != nil {
49
- minimalCommit .Commit .Committer .Date = commit .Commit .Committer .Date .Format ("2006-01-02T15:04:05Z" )
50
- }
51
- }
52
- }
53
-
54
- if commit .Author != nil {
55
- minimalCommit .Author = & MinimalUser {
56
- Login : commit .Author .GetLogin (),
57
- ID : commit .Author .GetID (),
58
- ProfileURL : commit .Author .GetHTMLURL (),
59
- AvatarURL : commit .Author .GetAvatarURL (),
60
- }
61
- }
62
-
63
- if commit .Committer != nil {
64
- minimalCommit .Committer = & MinimalUser {
65
- Login : commit .Committer .GetLogin (),
66
- ID : commit .Committer .GetID (),
67
- ProfileURL : commit .Committer .GetHTMLURL (),
68
- AvatarURL : commit .Committer .GetAvatarURL (),
69
- }
70
- }
71
-
72
- // Only include stats and files if includeDiffs is true
73
- if includeDiffs {
74
- if commit .Stats != nil {
75
- minimalCommit .Stats = & MinimalCommitStats {
76
- Additions : commit .Stats .GetAdditions (),
77
- Deletions : commit .Stats .GetDeletions (),
78
- Total : commit .Stats .GetTotal (),
79
- }
80
- }
81
-
82
- if len (commit .Files ) > 0 {
83
- minimalCommit .Files = make ([]MinimalCommitFile , 0 , len (commit .Files ))
84
- for _ , file := range commit .Files {
85
- minimalFile := MinimalCommitFile {
86
- Filename : file .GetFilename (),
87
- Status : file .GetStatus (),
88
- Additions : file .GetAdditions (),
89
- Deletions : file .GetDeletions (),
90
- Changes : file .GetChanges (),
91
- }
92
- minimalCommit .Files = append (minimalCommit .Files , minimalFile )
93
- }
94
- }
95
- }
96
-
97
- return minimalCommit
98
- }
99
-
100
- // convertToMinimalBranch converts a GitHub API Branch to MinimalBranch
101
- func convertToMinimalBranch (branch * github.Branch ) MinimalBranch {
102
- return MinimalBranch {
103
- Name : branch .GetName (),
104
- SHA : branch .GetCommit ().GetSHA (),
105
- Protected : branch .GetProtected (),
106
- }
107
- }
108
-
109
21
func GetCommit (getClient GetClientFn , t translations.TranslationHelperFunc ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
110
22
return mcp .NewTool ("get_commit" ,
111
23
mcp .WithDescription (t ("TOOL_GET_COMMITS_DESCRIPTION" , "Get details for a commit from a GitHub repository" )),
@@ -274,9 +186,9 @@ func ListCommits(getClient GetClientFn, t translations.TranslationHelperFunc) (t
274
186
275
187
// Convert to minimal commits
276
188
minimalCommits := make ([]MinimalCommit , len (commits ))
277
- for i , commit := range commits {
278
- minimalCommits [i ] = convertToMinimalCommit (commit , false )
279
- }
189
+ for i , commit := range commits {
190
+ minimalCommits [i ] = convertToMinimalCommit (commit , false )
191
+ }
280
192
281
193
r , err := json .Marshal (minimalCommits )
282
194
if err != nil {
0 commit comments