workspace

package
v4.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRootNotFound is an error when the root is not found
	ErrRootNotFound = errors.New("repository root not found")

	// ErrRootAlreadyExists is an error when the root already exists
	ErrRootAlreadyExists = errors.New("repository root already exists")

	// ErrNoPrimaryRoot is an error when no primary root is configured
	ErrNoPrimaryRoot = errors.New("no primary repository root configured")
)
View Source
var ErrNotMatched = errors.New("repository not matched for a layout")

Functions

This section is empty.

Types

type FinderService

type FinderService interface {
	// FindByReference retrieves a repository by its reference
	FindByReference(ctx context.Context, ws WorkspaceService, reference repository.Reference) (*repository.Location, error)

	// FindByPath retrieves a repository by its path
	FindByPath(ctx context.Context, ws WorkspaceService, path string) (*repository.Location, error)

	// ListAllRepository retrieves a list of repositories under all roots
	ListAllRepository(context.Context, WorkspaceService, ListOptions) iter.Seq2[*repository.Location, error]

	// ListRepositoryInRoot retrieves a list of repositories under a root
	ListRepositoryInRoot(context.Context, LayoutService, ListOptions) iter.Seq2[*repository.Location, error]
}

FinderService is a service for searching repositories

type LayoutService

type LayoutService interface {
	// GetRoot returns the root of the layout
	GetRoot() string

	// Match returns the repository reference corresponding the given path
	// If the path does not match the layout, it returns the error `repository.ErrNotMatched`
	// Example:
	// Match("github.com/owner/repo") returns "github.com/owner/repo"
	// Match("github.com/owner/repo/foo") returns "github.com/owner/repo"
	Match(path string) (*repository.Reference, error)

	// ExactMatch returns the repository reference corresponding exactly to the given path
	// If the path does not match the layout, it returns the error `repository.ErrNotMatched`
	// Example:
	// ExactMatch("github.com/owner/repo") returns "github.com/owner/repo"
	// ExactMatch("github.com/owner/repo/foo") returns `repository.ErrNotMatched`
	ExactMatch(path string) (*repository.Reference, error)

	// PathFor returns the path corresponding to the given reference
	PathFor(ref repository.Reference) string

	// CreateRepositoryFolder creates a new folder for the repository
	CreateRepositoryFolder(reference repository.Reference) (string, error)

	// DeleteRepository deletes the repository
	DeleteRepository(reference repository.Reference) error
}

LayoutService defines the layout structure of a repository under a root

type ListOptions

type ListOptions struct {
	// Limit is the maximum number of repositories to return
	// If 0, all repositories will be returned
	Limit int
	// Patterns to match repository paths
	// If empty, all repositories will be returned
	Patterns []string
}

ListOptions is the options for repository search

type Root

type Root = string

type WorkspaceService

type WorkspaceService interface {
	// GetRoots returns all registered roots
	GetRoots() []Root

	// GetPrimaryRoot returns the primary root
	GetPrimaryRoot() Root

	// GetLayoutFor returns a Layout for the root
	GetLayoutFor(root Root) LayoutService

	// GetPrimaryLayout returns a Layout for the primary root
	GetPrimaryLayout() LayoutService

	// SetPrimaryRoot sets the primary root
	SetPrimaryRoot(Root) error

	// AddRoot adds a new root
	AddRoot(root Root, asPrimary bool) error

	// RemoveRoot removes a root
	RemoveRoot(root Root) error

	store.Content
}

WorkspaceService manages a collection of repository roots

Jump to

Keyboard shortcuts

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