worktrees

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package worktrees implements `sf worktrees` — a read-only, cross-project view of git-worktree dev forks under a configured parent directory (see DefaultWww). For each repo it lists linked worktrees; where a repo ships dev/worktree.sh it enriches them with that script's `ls --json` (stack state, health, ports — the single source of truth for the per-project scheme). This tool never mutates: create/remove forks via the project's own dev/worktree.sh.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultWww

func DefaultWww() string

DefaultWww is the parent dir sf worktrees scans when neither --www nor Options.Www is set: the SOFIA_WWW env var when present, else the conventional /www directory when it actually exists on this machine (many dev setups symlink it to a shared checkout root — but that's a convention, not something every install has), else the current working directory. No single absolute path is universal, so unlike a hardcoded "/www" this never points somewhere that doesn't exist without the caller opting in.

func NewCommand

func NewCommand() *cobra.Command

NewCommand returns the `worktrees` Cobra command (`sf worktrees`).

func Run

func Run(opts Options, w io.Writer) error

Run collects the cross-project fork view, renders it, and logs the call.

Types

type Fork

type Fork struct {
	Project  string `json:"project"`        // repo name (basename of /www/<project>)
	Slug     string `json:"slug,omitempty"` // fork id from dev/worktree.sh; empty for plain worktrees
	Branch   string `json:"branch"`
	Dir      string `json:"dir"`
	Running  *bool  `json:"running,omitempty"`
	Health   string `json:"health,omitempty"`
	Dirty    bool   `json:"dirty"`
	Ahead    *int   `json:"ahead,omitempty"`
	URL      string `json:"url,omitempty"`
	FrontURL string `json:"front_url,omitempty"` // front-end (vite) URL, where the scheme provides one
	Age      string `json:"age,omitempty"`
}

Fork is one linked worktree, optionally enriched with dev-stack info when the owning repo ships dev/worktree.sh (otherwise stack fields stay empty/nil).

type Options

type Options struct {
	Www    string // parent dir to scan for repos; empty means DefaultWww()
	Format string
}

type Result

type Result struct {
	Www   string `json:"www"`
	Forks []Fork `json:"forks"`
}

func Collect

func Collect(opts Options) (*Result, error)

Collect scans <www>/* for git repos and gathers their linked worktrees.

Jump to

Keyboard shortcuts

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