Documentation
¶
Index ¶
- Constants
- Variables
- func Bool(b bool) *bool
- func Detect(forgeFlag, repoFlag string) (forge, repo string, err error)
- func Int(i int) *int
- func ParseRemote(remote string) (forge, repo string, err error)
- func String(s string) *string
- type BaseError
- type CheckSummary
- type Forge
- type Issue
- type IssueCloseOptions
- type IssueCreateOptions
- type IssueGetOptions
- type IssueListOptions
- type IssueReopenOptions
- type IssueService
- type IssueUpdateOptions
- type Label
- type LabelCreateOptions
- type LabelDeleteOptions
- type LabelListOptions
- type LabelService
- type LabelUpdateOptions
- type ListMeta
- type PR
- type PRCloseOptions
- type PRCreateOptions
- type PRGetOptions
- type PRListOptions
- type PRMergeOptions
- type PRService
- type PRUpdateOptions
- type ReviewState
- type StructuredError
Constants ¶
const ( StateOpen = "open" StateClosed = "closed" StateMerged = "merged" // PR only StateAll = "all" // list filter only )
Issue and PR states.
Variables ¶
var RemoteFn func() (string, error)
RemoteFn resolves the URL of the "origin" git remote. Defaults to shelling out to git; overridden in tests.
Functions ¶
func Bool ¶
Bool returns a pointer to the given bool value. Useful for constructing options structs with optional fields.
func Detect ¶
Detect determines the forge host and repository owner/name. If forgeFlag or repoFlag are provided, they override auto-detection.
func Int ¶
Int returns a pointer to the given int value. Useful for constructing options structs with optional fields.
func ParseRemote ¶
ParseRemote extracts forge host and owner/repo from a git remote URL. Handles HTTPS (https://github.com/owner/repo.git) and SSH (git@github.com:owner/repo.git).
Types ¶
type BaseError ¶
type BaseError struct {
// contains filtered or unexported fields
}
BaseError is a reusable implementation of StructuredError. Use NewBaseError to construct one.
func NewBaseError ¶
NewBaseError creates a BaseError with a message and optional help hint.
type CheckSummary ¶
CheckSummary holds aggregate check/CI run status for a PR.
type Forge ¶
type Forge interface {
Issues() IssueService
Labels() LabelService
PRs() PRService
}
Forge is the central facade interface composed of service interfaces. Implementations provide access to a specific forge (GitHub, GitLab, Forgejo).
type Issue ¶
type Issue struct {
Number int `json:"number"`
Title string `json:"title"`
State string `json:"state"` // "open", "closed"
Body string `json:"body"`
Labels []Label `json:"labels"`
Author string `json:"author"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
URL string `json:"url"`
Extras map[string]any `json:"extras,omitempty"`
}
Issue represents an issue with normalized fields across forges. Fields present in ≥2 forges are normalized; forge-specific fields go in Extras.
type IssueCloseOptions ¶
type IssueCloseOptions struct {
Number int // issue number
}
IssueCloseOptions holds parameters for closing an issue.
type IssueCreateOptions ¶
type IssueCreateOptions struct {
Title *string `json:"title,omitempty"` // required
Body *string `json:"body,omitempty"`
Labels []string `json:"labels,omitempty"`
Assignees []string `json:"assignees,omitempty"`
}
IssueCreateOptions holds parameters for creating an issue.
type IssueGetOptions ¶
type IssueGetOptions struct {
Number int // issue number
}
IssueGetOptions holds parameters for fetching a single issue.
type IssueListOptions ¶
type IssueListOptions struct {
State string // "open", "closed", "all"
Labels []string // filter by label names
Sort string // "created", "updated", "comments"
Direction string // "asc", "desc"
Limit int // max results per page
Page int // page number (1-indexed)
}
IssueListOptions holds parameters for listing issues.
type IssueReopenOptions ¶
type IssueReopenOptions struct {
Number int // issue number
}
IssueReopenOptions holds parameters for reopening an issue.
type IssueService ¶
type IssueService interface {
List(ctx context.Context, opts IssueListOptions) ([]Issue, *ListMeta, error)
Get(ctx context.Context, opts IssueGetOptions) (*Issue, error)
Create(ctx context.Context, opts IssueCreateOptions) (*Issue, error)
Update(ctx context.Context, opts IssueUpdateOptions) (*Issue, error)
Close(ctx context.Context, opts IssueCloseOptions) (*Issue, error)
Reopen(ctx context.Context, opts IssueReopenOptions) (*Issue, error)
}
IssueService defines operations for issue management.
type IssueUpdateOptions ¶
type IssueUpdateOptions struct {
Number int // issue number
Title *string `json:"title,omitempty"`
Body *string `json:"body,omitempty"`
State *string `json:"state,omitempty"` // "open" or "closed"
Labels []string `json:"labels,omitempty"`
Assignees []string `json:"assignees,omitempty"`
}
IssueUpdateOptions holds parameters for updating an issue.
type Label ¶
type Label struct {
Name string `json:"name"`
Scope string `json:"scope,omitempty"` // empty for unscoped labels
Color string `json:"color"` // hex color without #
Description string `json:"description"`
Exclusive bool `json:"exclusive"` // scoped labels: only one per scope
Extras map[string]any `json:"extras,omitempty"`
}
Label represents a label with normalized fields. Scope (e.g., "kind" from GitHub's "kind:bug" or GitLab's "kind::bug") and Exclusive are normalized across GitHub, GitLab, and Forgejo.
type LabelCreateOptions ¶
type LabelCreateOptions struct {
Scope *string `json:"scope,omitempty"` // scope prefix (nil for unscoped)
Name string `json:"name"` // label name (required)
Color *string `json:"color,omitempty"` // hex color without #
Description *string `json:"description,omitempty"`
Exclusive *bool `json:"exclusive,omitempty"` // only one label allowed per scope
}
LabelCreateOptions holds parameters for creating a label.
type LabelDeleteOptions ¶
type LabelDeleteOptions struct {
Scope string // scope prefix (empty for unscoped)
Name string // label name
}
LabelDeleteOptions holds parameters for deleting a label.
type LabelListOptions ¶
type LabelListOptions struct {
Limit int // max results per page
Page int // page number (1-indexed)
}
LabelListOptions holds parameters for listing labels.
type LabelService ¶
type LabelService interface {
List(ctx context.Context, opts LabelListOptions) ([]Label, error)
Create(ctx context.Context, opts LabelCreateOptions) (*Label, error)
Update(ctx context.Context, opts LabelUpdateOptions) (*Label, error)
Delete(ctx context.Context, opts LabelDeleteOptions) error
}
LabelService defines operations for label management.
type LabelUpdateOptions ¶
type LabelUpdateOptions struct {
Scope string // current scope
Name string // current name
NewName *string `json:"new_name,omitempty"`
NewScope *string `json:"new_scope,omitempty"`
Color *string `json:"color,omitempty"`
Description *string `json:"description,omitempty"`
Exclusive *bool `json:"exclusive,omitempty"`
}
LabelUpdateOptions holds parameters for updating a label.
type ListMeta ¶
type ListMeta struct {
Total int `json:"total"` // total number of items matching the query
Count int `json:"count"` // number of items in this response
}
ListMeta holds aggregate count information for list responses.
type PR ¶
type PR struct {
Number int `json:"number"`
Title string `json:"title"`
State string `json:"state"` // "open", "closed", "merged"
Body string `json:"body"`
BaseRef string `json:"base_ref"` // target branch
HeadRef string `json:"head_ref"` // source branch
Stack string `json:"stack,omitempty"` // stack name extracted from title prefix
DependsOn []int `json:"depends_on"` // PR numbers this depends on
DependedOnBy []int `json:"depended_on_by"` // PR numbers that depend on this
Reviewers []ReviewState `json:"reviewers,omitempty"`
Checks *CheckSummary `json:"checks,omitempty"`
Author string `json:"author"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
URL string `json:"url"`
Extras map[string]any `json:"extras,omitempty"`
}
PR represents a pull request / merge request with normalized fields.
type PRCloseOptions ¶
type PRCloseOptions struct {
Number int // PR number
}
PRCloseOptions holds parameters for closing a pull request.
type PRCreateOptions ¶
type PRCreateOptions struct {
Title *string `json:"title,omitempty"` // required
Body *string `json:"body,omitempty"`
HeadRef *string `json:"head,omitempty"` // source branch (default: current)
BaseRef *string `json:"base,omitempty"` // target branch (default: repo default)
Stack *string `json:"stack,omitempty"` // stack name; auto-derived from branch if nil
Draft *bool `json:"draft,omitempty"`
}
PRCreateOptions holds parameters for creating a pull request.
type PRGetOptions ¶
type PRGetOptions struct {
Number int // PR number
}
PRGetOptions holds parameters for fetching a single pull request.
type PRListOptions ¶
type PRListOptions struct {
State string // "open", "closed", "merged", "all"
Sort string // "created", "updated"
Direction string // "asc", "desc"
Limit int // max results per page
Page int // page number (1-indexed)
}
PRListOptions holds parameters for listing pull requests.
type PRMergeOptions ¶
type PRMergeOptions struct {
Number int // PR number
Method *string `json:"merge_method,omitempty"` // "merge", "squash", "rebase"
Title *string `json:"title,omitempty"`
Body *string `json:"body,omitempty"`
}
PRMergeOptions holds parameters for merging a pull request.
type PRService ¶
type PRService interface {
List(ctx context.Context, opts PRListOptions) ([]PR, *ListMeta, error)
Get(ctx context.Context, opts PRGetOptions) (*PR, error)
Create(ctx context.Context, opts PRCreateOptions) (*PR, error)
Update(ctx context.Context, opts PRUpdateOptions) (*PR, error)
Merge(ctx context.Context, opts PRMergeOptions) (*PR, error)
Close(ctx context.Context, opts PRCloseOptions) (*PR, error)
}
PRService defines operations for pull request management.
type PRUpdateOptions ¶
PRUpdateOptions holds parameters for updating a pull request.
type ReviewState ¶
type ReviewState struct {
Login string `json:"login"`
State string `json:"state"` // APPROVED, CHANGES_REQUESTED, COMMENTED, PENDING
}
ReviewState represents a single reviewer's review status on a PR.
type StructuredError ¶
type StructuredError interface {
error
// Message returns the user-facing error message.
Message() string
// Help returns an optional corrective action hint, or "".
Help() string
}
StructuredError is an error that carries a user-facing message and an optional help hint. All architectural layers — adapters, commands, auth — return errors satisfying this interface so that main.go can format output with a single type-assertion.