git

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: EUPL-1.2 Imports: 9 Imported by: 0

Documentation

Overview

Package git provides utilities for git operations across multiple repositories.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNonFastForward

func IsNonFastForward(err error) bool

IsNonFastForward checks if an error is a non-fast-forward rejection.

func NewService

func NewService(opts ServiceOptions) func(*framework.Core) (any, error)

NewService creates a git service factory.

func Pull

func Pull(ctx context.Context, path string) error

Pull pulls changes for a single repository. Uses interactive mode to support SSH passphrase prompts.

func Push

func Push(ctx context.Context, path string) error

Push pushes commits for a single repository. Uses interactive mode to support SSH passphrase prompts.

Types

type GitError

type GitError struct {
	Err    error
	Stderr string
}

GitError wraps a git command error with stderr output.

func (*GitError) Error

func (e *GitError) Error() string

Error returns the git error message, preferring stderr output.

func (*GitError) Unwrap

func (e *GitError) Unwrap() error

Unwrap returns the underlying error for error chain inspection.

type PushResult

type PushResult struct {
	Name    string
	Path    string
	Success bool
	Error   error
}

PushResult represents the result of a push operation.

func PushMultiple

func PushMultiple(ctx context.Context, paths []string, names map[string]string) []PushResult

PushMultiple pushes multiple repositories sequentially. Sequential because SSH passphrase prompts need user interaction.

type QueryAheadRepos

type QueryAheadRepos struct{}

QueryAheadRepos requests repos with unpushed commits.

type QueryDirtyRepos

type QueryDirtyRepos struct{}

QueryDirtyRepos requests repos with uncommitted changes.

type QueryStatus

type QueryStatus struct {
	Paths []string
	Names map[string]string
}

QueryStatus requests git status for paths.

type RepoStatus

type RepoStatus struct {
	Name      string
	Path      string
	Modified  int
	Untracked int
	Staged    int
	Ahead     int
	Behind    int
	Branch    string
	Error     error
}

RepoStatus represents the git status of a single repository.

func Status

func Status(ctx context.Context, opts StatusOptions) []RepoStatus

Status checks git status for multiple repositories in parallel.

func (*RepoStatus) HasUnpulled

func (s *RepoStatus) HasUnpulled() bool

HasUnpulled returns true if there are commits to pull.

func (*RepoStatus) HasUnpushed

func (s *RepoStatus) HasUnpushed() bool

HasUnpushed returns true if there are commits to push.

func (*RepoStatus) IsDirty

func (s *RepoStatus) IsDirty() bool

IsDirty returns true if there are uncommitted changes.

type Service

type Service struct {
	*framework.ServiceRuntime[ServiceOptions]
	// contains filtered or unexported fields
}

Service provides git operations as a Core service.

func (*Service) AheadRepos

func (s *Service) AheadRepos() []RepoStatus

AheadRepos returns repos with unpushed commits.

func (*Service) DirtyRepos

func (s *Service) DirtyRepos() []RepoStatus

DirtyRepos returns repos with uncommitted changes.

func (*Service) OnStartup

func (s *Service) OnStartup(ctx context.Context) error

OnStartup registers query and task handlers.

func (*Service) Status

func (s *Service) Status() []RepoStatus

Status returns last status result.

type ServiceOptions

type ServiceOptions struct {
	WorkDir string
}

ServiceOptions for configuring the git service.

type StatusOptions

type StatusOptions struct {
	// Paths is a list of repo paths to check
	Paths []string
	// Names maps paths to display names
	Names map[string]string
}

StatusOptions configures the status check.

type TaskPull

type TaskPull struct {
	Path string
	Name string
}

TaskPull requests git pull for a path.

type TaskPush

type TaskPush struct {
	Path string
	Name string
}

TaskPush requests git push for a path.

type TaskPushMultiple

type TaskPushMultiple struct {
	Paths []string
	Names map[string]string
}

TaskPushMultiple requests git push for multiple paths.

Jump to

Keyboard shortcuts

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