projects

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package projects defines the local filesystem policy for git-ci projects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeSlug

func NormalizeSlug(value string) string

NormalizeSlug converts arbitrary text into lowercase ASCII slug components. Runs of unsupported characters become one hyphen, while leading and trailing separators are removed. An input with no ASCII letters or digits normalizes to the empty string and should be rejected or given a fallback by the caller.

func SuggestSlug

func SuggestSlug(path string) string

SuggestSlug deterministically derives a valid project slug from path's directory basename. It does not inspect existing projects, so suggestions do not change when another project with the same basename is discovered.

func ValidateSlug

func ValidateSlug(slug string) error

ValidateSlug reports whether slug contains only lowercase ASCII letters, digits, and single interior hyphens.

Types

type Project

type Project struct {
	Path          string `json:"path"`
	SuggestedSlug string `json:"suggestedSlug"`
}

Project is an immediately discovered Git repository. Path is canonical and SuggestedSlug is derived only from the directory basename.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry contains the canonical directories under which local projects may be selected. Its roots are immutable after construction.

func NewRegistry

func NewRegistry(configuredRoots []string) (*Registry, error)

NewRegistry builds a project registry from configured roots. Every root must already exist and be a directory. Roots are made absolute, symlinks are resolved, then equal and nested roots are removed. The remaining roots are sorted lexicographically so policy decisions do not depend on configuration order.

func (*Registry) Discover

func (r *Registry) Discover() ([]Project, error)

Discover finds Git repositories that are immediate children of configured roots. It does not walk descendants. Entries whose canonical target escapes a root are ignored. Results are sorted by canonical path, then suggested slug, and duplicate canonical paths are returned once.

func (*Registry) DiscoverProjects

func (r *Registry) DiscoverProjects() ([]Project, error)

DiscoverProjects is an explicit name for Discover.

func (*Registry) Roots

func (r *Registry) Roots() []string

Roots returns a copy of the registry's canonical, non-overlapping roots.

func (*Registry) ValidateLocalPath

func (r *Registry) ValidateLocalPath(selectedPath string) (string, error)

ValidateLocalPath validates an operator-selected local directory and returns its canonical path. Absolute paths must be beneath one configured root. Relative paths are evaluated beneath every canonical root in sorted order; exactly one existing canonical directory must be valid, otherwise an absent or ambiguous selection is rejected. The process working directory is never used to resolve a relative selection.

Jump to

Keyboard shortcuts

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