Help us shape the future of Go! Take the 2026 Go Developer Survey

project

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package project provides the core domain logic for managing multi-repository workspaces.

It is designed to cleanly separate the command-line interface (CLI) concerns from the underlying business logic of fetching, pulling, syncing, and setting up projects. By abstracting git operations behind the RepoClient interface, this package enables fast, deterministic, and reliable operations across multiple repositories concurrently.

Key concepts and features:

  • **Options Structs:** Each primary operation (Setup, Sync, Pull, Fetch, List) is configured via an `Options` struct. These structs contain pure data, cleanly decoupling the package from global configuration parsers like Viper.

  • **RepoClient Abstraction:** All external side effects (e.g., executing git clone, git fetch, checking for dirty working trees) are abstracted behind the `RepoClient` interface. If no client is explicitly provided in the options, a default OS-based client is used. This architecture enables high test coverage without hitting the network or creating real repositories on disk.

  • **Concurrency & Resilience:** Operations such as Sync, Pull, and Fetch are designed to run in parallel using an `errgroup`, capped at a safe concurrency limit. Interactive prompts and network timeouts are strictly disabled to prevent the CLI from hanging indefinitely on network or authentication issues.

  • **Safety First:** The default workflow respects the developer's working tree. Pull and Sync operations skip repositories that are "dirty" (contain uncommitted changes) to prevent merge conflicts or interrupted rebases mid-sync. Furthermore, operations pull the *current* branch rather than forcing checkouts to the default branch.

Example Usage:

opts := project.SyncOptions{
	DevPath:  "/path/to/dev",
	Projects: myConfiguredProjects,
	DryRun:   false,
}

// Executes a concurrent sync, pulling the latest code for all projects
// without uncommitted changes.
project.Sync(context.Background(), opts)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch added in v1.14.0

func Fetch(ctx context.Context, opts FetchOptions)

Fetch ensures project repositories are fetched.

func List added in v1.14.0

func List(opts ListOptions)

List displays project names, repository counts, and clone status.

func Pull added in v1.14.0

func Pull(ctx context.Context, opts PullOptions)

Pull updates from remote for all repositories in configured projects.

func Setup

func Setup(ctx context.Context, opts SetupOptions)

Setup ensures project directories exist and clones missing repositories.

func Sync added in v1.14.0

func Sync(ctx context.Context, opts SyncOptions)

Sync fetches and pulls all repositories in configured projects.

Types

type FetchOptions added in v1.14.0

type FetchOptions struct {
	DryRun        bool
	IsVerbose     bool
	ProjectFilter string
	DevPath       string
	Projects      []config.Project
	RepoClient    RepoClient
}

FetchOptions holds the configuration for fetching projects.

type ListOptions added in v1.14.0

type ListOptions struct {
	IsVerbose     bool
	ProjectFilter string
	DevPath       string
	Projects      []config.Project
	RepoClient    RepoClient
}

ListOptions holds the configuration for listing projects.

type PullOptions added in v1.14.0

type PullOptions struct {
	DryRun        bool
	IsVerbose     bool
	ProjectFilter string
	DevPath       string
	Projects      []config.Project
	RepoClient    RepoClient
}

PullOptions holds the configuration for pulling projects.

type RepoClient added in v1.14.0

type RepoClient interface {
	Clone(ctx context.Context, url, path string) error
	IsDirty(ctx context.Context, repoPath string) (bool, error)
	PullLatestCode(ctx context.Context, repoPath string) error
	FetchAllPrune(ctx context.Context, repoPath string) error
}

RepoClient defines the interface for repository operations to allow testing.

type SetupOptions

type SetupOptions struct {
	DryRun        bool
	IsVerbose     bool
	ProjectFilter string
	DevPath       string
	Projects      []config.Project
	RepoClient    RepoClient
}

SetupOptions holds the configuration for setting up projects.

type SetupStats

type SetupStats struct {
	TotalRepos   int
	ClonedCount  int
	SkippedCount int
	FailedCount  int
	FailedRepos  []string
}

SetupStats tracks the results of the setup operation.

type SyncOptions added in v1.14.0

type SyncOptions struct {
	DryRun        bool
	IsVerbose     bool
	ProjectFilter string
	DevPath       string
	Projects      []config.Project
	RepoClient    RepoClient
}

SyncOptions holds the configuration for syncing projects.

Jump to

Keyboard shortcuts

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