resolve

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package resolve provides target resolution for worktree commands.

Many wt commands operate on specific worktrees or repos. This package handles looking up targets and validating they still exist on disk.

Targeting Methods

Commands support several targeting methods:

  • -r/--repository: Target by repository name
  • -l/--label: Target repos by label
  • --branch: Target specific worktree by branch name
  • -i/--interactive: Interactive selection

Usage Pattern

Commands that use target resolution follow this pattern:

  • Repo targeting: wt exec -r myrepo, wt cd -r myrepo
  • Label targeting: wt exec -l backend, wt hook -l frontend
  • Branch targeting: wt prune --branch feature, wt hook --branch feat
  • Context-aware: wt note, wt pr create (default to current repo/branch)

The -r/--repository and -l/--label flags are used consistently across commands for repo-based targeting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Target

type Target struct {
	Branch   string
	MainRepo string
	Path     string
}

Target represents a resolved worktree target

func ByRepoName added in v0.7.0

func ByRepoName(ctx context.Context, repoName, repoDir string) (*Target, error)

ByRepoName resolves a target by repository name. Returns target with current branch of that repo.

func ByRepoOrPath added in v0.13.0

func ByRepoOrPath(ctx context.Context, repository, worktreeDir, repoDir, workDir string) (*Target, error)

ByRepoOrPath resolves target with 2 modes: 1. repository != "": by repository name (uses repoDir, falls back to worktreeDir) 2. repository == "": from current path (worktree or main repo)

func FromCurrentWorktree added in v0.7.0

func FromCurrentWorktree(ctx context.Context) (*Target, error)

FromCurrentWorktree resolves target from the current working directory. Returns error if not inside a git worktree.

func FromCurrentWorktreeOrRepo added in v0.7.0

func FromCurrentWorktreeOrRepo(ctx context.Context) (*Target, error)

FromCurrentWorktreeOrRepo resolves target from the current working directory. Works in both worktrees and main repos.

func FromWorktreeOrRepoPath added in v0.8.0

func FromWorktreeOrRepoPath(ctx context.Context, path string) (*Target, error)

FromWorktreeOrRepoPath resolves target from the given path. Works in both worktrees and main repos.

func FromWorktreePath added in v0.8.0

func FromWorktreePath(ctx context.Context, path string) (*Target, error)

FromWorktreePath resolves target from the given path. Returns error if the path is not inside a git worktree.

Jump to

Keyboard shortcuts

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