Documentation
¶
Index ¶
- func SubmoduleUpdateContext(ctx context.Context, s *git.Submodule, o *git.SubmoduleUpdateOptions) error
- func UpdateContext(ctx context.Context, s git.Submodules, o *git.SubmoduleUpdateOptions) error
- func UpdateSubmodules(r *git.Repository, o *git.SubmoduleUpdateOptions) error
- type CapabilityDetector
- type Fetcher
- type FetcherFactory
- type FetcherOption
- type Strategy
- type SubmoduleFetcher
- type SubmoduleUpdater
- type UpdaterOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SubmoduleUpdateContext ¶
func UpdateContext ¶
func UpdateContext(ctx context.Context, s git.Submodules, o *git.SubmoduleUpdateOptions) error
func UpdateSubmodules ¶
func UpdateSubmodules(r *git.Repository, o *git.SubmoduleUpdateOptions) error
Types ¶
type CapabilityDetector ¶
type CapabilityDetector interface {
// Detect queries the Git server at the given URL for its capabilities.
// Returns the server's advertised capabilities or an error if unreachable.
Detect(url string, auth transport.AuthMethod) (*capability.Capabilities, error)
// ChooseStrategy selects the optimal fetch strategy based on capabilities.
ChooseStrategy(caps *capability.Capabilities) capability.StrategyType
}
CapabilityDetectorInterface abstracts capability detection for testing. It allows injecting mock detectors to test Fetcher behavior without making actual network calls to Git servers.
type Fetcher ¶
type Fetcher struct {
// Auth contains credentials for authenticating with the remote server.
Auth transport.AuthMethod
// contains filtered or unexported fields
}
Fetcher orchestrates the fetching of a specific commit from a remote repository. It automatically detects server capabilities and selects the optimal strategy, or uses a forced strategy if configured (useful for testing or debugging).
func NewFetcher ¶
func NewFetcher(auth transport.AuthMethod, repo *git.Repository, opts ...FetcherOption) (*Fetcher, error)
type FetcherFactory ¶
type FetcherFactory func(auth transport.AuthMethod, repo *git.Repository) (SubmoduleFetcher, error)
type FetcherOption ¶
type FetcherOption func(*Fetcher)
FetcherOption configures a Fetcher instance. Use with NewFetcher to customize behavior.
func WithDetector ¶
func WithDetector(d CapabilityDetector) FetcherOption
WithDetector injects a custom capability detector. Primarily used for testing to avoid network calls.
func WithForcedStrategy ¶
func WithForcedStrategy(st capability.StrategyType) FetcherOption
WithForcedStrategy forces the use of a specific strategy, completely bypassing capability detection. Useful for tests where you want to verify the behavior of each strategy against the same server.
func WithRemoteName ¶
func WithRemoteName(name string) FetcherOption
func WithStrategies ¶
func WithStrategies(s map[capability.StrategyType]Strategy) FetcherOption
WithStrategies injects custom strategy implementations. Primarily used for testing to verify strategy selection.
type Strategy ¶
type Strategy interface {
Type() capability.StrategyType
// Execute fetches the specified commit from the remote.
Execute(ctx context.Context, r *git.Repository, commitHash plumbing.Hash) error
}
Strategy defines the interface for fetch strategies. Each strategy implements a different approach to fetching a specific commit from a remote Git server, optimized for different server capabilities.
type SubmoduleFetcher ¶
func DefaultFetcherFactory ¶
func DefaultFetcherFactory(auth transport.AuthMethod, repo *git.Repository) (SubmoduleFetcher, error)
type SubmoduleUpdater ¶
type SubmoduleUpdater struct {
// contains filtered or unexported fields
}
func NewSubmoduleUpdater ¶
func NewSubmoduleUpdater(opts ...UpdaterOption) *SubmoduleUpdater
func (*SubmoduleUpdater) UpdateContext ¶
func (u *SubmoduleUpdater) UpdateContext(ctx context.Context, s git.Submodules, o *git.SubmoduleUpdateOptions) error
func (*SubmoduleUpdater) UpdateSubmodules ¶
func (u *SubmoduleUpdater) UpdateSubmodules(r *git.Repository, o *git.SubmoduleUpdateOptions) error
type UpdaterOption ¶
type UpdaterOption func(*SubmoduleUpdater)
func WithFetcherFactory ¶
func WithFetcherFactory(factory FetcherFactory) UpdaterOption