gsync

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStale

func IsStale(ctx context.Context, repo *git.Repository, ref *plumbing.Reference, age time.Duration, auth transport.AuthMethod, log *slog.Logger) bool

IsStale is a helper that wraps checkStaleness and handles logging. Returns true if the branch is definitely stale and should be skipped. Returns false if it's fresh OR if we couldn't determine (fail-safe).

func PruneItems

func PruneItems[T any](
	items []T,
	dryRun bool,
	log *slog.Logger,
	dryRunMsg string,
	prunedMsg string,
	errorMsg string,
	getName func(T) string,
	deleteFunc func(T) error,
) []string

PruneItems is a generic helper for pruning items (branches, tags, directories). It iterates over a list of obsolete items, checks for dry-run, logs actions, and executes the deletion logic.

func SanitizeName

func SanitizeName(name string) string

SanitizeName converts a Git ref name into a valid Puppet environment name. Puppet environments only allow [a-zA-Z0-9_]. Any character outside this set is replaced with an underscore.

Types

type Result

type Result struct {
	RepoName         string
	BranchesSynced   []string
	BranchesUpToDate []string
	BranchesFailed   []string
	TagsFetched      []string
	TagsUpToDate     []string
	TagsFailed       []string
	TagsObsolete     []string
	TagsPruned       []string
	BranchesObsolete []string
	BranchesPruned   []string
	BranchesStale    []string
	Checkout         string
	Err              error
}

Result holds the outcome of syncing a single repository.

type SyncOptions

type SyncOptions struct {
	Prune      bool
	PruneStale bool
	StaleAge   time.Duration
	DryRun     bool
}

SyncOptions controls optional sync behaviour.

type Syncer

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

Syncer performs git sync operations.

func New

func New(logger *slog.Logger) *Syncer

New creates a new Syncer with the given logger.

func (*Syncer) SyncAll

func (s *Syncer) SyncAll(ctx context.Context, cfg *config.Config, opts SyncOptions) []Result

SyncAll syncs all repositories in the config.

func (*Syncer) SyncRepo

func (s *Syncer) SyncRepo(ctx context.Context, repo *config.RepoConfig, opts SyncOptions) Result

SyncRepo syncs a single repository.

Jump to

Keyboard shortcuts

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