client

package
v0.0.0-...-60a2622 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRawClient

func NewRawClient(repo string, opts ...options.Option) (*rawClient, error)

NewRawClient creates a new Git client for the specified repository URL. The client implements the Git Smart Protocol version 2 over HTTP/HTTPS transport. It supports both HTTP and HTTPS URLs and can be configured with various options for authentication, logging, and HTTP client customization.

Parameters:

  • repo: Repository URL (must be HTTP or HTTPS)
  • options: Configuration options for authentication, logging, etc.

Returns:

  • Client: Configured Git client interface
  • error: Error if URL is invalid or configuration fails

Example:

// Create client with basic authentication
client, err := client.NewHTTPClient(
    "https://github.com/user/repo",
    options.WithBasicAuth("username", "password"),
    options.WithLogger(logger),
)
if err != nil {
    return err
}

Types

type FetchOptions

type FetchOptions struct {
	NoCache      bool
	NoProgress   bool
	NoBlobFilter bool
	Want         []hash.Hash
	Done         bool // not sure why we need this one
	Deepen       int
	Shallow      bool

	// NoExtraObjects stops reading the packfile once all wanted objects have been found.
	// This can significantly improve performance when fetching specific objects from large repositories,
	// as it avoids downloading and processing unnecessary objects.
	NoExtraObjects bool
}

type LsRefsOptions

type LsRefsOptions struct {
	Prefix string
}

type RawClient

type RawClient interface {
	IsAuthorized(ctx context.Context) (bool, error)
	SmartInfo(ctx context.Context, service string) error
	UploadPack(ctx context.Context, data io.Reader) (io.ReadCloser, error)
	ReceivePack(ctx context.Context, data io.Reader) error
	Fetch(ctx context.Context, opts FetchOptions) (map[string]*protocol.PackfileObject, error)
	LsRefs(ctx context.Context, opts LsRefsOptions) ([]protocol.RefLine, error)
}

RawClient is a client that can be used to make raw Git protocol requests. It is used to implement the Git Smart Protocol version 2 over HTTP/HTTPS transport.

Jump to

Keyboard shortcuts

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