gitx

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package gitx contains provider-neutral Git smart-HTTP helpers.

Index

Constants

View Source
const MaxPktLinePayload = gitpktline.MaxPayloadSize

Variables

View Source
var (
	ErrFlush = errors.New("pkt-line flush")
	ErrDone  = errors.New("pkt-line input exhausted")
)

Functions

func AppendFlushPkt added in v0.2.0

func AppendFlushPkt(dst []byte) []byte

AppendFlushPkt appends one flush packet.

func AppendPktLine added in v0.2.0

func AppendPktLine(dst, payload []byte) ([]byte, error)

AppendPktLine appends one encoded pkt-line using go-git's canonical encoder.

func AppendPktLineString added in v0.2.0

func AppendPktLineString(dst []byte, payload string) ([]byte, error)

AppendPktLineString appends one string payload as a pkt-line.

func ComputeObjectHash added in v0.2.0

func ComputeObjectHash(objectType string, data []byte) (string, error)

ComputeObjectHash returns the canonical SHA-1 identifier for a Git object.

func ReadPktLine

func ReadPktLine(r io.Reader) ([]byte, error)

ReadPktLine reads one Git pkt-line payload.

Types

type PackBaseReader added in v0.2.0

type PackBaseReader func(context.Context, string) (PackObject, bool, error)

PackBaseReader resolves an object omitted from a thin pack.

type PackLimits added in v0.2.0

type PackLimits struct {
	MaxPackBytes     int64
	MaxObjects       uint32
	MaxObjectBytes   int64
	MaxInflatedBytes int64
}

PackLimits bounds all work performed while inspecting a SHA-1 packfile.

type PackObject added in v0.2.0

type PackObject struct {
	Type string
	Data []byte
	Hash string
}

PackObject is an extracted Git object.

func ExtractCommitAndTagObjects added in v0.2.0

func ExtractCommitAndTagObjects(
	ctx context.Context,
	pack []byte,
	limits PackLimits,
	readBase PackBaseReader,
) ([]PackObject, error)

ExtractCommitAndTagObjects validates a SHA-1 pack and returns its commit and tag objects. All go-git parsing is contained behind this bounded adapter.

type ReceivePackCommand

type ReceivePackCommand struct {
	Old  string
	New  string
	Ref  string
	Kind RefUpdateKind
}

ReceivePackCommand is one parsed receive-pack ref update command.

func ParseReceivePackCommands

func ParseReceivePackCommands(r io.Reader) ([]ReceivePackCommand, error)

ParseReceivePackCommands parses pkt-line receive-pack commands.

type RefUpdateKind

type RefUpdateKind string

RefUpdateKind is the policy-relevant class of a receive-pack command.

const (
	RefUpdateBranchCreate RefUpdateKind = "branch_create"
	RefUpdateBranchUpdate RefUpdateKind = "branch_update"
	RefUpdateRefDelete    RefUpdateKind = "ref_delete"
	RefUpdateTagCreate    RefUpdateKind = "tag_create"
	RefUpdateTagUpdate    RefUpdateKind = "tag_update"
	RefUpdateOther        RefUpdateKind = "other"
)

type Scanner added in v0.2.0

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

Scanner reads pkt-lines while retaining the trailing byte offset.

func NewScanner added in v0.2.0

func NewScanner(data []byte) *Scanner

NewScanner returns a scanner over an in-memory Git request.

func (*Scanner) Next added in v0.2.0

func (s *Scanner) Next() ([]byte, bool, error)

Next returns one payload and reports whether it is a flush packet.

func (*Scanner) Offset added in v0.2.0

func (s *Scanner) Offset() int64

Offset returns the number of input bytes consumed.

Jump to

Keyboard shortcuts

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