Documentation
¶
Index ¶
- Variables
- func FormatRemoteID(ft ForgeType, number int) string
- func ParseHostOwnerRepo(remoteURL string) (host, owner, repo string, err error)
- func ParseOwnerRepo(remoteURL string) (owner, repo string, err error)
- type Comment
- type Diff
- type Forge
- type ForgeType
- type GitHubForge
- func (g *GitHubForge) CheckAuthenticated() error
- func (g *GitHubForge) CheckAvailable() error
- func (g *GitHubForge) CommentOnDiff(ctx context.Context, owner, repo string, number int, body string) error
- func (g *GitHubForge) CommentOnIssue(ctx context.Context, owner, repo string, number int, body string) error
- func (g *GitHubForge) CreateDiff(ctx context.Context, owner, repo, title, body, head, base string) (*Diff, error)
- func (g *GitHubForge) CreateIssue(ctx context.Context, owner, repo, title, body string) (*Issue, error)
- func (g *GitHubForge) GetDiff(ctx context.Context, owner, repo string, number int) (*Diff, error)
- func (g *GitHubForge) GetIssue(ctx context.Context, owner, repo string, number int) (*Issue, error)
- func (g *GitHubForge) ListDiffComments(ctx context.Context, owner, repo string, number int) ([]Comment, error)
- func (g *GitHubForge) ListDiffs(ctx context.Context, owner, repo, state string) ([]Diff, error)
- func (g *GitHubForge) ListIssues(ctx context.Context, owner, repo, state string) ([]Issue, error)
- func (g *GitHubForge) Type() ForgeType
- type GitLabForge
- func (g *GitLabForge) CheckAuthenticated() error
- func (g *GitLabForge) CheckAvailable() error
- func (g *GitLabForge) CommentOnDiff(ctx context.Context, owner, repo string, number int, body string) error
- func (g *GitLabForge) CommentOnIssue(ctx context.Context, owner, repo string, number int, body string) error
- func (g *GitLabForge) CreateDiff(ctx context.Context, owner, repo, title, body, head, base string) (*Diff, error)
- func (g *GitLabForge) CreateIssue(ctx context.Context, owner, repo, title, body string) (*Issue, error)
- func (g *GitLabForge) GetDiff(ctx context.Context, owner, repo string, number int) (*Diff, error)
- func (g *GitLabForge) GetIssue(ctx context.Context, owner, repo string, number int) (*Issue, error)
- func (g *GitLabForge) ListDiffComments(ctx context.Context, owner, repo string, number int) ([]Comment, error)
- func (g *GitLabForge) ListDiffs(ctx context.Context, owner, repo, state string) ([]Diff, error)
- func (g *GitLabForge) ListIssues(ctx context.Context, owner, repo, state string) ([]Issue, error)
- func (g *GitLabForge) Type() ForgeType
- type Issue
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented is returned by Forge methods that are not yet implemented.
Functions ¶
func FormatRemoteID ¶
FormatRemoteID returns a display ID like "github#42".
func ParseHostOwnerRepo ¶
ParseHostOwnerRepo extracts the host, owner, and repo name from a git remote URL. For self-hosted instances (e.g., gitlab.example.com), the host is needed so CLIs like glab can target the correct server.
func ParseOwnerRepo ¶
ParseOwnerRepo extracts the owner and repo name from a git remote URL. Supports both SSH (git@host:owner/repo.git) and HTTPS (https://host/owner/repo.git) formats. For nested groups (e.g., GitLab subgroups), owner includes the full path (group/subgroup).
Types ¶
type Comment ¶
type Comment struct {
ID int `json:"id"`
Author string `json:"author"`
Body string `json:"body"`
CreatedAt time.Time `json:"created_at"`
}
Comment represents a comment on an issue or diff.
type Diff ¶
type Diff struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
State string `json:"state"`
URL string `json:"url"`
Author string `json:"author,omitempty"`
Branch string `json:"branch"`
Base string `json:"base"`
CreatedAt time.Time `json:"created_at"`
}
Diff represents a remote pull request / merge request.
type Forge ¶
type Forge interface {
Type() ForgeType
// Issues
ListIssues(ctx context.Context, owner, repo, state string) ([]Issue, error)
GetIssue(ctx context.Context, owner, repo string, number int) (*Issue, error)
CreateIssue(ctx context.Context, owner, repo, title, body string) (*Issue, error)
CommentOnIssue(ctx context.Context, owner, repo string, number int, body string) error
// Diffs (pull requests / merge requests)
ListDiffs(ctx context.Context, owner, repo, state string) ([]Diff, error)
GetDiff(ctx context.Context, owner, repo string, number int) (*Diff, error)
CreateDiff(ctx context.Context, owner, repo, title, body, head, base string) (*Diff, error)
ListDiffComments(ctx context.Context, owner, repo string, number int) ([]Comment, error)
CommentOnDiff(ctx context.Context, owner, repo string, number int, body string) error
// Availability
CheckAvailable() error
CheckAuthenticated() error
}
Forge abstracts issue and diff operations on GitHub/GitLab.
func ForForgeType ¶
ForForgeType returns the Forge implementation for the given type. The returned forge targets the default SaaS host (github.com / gitlab.com). Use ResolveForge to get a host-aware forge for self-hosted instances.
func ResolveForge ¶
ResolveForge determines the forge, owner, and repo for a resolved repo config. The returned Forge is configured with the correct host from the repo URL, so self-hosted instances (e.g., gitlab.example.com) work automatically.
type GitHubForge ¶
type GitHubForge struct {
Host string // e.g., "github.com" or a GitHub Enterprise host
}
GitHubForge implements Forge using the gh CLI.
func (*GitHubForge) CheckAuthenticated ¶
func (g *GitHubForge) CheckAuthenticated() error
func (*GitHubForge) CheckAvailable ¶
func (g *GitHubForge) CheckAvailable() error
func (*GitHubForge) CommentOnDiff ¶
func (*GitHubForge) CommentOnIssue ¶
func (*GitHubForge) CreateDiff ¶
func (*GitHubForge) CreateIssue ¶
func (*GitHubForge) ListDiffComments ¶
func (*GitHubForge) ListIssues ¶
func (*GitHubForge) Type ¶
func (g *GitHubForge) Type() ForgeType
type GitLabForge ¶
type GitLabForge struct {
Host string // e.g., "gitlab.com" or "gitlab.example.com"
}
GitLabForge implements Forge using the glab CLI.
func (*GitLabForge) CheckAuthenticated ¶
func (g *GitLabForge) CheckAuthenticated() error
func (*GitLabForge) CheckAvailable ¶
func (g *GitLabForge) CheckAvailable() error
func (*GitLabForge) CommentOnDiff ¶
func (*GitLabForge) CommentOnIssue ¶
func (*GitLabForge) CreateDiff ¶
func (*GitLabForge) CreateIssue ¶
func (*GitLabForge) ListDiffComments ¶
func (*GitLabForge) ListIssues ¶
func (*GitLabForge) Type ¶
func (g *GitLabForge) Type() ForgeType
type Issue ¶
type Issue struct {
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
State string `json:"state"`
URL string `json:"url"`
Labels []string `json:"labels,omitempty"`
Author string `json:"author,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Issue represents a remote issue/ticket.