Documentation
¶
Index ¶
- func GenerateBookmarkName(description, shortChangeID string) string
- func MatchBookmarksToChanges(dag *ChangeDAG, bookmarks []BookmarkInfo) map[string][]*BookmarkInfo
- func ParseRemoteList(data []byte) map[string]string
- type BookmarkInfo
- type Change
- type ChangeBookmark
- type ChangeDAG
- type RemoteBookmarkState
- type Runner
- type SyncState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateBookmarkName ¶
GenerateBookmarkName creates a bookmark name following the jip convention: jip/<slugified-description>/<short-change-id>
func MatchBookmarksToChanges ¶
func MatchBookmarksToChanges(dag *ChangeDAG, bookmarks []BookmarkInfo) map[string][]*BookmarkInfo
MatchBookmarksToChanges returns a map from change ID to bookmarks that point to that change. Matching is done via commit ID (local target).
func ParseRemoteList ¶
ParseRemoteList parses the output of jj git remote list into a map of remote name → URL.
Types ¶
type BookmarkInfo ¶
type BookmarkInfo struct {
Name string // bookmark name
Target string // local commit ID ("" if remote-only or conflicted)
ChangeID string // local change ID ("" if remote-only or conflicted)
Present bool // has local target
Conflict bool // bookmark is in conflicted state (multiple targets)
Remotes map[string]RemoteBookmarkState // remote name → state
}
BookmarkInfo holds the full state of a named bookmark across local and remotes.
func ParseBookmarkList ¶
func ParseBookmarkList(data []byte) ([]BookmarkInfo, error)
ParseBookmarkList parses JSONL output from jj bookmark list --all-remotes into grouped BookmarkInfo entries. The internal "git" remote is filtered out.
func (*BookmarkInfo) SyncWith ¶
func (b *BookmarkInfo) SyncWith(remote string) SyncState
SyncWith returns the sync state of this bookmark relative to the given remote.
type Change ¶
type Change struct {
ChangeID string `json:"change_id"`
CommitID string `json:"commit_id"`
Description string `json:"description"`
ParentIDs []string `json:"parent_ids"`
Bookmarks []string `json:"bookmarks"`
}
Change represents a single jj change in a stack.
func ParseChanges ¶
ParseChanges parses JSONL output from jj log into a slice of Changes.
type ChangeBookmark ¶
type ChangeBookmark struct {
ChangeID string
Bookmark string
IsNew bool // bookmark was created (not pre-existing)
SyncState SyncState // sync state relative to the push remote
Conflict bool // bookmark has conflicting targets (true divergence)
Displaced bool // bookmark exists but no longer points to this change's commit
}
ChangeBookmark represents the bookmark assignment for a change.
func EnsureBookmarks ¶
func EnsureBookmarks( runner Runner, dag *ChangeDAG, bookmarks []BookmarkInfo, pushRemote string, shouldUseExisting func(changeID, bookmark string) bool, createNew bool, ) ([]ChangeBookmark, error)
EnsureBookmarks assigns a bookmark to each change in the DAG. For changes that already have a matching bookmark, it is reused (subject to the shouldUseExisting callback). For changes without a bookmark, a new one is created using the jip naming convention.
shouldUseExisting is called for each existing bookmark on a change and returns true if that bookmark should be used for the PR. This is the extension point for GitHub API integration (e.g., checking if a PR already exists for that branch). If nil, all existing bookmarks are accepted.
type ChangeDAG ¶
ChangeDAG is a connected DAG of changes. Changes are topologically sorted with roots (closest to base) first.
func BuildDAGs ¶
BuildDAGs splits a flat list of changes into connected components and returns each as a topologically sorted ChangeDAG. Parent IDs that don't appear in the input are ignored (they reference changes outside the resolved range, e.g. the base branch). The returned DAGs reference the original Change values in the input slice; the caller must not modify the input after calling BuildDAGs.
func ResolveStacks ¶
ResolveStacks resolves one or more revsets against a base branch and returns the changes organized into connected DAGs. Each DAG represents an independent stack of changes between the base and the given revsets.
func (*ChangeDAG) LeafChanges ¶
LeafChanges returns changes that have no children within this DAG (the "tips").
type RemoteBookmarkState ¶
type RemoteBookmarkState struct {
Target string // commit ID on remote
Tracked bool // whether this remote ref is tracked by jj
Ahead int // commits the remote is ahead of local
Behind int // commits the remote is behind local
}
RemoteBookmarkState holds a bookmark's state on a specific remote.
type Runner ¶
type Runner interface {
// Log runs jj log with the given revset and returns raw JSONL output.
Log(revset string) ([]byte, error)
// BookmarkList runs jj bookmark list --all-remotes and returns raw JSONL output.
BookmarkList() ([]byte, error)
// BookmarkSet creates or moves a bookmark to the given revision.
BookmarkSet(name, rev string) error
// GitRemoteList returns the output of jj git remote list.
GitRemoteList() ([]byte, error)
// GitFetch fetches from the given remote.
GitFetch(remote string) error
// GitPush pushes the given bookmarks. remote optionally specifies the
// push target (empty = jj default). allowNew permits new remote branches.
GitPush(bookmarks []string, allowNew bool, remote string) error
// Interdiff returns the diff between two revisions using jj interdiff --git.
Interdiff(from, to string) (string, error)
// Rebase rebases the given revsets onto the destination revision.
Rebase(revsets []string, destination string) error
}
Runner executes jj commands and returns their output.
type SyncState ¶
type SyncState int
SyncState describes how a local bookmark relates to a remote copy.
const ( SyncUnknown SyncState = iota SyncInSync // local and remote point to same commit SyncAhead // local has commits not on remote (remote is behind) SyncBehind // remote has commits not on local (remote is ahead) SyncDiverged // both sides have unique commits SyncLocalOnly // bookmark exists locally only SyncRemoteOnly // bookmark exists on remote only )