Documentation
¶
Overview ¶
Package forge provides an abstraction over git hosting services (GitHub, GitLab).
Index ¶
- type CreatePRParams
- type CreatePRResult
- type Forge
- type GitHub
- func (g *GitHub) Check() error
- func (g *GitHub) CloneRepo(repoSpec, destPath string) (string, error)
- func (g *GitHub) CreatePR(repoURL string, params CreatePRParams) (*CreatePRResult, error)
- func (g *GitHub) FormatState(state string) string
- func (g *GitHub) GetPRBranch(repoURL string, number int) (string, error)
- func (g *GitHub) GetPRForBranch(repoURL, branch string) (*PRInfo, error)
- func (g *GitHub) MergePR(repoURL string, number int, strategy string) error
- func (g *GitHub) Name() string
- func (g *GitHub) ViewPR(repoURL string, number int, web bool) error
- type GitLab
- func (g *GitLab) Check() error
- func (g *GitLab) CloneRepo(repoSpec, destPath string) (string, error)
- func (g *GitLab) CreatePR(repoURL string, params CreatePRParams) (*CreatePRResult, error)
- func (g *GitLab) FormatState(state string) string
- func (g *GitLab) GetPRBranch(repoURL string, number int) (string, error)
- func (g *GitLab) GetPRForBranch(repoURL, branch string) (*PRInfo, error)
- func (g *GitLab) MergePR(repoURL string, number int, strategy string) error
- func (g *GitLab) Name() string
- func (g *GitLab) ViewPR(repoURL string, number int, web bool) error
- type PRInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreatePRParams ¶ added in v0.3.0
type CreatePRParams struct {
Title string
Body string
Base string // base branch (empty = repo default)
Head string // head/source branch
Draft bool
}
CreatePRParams contains parameters for creating a PR/MR
type CreatePRResult ¶ added in v0.3.0
CreatePRResult contains the result of creating a PR/MR
type Forge ¶
type Forge interface {
// Name returns the forge name ("github" or "gitlab")
Name() string
// Check verifies the CLI is installed and authenticated
Check() error
// GetPRForBranch fetches PR info for a branch
GetPRForBranch(repoURL, branch string) (*PRInfo, error)
// GetPRBranch gets the source branch name for a PR number
GetPRBranch(repoURL string, number int) (string, error)
// CloneRepo clones a repository to destPath, returns the full clone path
CloneRepo(repoSpec, destPath string) (string, error)
// CreatePR creates a new PR/MR
CreatePR(repoURL string, params CreatePRParams) (*CreatePRResult, error)
// MergePR merges a PR by number with the given strategy
// strategy: "squash", "rebase", or "merge"
// Returns error if repo doesn't allow the requested merge strategy
MergePR(repoURL string, number int, strategy string) error
// ViewPR shows PR details or opens in browser
// If web is true, opens in browser; otherwise shows details in terminal
ViewPR(repoURL string, number int, web bool) error
// FormatState returns a human-readable PR state
FormatState(state string) string
}
Forge represents a git hosting service (GitHub, GitLab, etc.)
func ByName ¶
ByName returns a Forge implementation by name. Supported names: "github", "gitlab" Returns GitHub as default for unknown names.
type GitHub ¶
type GitHub struct{}
GitHub implements Forge for GitHub repositories using the gh CLI.
func (*GitHub) CreatePR ¶ added in v0.3.0
func (g *GitHub) CreatePR(repoURL string, params CreatePRParams) (*CreatePRResult, error)
CreatePR creates a new PR using gh CLI
func (*GitHub) FormatState ¶
FormatState returns a human-readable PR state
func (*GitHub) GetPRBranch ¶
GetPRBranch fetches the head branch name for a PR number using gh CLI
func (*GitHub) GetPRForBranch ¶
GetPRForBranch fetches PR info for a branch using gh CLI
type GitLab ¶
type GitLab struct{}
GitLab implements Forge for GitLab repositories using the glab CLI.
func (*GitLab) CreatePR ¶ added in v0.3.0
func (g *GitLab) CreatePR(repoURL string, params CreatePRParams) (*CreatePRResult, error)
CreatePR creates a new MR using glab CLI
func (*GitLab) FormatState ¶
FormatState returns a human-readable PR state
func (*GitLab) GetPRBranch ¶
GetPRBranch fetches the source branch name for a PR number using glab CLI
func (*GitLab) GetPRForBranch ¶
GetPRForBranch fetches PR info for a branch using glab CLI