push

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSizeOfObjects

func GetSizeOfObjects(note pushtypes.PushNote) (uint64, error)

GetSizeOfObjects returns the size of objects required to fulfil the push note.

func MakeReferenceUpdateRequestPack

func MakeReferenceUpdateRequestPack(note pushtypes.PushNote) (io.ReadSeeker, error)

MakeReferenceUpdateRequestPack creates a reference update request to send to git-receive-pack program.

Types

type BasicHandler

type BasicHandler struct {
	Repo       remotetypes.LocalRepo     // The target repository
	Server     core.RemoteServer         // The repository remote server
	OldState   remotetypes.RepoRefsState // The old state of the repo before the current push was written
	PushReader *Reader                   // The push reader for reading pushed git objects
	NoteID     string                    // The push note unique ID

	ChangeValidator validation.ChangeValidatorFunc      // Repository state change validator
	Reverter        plumbing.RevertFunc                 // Repository state reverser function
	MergeChecker    validation.MergeComplianceCheckFunc // Merge request checker function

	TxDetails            remotetypes.ReferenceTxDetails // Map of references to their transaction details
	ReferenceHandler     HandleReferenceFunc            // Pushed reference handler function
	AuthorizationHandler HandleAuthorizationFunc        // Authorization handler function
	PolicyChecker        policy.PolicyChecker           // Policy checker function
	// contains filtered or unexported fields
}

BasicHandler implements Handler. It provides handles all phases of a push operation.

func NewHandler

func NewHandler(
	repo remotetypes.LocalRepo,
	txDetails []*remotetypes.TxDetail,
	polEnforcer policy.EnforcerFunc,
	rMgr core.RemoteServer) *BasicHandler

NewHandler returns an instance of BasicHandler

func (*BasicHandler) DoAuth

func (h *BasicHandler) DoAuth(ur *packp.ReferenceUpdateRequest, targetRef string, ignorePostRefs bool) error

DoAuth implements Handler. It performs access-level checks.

func (*BasicHandler) EnsureReferencesHaveTxDetail

func (h *BasicHandler) EnsureReferencesHaveTxDetail() error

EnsureReferencesHaveTxDetail implements Handler. It ensures each references have a signed push transaction detail.

func (*BasicHandler) GetChange

func (h *BasicHandler) GetChange(ref string) (*remotetypes.ItemChange, error)

GetChange computes and returns the change made to the given reference

func (*BasicHandler) HandleAnnouncement

func (h *BasicHandler) HandleAnnouncement(cb func(errCount int))

HandleAnnouncement announces the repository name, pushed commit and tag objects. cb is called with the number of failed announcements.

func (*BasicHandler) HandleAuthorization

func (h *BasicHandler) HandleAuthorization(ur *packp.ReferenceUpdateRequest) error

HandleAuthorization implements Handler

func (*BasicHandler) HandleGCAndSizeCheck

func (h *BasicHandler) HandleGCAndSizeCheck() error

HandleRepoSize implements Handler. Performs garbage collection and repo size limit check.

func (*BasicHandler) HandlePushNote

func (h *BasicHandler) HandlePushNote(note types.PushNote) (err error)

HandlePushNote implements Handler by handing incoming push note

func (*BasicHandler) HandleRefMismatch

func (h *BasicHandler) HandleRefMismatch(note types.PushNote, ref string, netMismatch bool) (err error)

HandleRefMismatch handles cases where a reference in the push note differs from the hash of its corresponding local or network reference hash. We react by attempting resyncing the reference.

func (*BasicHandler) HandleReference

func (h *BasicHandler) HandleReference(ref string) (errs []error)

HandleReference implements Handler

func (*BasicHandler) HandleReferences

func (h *BasicHandler) HandleReferences() error

HandleReferences implements Handler. It processes pushed references.

func (*BasicHandler) HandleReversion

func (h *BasicHandler) HandleReversion() []error

HandleReversion reverts the pushed references back to their pre-push state. It will do nothing and return nil if already called successfully.

func (*BasicHandler) HandleStream

func (h *BasicHandler) HandleStream(
	packfile io.Reader,
	gitReceive io.WriteCloser,
	gitRcvCmd util.Cmd,
	pktEnc *pktline.Encoder,
) error

HandleStream implements Handler. It reads the packfile and pipes it to git.

func (*BasicHandler) HandleUpdate

func (h *BasicHandler) HandleUpdate(targetNote types.PushNote) (err error)

HandleUpdate implements Handler

func (*BasicHandler) WaitForPushTx added in v0.0.29

func (h *BasicHandler) WaitForPushTx() chan interface{}

WaitForPushTx waits for the final push transaction to be created and added to the mempool. It will return error if the tx was rejected. An error is returned if the tx was not successfully added to the pool after 15 minutes. On success, it returns the tx hash

type HandleAuthorizationFunc

type HandleAuthorizationFunc func(ur *packp.ReferenceUpdateRequest) error

HandleAuthorizationFunc describes a function for checking authorization to access a reference

type HandleReferenceFunc

type HandleReferenceFunc func(ref string) []error

HandleReferenceFunc describes a function for processing a reference

type MakeReferenceUpdateRequestPackFunc

type MakeReferenceUpdateRequestPackFunc func(tx pushtypes.PushNote) (io.ReadSeeker, error)

MakeReferenceUpdateRequestPackFunc describes a function for create git packfile from a push note and a target repository

type ObjectObserver

type ObjectObserver struct {
	Objects     []*PackObject
	MaxBlobSize int64
	// contains filtered or unexported fields
}

ObjectObserver implements packfile.Observer. It allows us to read objects of a packfile and also set limitation of blob size.

func (*ObjectObserver) OnFooter

func (o *ObjectObserver) OnFooter(plumbing.Hash) error

func (*ObjectObserver) OnHeader

func (o *ObjectObserver) OnHeader(uint32) error

func (*ObjectObserver) OnInflatedObjectContent

func (o *ObjectObserver) OnInflatedObjectContent(h plumbing.Hash, pos int64, crc uint32, content []byte) error

OnInflatedObjectContent implements packfile.Observer.

func (*ObjectObserver) OnInflatedObjectHeader

func (o *ObjectObserver) OnInflatedObjectHeader(t plumbing.ObjectType, objSize int64, pos int64) error

OnInflatedObjectHeader implements packfile.Observer. Returns error if a blob object size surpasses maxBlobSize.

type PackObject

type PackObject struct {
	Type plumbing.ObjectType
	Hash plumbing.Hash
}

type PackedReferenceObject

type PackedReferenceObject struct {
	OldHash string
	NewHash string
}

PackedReferenceObject represent references added to a pack file

type PackedReferences

type PackedReferences map[string]*PackedReferenceObject

PackedReferences represents a collection of packed references

func (*PackedReferences) ID

func (p *PackedReferences) ID() string

ID returns the ID of the packed references

func (*PackedReferences) Names

func (p *PackedReferences) Names() (refs []string)

Names return the Names of the references

type PushedObjects

type PushedObjects []*PackObject

PushedObjects is a collection of PackObject

func (*PushedObjects) Hashes

func (po *PushedObjects) Hashes() (objs []string)

Hashes returns the string equivalent of the object hashes

type Reader

type Reader struct {
	References PackedReferences
	Objects    PushedObjects
	// contains filtered or unexported fields
}

PushReader inspects push data from git client, extracting data such as the pushed references, objects and object to reference mapping. It also pipes the pushed stream to a destination (git-receive-pack) when finished.

func NewPushReader

func NewPushReader(dst io.WriteCloser, repo types.LocalRepo) (*Reader, error)

NewPushReader creates an instance of PushReader, and after inspection, the written content will be copied to dst.

func (*Reader) GetSizeObjects

func (r *Reader) GetSizeObjects() int64

GetSizeObjects returns the size of pushed objects

func (*Reader) GetUpdateRequest

func (r *Reader) GetUpdateRequest() *packp.ReferenceUpdateRequest

GetUpdateRequest returns the reference update request object

func (*Reader) Read

func (r *Reader) Read() error

Read reads the packfile, extracting object and reference information and finally writes the read data to a provided destination

func (*Reader) SetUpdateRequest

func (r *Reader) SetUpdateRequest(request *packp.ReferenceUpdateRequest)

SetUpdateRequest sets the reference update request

func (*Reader) UseReferenceUpdateRequestRead

func (r *Reader) UseReferenceUpdateRequestRead(cb func(ur *packp.ReferenceUpdateRequest) error)

UseReferenceUpdateRequestRead sets a callback that is called after the push requested has been decoded but yet to be written to git. If the callback returns an error, the push request is aborted.

func (*Reader) Write

func (r *Reader) Write(p []byte) (int, error)

Write implements the io.Writer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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