feat(forge): add MilestoneService, fix comment creation

- Add MilestoneService with ListAll, Get, Create
- Fix CreateIssueCommentOption Updated field to *time.Time (was serialising zero value)
- Register Milestones in Forge client

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-03-23 12:53:10 +00:00
parent 244ff651c3
commit ecad738da9
3 changed files with 46 additions and 1 deletions

View file

@ -22,6 +22,7 @@ type Forge struct {
Wiki *WikiService
Misc *MiscService
Commits *CommitService
Milestones *MilestoneService
}
// NewForge creates a new Forge client.
@ -46,6 +47,7 @@ func NewForge(url, token string, opts ...Option) *Forge {
f.Wiki = newWikiService(c)
f.Misc = newMiscService(c)
f.Commits = newCommitService(c)
f.Milestones = newMilestoneService(c)
return f
}

43
milestones.go Normal file
View file

@ -0,0 +1,43 @@
package forge
import (
"context"
"fmt"
"dappco.re/go/core/forge/types"
)
// MilestoneService handles repository milestones.
type MilestoneService struct {
client *Client
}
func newMilestoneService(c *Client) *MilestoneService {
return &MilestoneService{client: c}
}
// ListAll returns all milestones for a repository.
func (s *MilestoneService) ListAll(ctx context.Context, params Params) ([]types.Milestone, error) {
path := fmt.Sprintf("/api/v1/repos/%s/%s/milestones", params["owner"], params["repo"])
return ListAll[types.Milestone](ctx, s.client, path, nil)
}
// Get returns a single milestone by ID.
func (s *MilestoneService) Get(ctx context.Context, owner, repo string, id int64) (*types.Milestone, error) {
path := fmt.Sprintf("/api/v1/repos/%s/%s/milestones/%d", owner, repo, id)
var out types.Milestone
if err := s.client.Get(ctx, path, &out); err != nil {
return nil, err
}
return &out, nil
}
// Create creates a new milestone.
func (s *MilestoneService) Create(ctx context.Context, owner, repo string, opts *types.CreateMilestoneOption) (*types.Milestone, error) {
path := fmt.Sprintf("/api/v1/repos/%s/%s/milestones", owner, repo)
var out types.Milestone
if err := s.client.Post(ctx, path, opts, &out); err != nil {
return nil, err
}
return &out, nil
}

View file

@ -8,7 +8,7 @@ import "time"
// CreateIssueCommentOption — CreateIssueCommentOption options for creating a comment on an issue
type CreateIssueCommentOption struct {
Body string `json:"body"`
Updated time.Time `json:"updated_at,omitempty"`
Updated *time.Time `json:"updated_at,omitempty"`
}
// CreateIssueOption — CreateIssueOption options to create one issue