Documentation
¶
Overview ¶
Package jujutsu provides jj (Jujutsu) VCS operations for agent-deck. It mirrors the internal/git package pattern with package-level functions that execute jj CLI commands.
Index ¶
- func AbortMerge(repoDir string) error
- func BookmarkExists(repoDir, name string) (bool, error)
- func CreateWorkspaceAtRevision(repoDir, workspacePath, branchName, revision string) error
- func GetMainWorktreePath(dir string) (string, error)
- func GetRepoRoot(dir string) (string, error)
- func GetWorktreeBaseRoot(dir string) (string, error)
- func IsDefaultWorkspace(dir string) (bool, error)
- func IsJJRepo(dir string) bool
- func IsWorktree(dir string) bool
- func MaterializeWipFromParent(parentDir, workspacePath string, includeIgnored bool) error
- func SupportsGitignoredCopy(dir string) bool
- func WorkingCopyParentRevision(dir string) (string, error)
- func WorkingCopyRevision(dir string) (string, error)
- type JJBackend
- func (b *JJBackend) BranchExists(branchName string) bool
- func (b *JJBackend) CheckoutBranch(branchName string) error
- func (b *JJBackend) CreateWorktree(workspacePath, branchName string) error
- func (b *JJBackend) DeleteBranch(branchName string, force bool) error
- func (b *JJBackend) GetCurrentBranch() (string, error)
- func (b *JJBackend) GetDefaultBranch() (string, error)
- func (b *JJBackend) GetWorktreeForBranch(branchName string) (string, error)
- func (b *JJBackend) HasUncommittedChanges() (bool, error)
- func (b *JJBackend) ListWorktrees() ([]vcs.Worktree, error)
- func (b *JJBackend) MergeBranch(branchName string) error
- func (b *JJBackend) PruneWorktrees() error
- func (b *JJBackend) RemoveWorktree(workspacePath string, force bool) error
- func (b *JJBackend) RepoDir() string
- func (g *JJBackend) Type() vcs.Type
- func (b *JJBackend) WorktreePath(opts vcs.WorktreePathOptions) string
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbortMerge ¶
AbortMerge undoes the last operation (equivalent to aborting a merge).
func BookmarkExists ¶ added in v1.9.51
BookmarkExists reports whether a jj bookmark (branch) named name exists in the repo. The name is passed with jj's "exact:" string-pattern prefix because a bare positional name is matched as a GLOB by default — so a name containing a glob metacharacter (or one that is a glob-prefix of a real bookmark) would otherwise report a false-positive collision. (jj 0.42.0 rejects the --name flag entirely; the pattern must be positional.)
func CreateWorkspaceAtRevision ¶ added in v1.9.51
CreateWorkspaceAtRevision creates a new jj workspace at workspacePath whose working copy is anchored at revision (the parent session's committed point), then creates branchName as a bookmark on the new workspace's @. Existing bookmarks are refused because with-state forks must create a fresh destination, matching the git path's collision semantics.
This is the jj equivalent of git.CreateWorktreeAtStartPoint: it differs from the plain CreateWorktree only by pinning the start revision, which is what lets a subsequent MaterializeWipFromParent reproduce the parent's WIP as uncommitted changes rather than as an extra ancestor commit.
func GetMainWorktreePath ¶
GetMainWorktreePath returns the path to the default workspace.
func GetRepoRoot ¶
GetRepoRoot returns the root directory of the jj repository.
func GetWorktreeBaseRoot ¶
GetWorktreeBaseRoot returns the default workspace path (equivalent to main worktree in git).
func IsDefaultWorkspace ¶
IsDefaultWorkspace returns true if the given directory is the default workspace.
func IsJJRepo ¶
IsJJRepo checks if the given directory is inside a jj repository by running `jj root`. Returns false if jj is not installed or the directory is not a jj repo.
func IsWorktree ¶
IsWorktree checks if the directory is a non-default jj workspace.
func MaterializeWipFromParent ¶ added in v1.9.51
MaterializeWipFromParent reproduces the parent workspace's uncommitted working-copy state inside workspacePath, which must be a freshly created jj workspace anchored at the parent's @- (see CreateWorkspaceAtRevision).
Because jj's working copy *is* a commit and untracked (non-ignored) files are auto-snapshotted into it, a single `jj restore --from <parent @>` carries both tracked edits and untracked files — no separate untracked-copy pass is needed (unlike git). Gitignored files are not part of @, so they are filesystem-copied only when includeIgnored is set.
Contract:
- parentDir is treated read-only (no commit/describe/squash); only a snapshot of its working copy is taken when resolving @.
- On a colocated jj repo (has .git), gitignored files are enumerated via git's exclude machinery from the parent workspace root. If git metadata is unavailable, ignored-file copy is a documented no-op.
func SupportsGitignoredCopy ¶ added in v1.9.51
SupportsGitignoredCopy reports whether copyGitignoredFromParent could actually enumerate and copy gitignored files for a fork rooted at dir — i.e. whether dir resolves to a git worktree root (a colocated jj repo). A pure jj repo (or a linked jj workspace) has no such root, so a with-ignored fork would silently carry nothing; callers use this to emit a notice instead.
func WorkingCopyParentRevision ¶ added in v1.9.51
WorkingCopyParentRevision returns the commit id of @- — the committed parent of the working-copy commit. This is the anchor a with-state fork workspace is created at, so that the materialized working copy reads as uncommitted changes on top of it (mirroring git's "fork at parent HEAD, lay WIP on top").
func WorkingCopyRevision ¶ added in v1.9.51
WorkingCopyRevision returns the commit id of the working-copy commit (@) of the workspace rooted at dir.
It intentionally does NOT pass --ignore-working-copy: jj only snapshots the on-disk working copy into @ when a normal command runs, so resolving with the flag would return a stale @ and silently drop the parent's most recent uncommitted edits — exactly the state a with-state fork must carry.
Types ¶
type JJBackend ¶
type JJBackend struct {
// contains filtered or unexported fields
}
func NewJJBackend ¶
func (*JJBackend) BranchExists ¶
BranchExists checks if a bookmark exists in the repository.
func (*JJBackend) CheckoutBranch ¶
CheckoutBranch moves the working copy to a new change based on the given bookmark.
func (*JJBackend) CreateWorktree ¶
CreateWorktree creates a new jj workspace at the given path.
func (*JJBackend) DeleteBranch ¶
DeleteBranch deletes a bookmark.
func (*JJBackend) GetCurrentBranch ¶
GetCurrentBranch returns the first bookmark of the current working-copy change.
func (*JJBackend) GetDefaultBranch ¶
GetDefaultBranch returns the default branch name (checks for main/master bookmarks).
func (*JJBackend) GetWorktreeForBranch ¶
func (*JJBackend) HasUncommittedChanges ¶
HasUncommittedChanges checks if the working copy has uncommitted changes.
func (*JJBackend) ListWorktrees ¶
ListWorktrees returns all workspaces for the repository.
func (*JJBackend) MergeBranch ¶
MergeBranch creates a merge change combining the current change with the given bookmark.
func (*JJBackend) PruneWorktrees ¶
PruneWorktrees removes workspace entries whose directories no longer exist.
func (*JJBackend) RemoveWorktree ¶
RemoveWorktree forgets a workspace and optionally removes its directory.
func (*JJBackend) WorktreePath ¶
func (b *JJBackend) WorktreePath(opts vcs.WorktreePathOptions) string
WorktreePath generates a workspace path using the backend's repoDir. Delegates to the shared template logic in the git package (VCS-agnostic).