Documentation
¶
Index ¶
- func CurrentBranch(nfo *Info) (string, error)
- func DefaultBranchBitbucket(ctx context.Context, bb *bitbucket.Client, nfo *Info) (string, error)
- func DefaultBranchGitHub(ctx context.Context, gh *githublib.Client, nfo *Info) (string, error)
- func DefaultBranchGitLab(ctx context.Context, gl *gitlab.Client, nfo *Info) (string, error)
- func FindRepoRoot(path string) (root, gitdir, wt string, err error)
- func LastCommitTitle(nfo *Info) (string, error)
- func LocalBranchDelete(repo *git.Repository, name string, force bool) error
- func LocalBranchRename(repo *git.Repository, oldName, newName string) error
- func ParallelMap[T, U any](iter iter.Seq[T], f func(T) (U, error)) ([]U, error)
- func ParallelMapValues[T, U any](elems []T, f func(T) (U, error)) ([]U, error)
- func ResolvePRTitle(inTitle string, nfo *Info) (string, error)
- type BranchDeleteOptions
- type BranchInfo
- type BranchListOptions
- type BranchRenameOptions
- type CreateOptions
- type Info
- type ListOptions
- type LocalRepo
- type MergeOptions
- type PRComment
- type PRDetails
- type Provider
- func (p Provider) BranchDelete(ctx context.Context, nfo *Info, name string, opts BranchDeleteOptions) error
- func (p Provider) BranchListRemote(ctx context.Context, nfo *Info, opts BranchListOptions) ([]BranchInfo, error)
- func (p Provider) BranchRename(ctx context.Context, nfo *Info, oldName, newName string, ...) error
- func (p Provider) BranchWebURL(nfo *Info, branch string) (string, error)
- func (p Provider) PrClose(ctx context.Context, nfo *Info, number int) (*PRDetails, error)
- func (p Provider) PrComments(ctx context.Context, nfo *Info, number int) ([]PRComment, error)
- func (p Provider) PrCreate(ctx context.Context, nfo *Info, in CreateOptions) (*PRDetails, error)
- func (p Provider) PrList(ctx context.Context, nfo *Info, opts ListOptions) ([]PullRequest, error)
- func (p Provider) PrMerge(ctx context.Context, nfo *Info, number int, opts MergeOptions) (*PRDetails, error)
- func (p Provider) PrView(ctx context.Context, nfo *Info, number int) (*PRDetails, error)
- func (p Provider) String() string
- type PullRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentBranch ¶
CurrentBranch returns the current branch name of the repository detected from Info.
func DefaultBranchBitbucket ¶
DefaultBranchBitbucket returns the main branch (default) for a Bitbucket Cloud repository.
func DefaultBranchGitHub ¶
DefaultBranchGitHub returns the default branch for a GitHub repository.
func DefaultBranchGitLab ¶
DefaultBranchGitLab returns the default branch for a GitLab project.
func FindRepoRoot ¶
FindRepoRoot returns the absolute path to the root of the repository and git related dir locations: - wt: if "" => the git checkout at root is not a worktree or path to git worktree folder - gitdir: absolute path to root of git repository dir ($root/.git if not in worktree)
func LastCommitTitle ¶
LastCommitTitle returns the first line of the last commit message on HEAD.
func LocalBranchDelete ¶
func LocalBranchDelete(repo *git.Repository, name string, force bool) error
LocalBranchDelete deletes a local branch reference. It refuses to delete the currently checked out branch. The force flag is currently ignored for safety (git also refuses deletion of the current branch).
func LocalBranchRename ¶
func LocalBranchRename(repo *git.Repository, oldName, newName string) error
LocalBranchRename renames a local branch reference and updates HEAD if needed.
func ParallelMapValues ¶
Types ¶
type BranchDeleteOptions ¶
type BranchDeleteOptions struct {
Force bool
}
type BranchListOptions ¶
type BranchRenameOptions ¶
type BranchRenameOptions struct {
NoUpdatePRs bool
}
type CreateOptions ¶
type CreateOptions struct {
Title string
Body string
Base string // target branch
Head string // source branch
Draft bool
// SquashByDefault indicates the PR/MR should default to squashing commits when merged
// (provider support varies; ignored where unsupported)
SquashByDefault bool
DeleteAfterMerge bool
}
CreateOptions controls PR/MR creation.
type Info ¶
type Info struct {
LocalRepo
Provider Provider // enum: github|gitlab|bitbucket|unknown
Variant string // cloud|self-hosted|unknown
Evidence string // method used (e.g. api_v4_version, headers, url-heuristic)
HTTPBase string // http(s) base used for probing, if any
Host string // e.g. github.com
Owner string // e.g. user or project
Repo string // repository name without .git
Remote string // remote name used (e.g. origin)
URL string // original remote URL used
Config *config.Config // user configuration (may be nil)
}
Info contains parsed repository and provider details inferred from git remotes.
func DetectFromRepo ¶
DetectFromRepo infers provider and repo info for an already detected local repository by inspecting remotes (preferring origin, then upstream, then first). It also performs light network probing (like the Python reference) to identify self-hosted services.
type ListOptions ¶
type ListOptions struct {
State string // open|closed|merged|all
Author string
Assignee string
Base string
Head string
Limit int
}
ListOptions are filters for PR list queries.
type LocalRepo ¶
type LocalRepo struct {
Root string // absolute repository root directory (worktree), respects -C
GitDir string // absolute path to /../.git dir (resolved .git file if inside worktree)
Worktree string // absolute path to /../.git/worktrees/<name>
GitRepo *git.Repository // handle to git repository instance or nil if not available
}
func FindLocalRepo ¶
type MergeOptions ¶
type MergeOptions struct {
Method string // merge|squash|rebase (provider support varies)
DeleteBranch bool
}
MergeOptions controls how a PR/MR is merged.
type PRComment ¶
type PRComment struct {
Author string `json:"author"`
Body string `json:"body"`
CreatedAt time.Time `json:"created_at"`
// Optional location for inline comments (when available)
Path string `json:"path,omitempty"`
Line int `json:"line,omitempty"`
URL string `json:"url,omitempty"`
}
PRComment represents a single review comment on a PR/MR.
type PRDetails ¶
type PRDetails struct {
Number int
Title string
Body string
Author string
State string
CreatedAt time.Time
UpdatedAt time.Time
Merged bool
Draft bool
Base string
Head string
URL string
}
PRDetails is a provider-agnostic view of a single PR/MR.
type Provider ¶
type Provider int
Provider represents a supported git hosting provider.
func (Provider) BranchDelete ¶
func (p Provider) BranchDelete(ctx context.Context, nfo *Info, name string, opts BranchDeleteOptions) error
BranchDelete deletes a remote branch across providers. It prevents deleting the default branch unless Force is true (where detectable).
func (Provider) BranchListRemote ¶
func (p Provider) BranchListRemote(ctx context.Context, nfo *Info, opts BranchListOptions) ([]BranchInfo, error)
BranchListRemote lists remote branches using provider APIs.
func (Provider) BranchRename ¶
func (p Provider) BranchRename(ctx context.Context, nfo *Info, oldName, newName string, opts BranchRenameOptions) error
BranchRename renames a remote branch across providers.
func (Provider) BranchWebURL ¶
BranchWebURL constructs a web URL for viewing a branch for the given repo info. It supports GitHub, GitLab, and Bitbucket Cloud. For self-hosted instances, it uses Info.HTTPBase if available; otherwise it falls back to https://<host>.
func (Provider) PrComments ¶
PrComments lists review comments for a PR number. For now only GitLab is supported.
func (Provider) PrList ¶
func (p Provider) PrList(ctx context.Context, nfo *Info, opts ListOptions) ([]PullRequest, error)
PrList lists pull/merge requests for a detected provider.
func (Provider) PrMerge ¶
func (p Provider) PrMerge(ctx context.Context, nfo *Info, number int, opts MergeOptions) (*PRDetails, error)
PrMerge merges a pull/merge request across supported providers.