jjclient

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(dir string) bool

Exists reports whether dir is inside a jj workspace.

Types

type Authenticator

type Authenticator interface {
	Name() string
}

Authenticator is the credential used for git transport operations.

type BindOptions

type BindOptions struct {
	Instance string
	Repo     string
}

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 BoundRepo

type BoundRepo struct {
	Instance string
	Forge    string
	Owner    string
	Name     string
	Remote   string
}

BoundRepo identifies the forge repository a local repository tracks.

func (BoundRepo) FullName

func (b BoundRepo) FullName() string

FullName returns the owner/name form used by the forge APIs.

type Branch

type Branch struct {
	Name     string
	Short    string
	Commit   string
	IsHead   bool
	IsRemote bool
}

Branches lists local and remote-tracking branches.

type CandidateHost

type CandidateHost struct {
	Host  string
	Forge string
}

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.

func (Change) String

func (c Change) String() string

String renders the change the way git status --short does.

type CheckoutOptions

type CheckoutOptions struct {
	Spec   operations.FetchSpec
	Detach bool
	Force  bool
}

CheckoutOptions controls CheckoutPR.

type Commit

type Commit struct {
	Hash    string
	Author  string
	Email   string
	Subject string
}

Commit represents a parsed commit.

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 Remote

type Remote struct {
	Name string
	URLs []string
}

Remote describes a configured remote.

func (Remote) URL

func (r Remote) URL() string

URL returns the first configured URL, or "".

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo is an opened local repository.

func Open

func Open(dir string) (*Repo, error)

Open opens the repository containing dir, walking up parent directories the way git does when run inside a subdirectory of a worktree.

func (*Repo) AddRemote

func (r *Repo) AddRemote(name, url string) error

AddRemote registers a new remote pointing at url.

func (*Repo) Branches

func (r *Repo) Branches() ([]Branch, error)

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

func (r *Repo) CommitObject(hash string) (*Commit, error)

CommitObject loads a commit by hash.

func (*Repo) CurrentBranch

func (r *Repo) CurrentBranch() (string, error)

CurrentBranch returns the branch the worktree is on.

func (*Repo) Diff

func (r *Repo) Diff(from, to string) (string, error)

Diff renders the unified diff between two revisions.

func (*Repo) Head

func (r *Repo) Head() (*plumbingReference, error)

Head returns the current HEAD reference.

func (*Repo) HeadBranch

func (r *Repo) HeadBranch() string

HeadBranch returns the short name of the current branch, or "" when HEAD is detached.

func (*Repo) Log

func (r *Repo) Log(limit int, path string) ([]LogEntry, error)

Log returns up to limit commits reachable from HEAD, newest first.

func (*Repo) Remotes

func (r *Repo) Remotes() ([]Remote, error)

Remotes lists the repository's configured remotes via `jj remote list`.

func (*Repo) RemoveRemote

func (r *Repo) RemoveRemote(name string) error

RemoveRemote deletes a remote by name.

func (*Repo) ResolveRev

func (r *Repo) ResolveRev(rev string) (string, error)

ResolveRev resolves a revision to a commit hash.

func (*Repo) Root

func (r *Repo) Root() string

Root returns the repository root path.

func (*Repo) Status

func (r *Repo) Status() ([]Change, error)

Status returns the worktree status relative to HEAD.

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 = '?'
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL