Documentation
¶
Index ¶
- Variables
- func AheadBehind(ctx context.Context, dir, ref string) (ahead, behind int, err error)
- func Checkout(ctx context.Context, dir, branch string, create bool) error
- func CommitAll(ctx context.Context, dir, message string) (string, error)
- func CurrentBranch(ctx context.Context, dir string) (string, error)
- func Fetch(ctx context.Context, dir string) error
- func IsMerged(ctx context.Context, dir, ref string) (bool, error)
- func MainBranch(ctx context.Context, dir string) string
- func MainBranchShort(ctx context.Context, dir string) string
- func OperationState(ctx context.Context, dir string) string
- func Pull(ctx context.Context, dir string) (string, error)
- func Push(ctx context.Context, dir string) (string, error)
- func RemoteURL(ctx context.Context, dir string) (string, error)
- type BranchList
- type Change
- type Commit
- type Error
- type FileChange
- type FileView
- type LineCount
- type PullRequest
- type Status
Constants ¶
This section is empty.
Variables ¶
var ErrNoPullRequest = errors.New("no pull request found for branch")
ErrNoPullRequest reports that the current branch has no hosted pull request (GitHub PR or GitLab MR) yet.
Functions ¶
func AheadBehind ¶
AheadBehind counts commits in ref but not in HEAD (behind) and in HEAD but not in ref (ahead), so callers can show how a branch relates to a remote main line instead of its upstream.
func Checkout ¶
Checkout switches the workspace to branch, creating it first when create is true. Remote-only names (origin/...) create a local tracking branch.
func CommitAll ¶
Commit stages every change (tracked, staged, and untracked) and creates a commit with message, so a subsequent push always has something to upload.
func CurrentBranch ¶
CurrentBranch returns the checked-out branch name, or "HEAD" when detached. symbolic-ref works even on an unborn HEAD (a repository without commits).
func Fetch ¶
Fetch downloads the latest refs from origin so panel comparisons against origin/main reflect what is actually on the remote. It never touches the working tree, so it is safe during rebases and merges.
func IsMerged ¶
IsMerged reports whether HEAD is an ancestor of ref, i.e. every commit on the current branch is already reachable from the main line.
func MainBranch ¶
MainBranch returns the remote ref of the repository's main line (origin/main, falling back to origin/master), or "" when the remote has neither.
func MainBranchShort ¶
MainBranchShort returns the short branch name of the repository's main line ("main" or "master"), or "" when the remote has neither.
func OperationState ¶
OperationState reports an in-progress git operation by inspecting the per-worktree git directory, or "" when the workspace is idle.
Types ¶
type BranchList ¶
BranchList separates local and remote branch names for one workspace.
type Change ¶
type Change struct {
Path string
Status string
Staged bool
RenameFrom string
Added int
Deleted int
}
Change is one working-tree change of a workspace.
type Commit ¶
type Commit struct {
Hash string
Short string
Subject string
Author string
Email string
Time time.Time
Files []FileChange
}
Commit is one entry of a workspace's commit history.
type Error ¶
Error carries the trimmed command output so the UI can show why an operation failed instead of a bare exit status.
type FileChange ¶
FileChange is one file touched by a commit, as reported by --name-status, with added/deleted line counts merged from --numstat.
type FileView ¶
FileView is one file's full content and its unified diff, both keyed to the same version: the working tree, the index, or a specific commit.
func Show ¶
Show returns the full content of path at the selected version together with its unified diff. When commit is non-empty both are keyed to that commit; staged selects the index; otherwise the working tree is shown. Untracked files have no reference version, so the whole file is shown as new content. Deleted files report an empty content with their diff.
type PullRequest ¶
type PullRequest struct {
Number int
Title string
Body string
State string
Draft bool
URL string
Author string
Base string
Head string
}
PullRequest is a hosted pull request for one branch, backed by either the GitHub CLI or the GitLab CLI depending on the origin remote.
func CreatePullRequest ¶
func CreatePullRequest(ctx context.Context, dir, title, body string) (*PullRequest, error)
CreatePullRequest pushes the current branch when needed and opens a pull request against the repository's main branch, returning the created request.
func PullRequestForBranch ¶
func PullRequestForBranch(ctx context.Context, dir string) (*PullRequest, error)
PullRequestForBranch returns the pull request whose head is the current branch, or (nil, ErrNoPullRequest) when none exists yet.