4b4b5ee247
Add 20+ new MCP tools for repository administration: - Repository: get_repo, repo_write (edit/delete/transfer), list_forks - Branch Protection: read (list/get) and write (create/edit/delete) - Webhooks: read (list/get) and write (create/edit/delete/test) - Collaborators: read (list) and write (add/delete) - Deploy Keys: read (list/get) and write (create/delete) - Topics: read (list) and write (add/delete/set) - Compare: get_compare for branch/tag/commit comparison - Organization: org_read (get/list_teams/get_team/list_team_members/list_team_repos) and org_write (create_team/delete_team/add_team_member/remove_team_member/add_team_repo/remove_team_repo) - PR enhancements: list_files and is_merged methods added to pull_request_read Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
package org
|
|
|
|
import (
|
|
gitea_sdk "code.gitea.io/sdk/gitea"
|
|
)
|
|
|
|
func slimOrg(o *gitea_sdk.Organization) map[string]any {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
return map[string]any{
|
|
"id": o.ID,
|
|
"username": o.UserName,
|
|
"full_name": o.FullName,
|
|
"description": o.Description,
|
|
"website": o.Website,
|
|
"location": o.Location,
|
|
"visibility": o.Visibility,
|
|
"avatar_url": o.AvatarURL,
|
|
}
|
|
}
|
|
|
|
func slimTeam(t *gitea_sdk.Team) map[string]any {
|
|
if t == nil {
|
|
return nil
|
|
}
|
|
return map[string]any{
|
|
"id": t.ID,
|
|
"name": t.Name,
|
|
"description": t.Description,
|
|
"permission": t.Permission,
|
|
"units": t.Units,
|
|
"includes_all_repositories": t.IncludesAllRepositories,
|
|
"can_create_org_repo": t.CanCreateOrgRepo,
|
|
}
|
|
}
|
|
|
|
func slimTeams(teams []*gitea_sdk.Team) []map[string]any {
|
|
out := make([]map[string]any, 0, len(teams))
|
|
for _, t := range teams {
|
|
out = append(out, slimTeam(t))
|
|
}
|
|
return out
|
|
}
|
|
|
|
func slimUser(u *gitea_sdk.User) map[string]any {
|
|
if u == nil {
|
|
return nil
|
|
}
|
|
return map[string]any{
|
|
"id": u.ID,
|
|
"login": u.UserName,
|
|
"full_name": u.FullName,
|
|
"email": u.Email,
|
|
"avatar_url": u.AvatarURL,
|
|
}
|
|
}
|
|
|
|
func slimUsers(users []*gitea_sdk.User) []map[string]any {
|
|
out := make([]map[string]any, 0, len(users))
|
|
for _, u := range users {
|
|
out = append(out, slimUser(u))
|
|
}
|
|
return out
|
|
}
|
|
|
|
func slimRepos(repos []*gitea_sdk.Repository) []map[string]any {
|
|
out := make([]map[string]any, 0, len(repos))
|
|
for _, r := range repos {
|
|
if r == nil {
|
|
continue
|
|
}
|
|
m := map[string]any{
|
|
"id": r.ID,
|
|
"full_name": r.FullName,
|
|
"html_url": r.HTMLURL,
|
|
"private": r.Private,
|
|
}
|
|
if r.Owner != nil {
|
|
m["owner"] = r.Owner.UserName
|
|
}
|
|
out = append(out, m)
|
|
}
|
|
return out
|
|
}
|