mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-08-30 12:07:45 +00:00
feat(project): add project management tools
Add read and write tools for Gitea projects, including project and column CRUD and issue-to-project-column management. Bump gitea.dev/sdk to include ProjectsService. Assisted-by: Codet:codet-internal
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
package project
|
||||
|
||||
import (
|
||||
"gitea.com/gitea/gitea-mcp/pkg/slim"
|
||||
|
||||
gitea_sdk "gitea.dev/sdk"
|
||||
)
|
||||
|
||||
func slimProject(p *gitea_sdk.Project) map[string]any {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
return map[string]any{
|
||||
"id": p.ID,
|
||||
"title": p.Title,
|
||||
"description": p.Description,
|
||||
"state": string(p.State),
|
||||
"type": string(p.Type),
|
||||
"template_type": string(p.TemplateType),
|
||||
"card_type": string(p.CardType),
|
||||
"owner_id": p.OwnerID,
|
||||
"repo_id": p.RepoID,
|
||||
"creator": slim.UserLogin(p.Creator),
|
||||
"num_open_issues": p.NumOpenIssues,
|
||||
"num_closed_issues": p.NumClosedIssues,
|
||||
"num_issues": p.NumIssues,
|
||||
"html_url": p.HTMLURL,
|
||||
"created_at": p.Created,
|
||||
"updated_at": p.Updated,
|
||||
"closed_at": p.Closed,
|
||||
}
|
||||
}
|
||||
|
||||
func slimProjects(projects []*gitea_sdk.Project) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(projects))
|
||||
for _, p := range projects {
|
||||
if p == nil {
|
||||
continue
|
||||
}
|
||||
out = append(out, slimProject(p))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func slimProjectColumn(c *gitea_sdk.ProjectColumn) map[string]any {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return map[string]any{
|
||||
"id": c.ID,
|
||||
"title": c.Title,
|
||||
"default": c.Default,
|
||||
"sorting": c.Sorting,
|
||||
"color": c.Color,
|
||||
"project_id": c.ProjectID,
|
||||
"creator": slim.UserLogin(c.Creator),
|
||||
"created_at": c.Created,
|
||||
"updated_at": c.Updated,
|
||||
}
|
||||
}
|
||||
|
||||
func slimProjectColumns(columns []*gitea_sdk.ProjectColumn) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(columns))
|
||||
for _, c := range columns {
|
||||
if c == nil {
|
||||
continue
|
||||
}
|
||||
out = append(out, slimProjectColumn(c))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func slimProjectIssue(i *gitea_sdk.Issue) map[string]any {
|
||||
if i == nil {
|
||||
return nil
|
||||
}
|
||||
return map[string]any{
|
||||
"id": i.ID,
|
||||
"number": i.Index,
|
||||
"title": i.Title,
|
||||
"state": string(i.State),
|
||||
"html_url": i.HTMLURL,
|
||||
"user": slim.UserLogin(i.Poster),
|
||||
}
|
||||
}
|
||||
|
||||
func slimProjectIssues(issues []*gitea_sdk.Issue) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(issues))
|
||||
for _, i := range issues {
|
||||
if i == nil {
|
||||
continue
|
||||
}
|
||||
out = append(out, slimProjectIssue(i))
|
||||
}
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user