Documentation
¶
Overview ¶
Package jjclient wraps the `jj` CLI for local git operations, replacing the go-git library previously used. jj is a Git-compatible SCM that exposes all operations through its subcommand interface.
Index ¶
- func Exists(dir string) bool
- type Authenticator
- type BindOptions
- type BindResult
- type BoundRepo
- type Branch
- type CandidateHost
- type Change
- type CheckoutOptions
- type Commit
- type LogEntry
- type Remote
- type Repo
- func (r *Repo) AddRemote(name, url string) error
- func (r *Repo) Branches() ([]Branch, error)
- func (r *Repo) CheckoutPR(ctx context.Context, auth Authenticator, opts CheckoutOptions) error
- func (r *Repo) CommitObject(hash string) (*Commit, error)
- func (r *Repo) CurrentBranch() (string, error)
- func (r *Repo) Diff(from, to string) (string, error)
- func (r *Repo) Head() (*plumbingReference, error)
- func (r *Repo) HeadBranch() string
- func (r *Repo) Log(limit int, path string) ([]LogEntry, error)
- func (r *Repo) Remotes() ([]Remote, error)
- func (r *Repo) RemoveRemote(name string) error
- func (r *Repo) ResolveRev(rev string) (string, error)
- func (r *Repo) Root() string
- func (r *Repo) Status() ([]Change, error)
- type StatusCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Authenticator ¶
type Authenticator interface {
Name() string
}
Authenticator is the credential used for git transport operations.
type BindOptions ¶
BindOptions selects how a local repository is matched to a forge.
type BindResult ¶
type BindResult struct {
Bound BoundRepo
Auth Authenticator
}
BindResult is the return value of Bind.
func Bind ¶
func Bind(local *Repo, cfg operations.Config, opts BindOptions) (BindResult, error)
Bind matches the local repository's remotes against the configured forge instances and returns the resolved context.
type CandidateHost ¶
CandidateHost records that a remote URL pointed at a known forge host but did not yield a usable owner/name.
type Change ¶
type Change struct {
Path string
Staging StatusCode // index state
Worktree StatusCode // working tree state
Untracked bool
}
Change is one file's state in the worktree.
type CheckoutOptions ¶
type CheckoutOptions struct {
Spec operations.FetchSpec
Detach bool
Force bool
}
CheckoutOptions controls CheckoutPR.
type LogEntry ¶
type LogEntry struct {
Hash string
Short string
Author string
Email string
When time.Time
Subject string
}
LogEntry is one commit in the history listing.
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo is an opened local repository.
func Open ¶
Open opens the repository containing dir, walking up parent directories the way git does when run inside a subdirectory of a worktree.
func (*Repo) Branches ¶
Branches returns the repository's branches, local first then remote, sorted by name.
func (*Repo) CheckoutPR ¶
func (r *Repo) CheckoutPR(ctx context.Context, auth Authenticator, opts CheckoutOptions) error
CheckoutPR fetches a remote pull request head and checks it out locally.
func (*Repo) CommitObject ¶
CommitObject loads a commit by hash.
func (*Repo) CurrentBranch ¶
CurrentBranch returns the branch the worktree is on.
func (*Repo) HeadBranch ¶
HeadBranch returns the short name of the current branch, or "" when HEAD is detached.
func (*Repo) RemoveRemote ¶
RemoveRemote deletes a remote by name.
func (*Repo) ResolveRev ¶
ResolveRev resolves a revision to a commit hash.
type StatusCode ¶
type StatusCode byte
StatusCode mirrors git's two-letter porcelain status codes.
const ( StatusUnmodified StatusCode = ' ' StatusModified StatusCode = 'M' StatusAdded StatusCode = 'A' StatusDeleted StatusCode = 'D' StatusRenamed StatusCode = 'R' StatusCopied StatusCode = 'C' StatusUntracked StatusCode = '?' )