updateref

package
v14.1.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error added in v14.1.0

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

Error reports an error in git update-ref

func (Error) Error added in v14.1.0

func (e Error) Error() string

type PreReceiveError added in v14.1.0

type PreReceiveError struct {
	Message string
}

PreReceiveError contains an error message for a git pre-receive failure

func (PreReceiveError) Error added in v14.1.0

func (e PreReceiveError) Error() string

type Updater

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

Updater wraps a `git update-ref --stdin` process, presenting an interface that allows references to be easily updated in bulk. It is not suitable for concurrent use.

func New

func New(ctx context.Context, conf config.Cfg, repo git.RepositoryExecutor, opts ...UpdaterOpt) (*Updater, error)

New returns a new bulk updater, wrapping a `git update-ref` process. Call the various methods to enqueue updates, then call Wait() to attempt to apply all the updates at once.

It is important that ctx gets canceled somewhere. If it doesn't, the process spawned by New() may never terminate.

func (*Updater) Create

func (u *Updater) Create(reference git.ReferenceName, value string) error

Create commands the reference to be created with the sha specified in value

func (*Updater) Delete

func (u *Updater) Delete(reference git.ReferenceName) error

Delete commands the reference to be removed from the repository

func (*Updater) Prepare

func (u *Updater) Prepare() error

Prepare prepares the reference transaction by locking all references and determining their current values. The updates are not yet committed and will be rolled back in case there is no call to `Wait()`. This call is optional.

func (*Updater) Update

func (u *Updater) Update(reference git.ReferenceName, newvalue, oldvalue string) error

Update commands the reference to be updated to point at the sha specified in newvalue

func (*Updater) Wait

func (u *Updater) Wait() error

Wait applies the commands specified in other calls to the Updater

type UpdaterOpt

type UpdaterOpt func(*updaterConfig)

UpdaterOpt is a type representing options for the Updater.

func WithDisabledTransactions

func WithDisabledTransactions() UpdaterOpt

WithDisabledTransactions disables hooks such that no reference-transactions are used for the updater.

type UpdaterWithHooks added in v14.1.0

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

UpdaterWithHooks updates a ref with Git hooks.

func NewUpdaterWithHooks added in v14.1.0

func NewUpdaterWithHooks(
	cfg config.Cfg,
	hookManager hook.Manager,
	gitCmdFactory git.CommandFactory,
	catfileCache catfile.Cache,
) *UpdaterWithHooks

NewUpdaterWithHooks creates a new instance of a struct that will update a Git reference.

func (*UpdaterWithHooks) UpdateReference added in v14.1.0

func (u *UpdaterWithHooks) UpdateReference(
	ctx context.Context,
	repo *gitalypb.Repository,
	user *gitalypb.User,
	reference git.ReferenceName,
	newrev, oldrev git.ObjectID,
	pushOptions ...string,
) error

UpdateReference updates a branch with a given commit ID using the Git hooks

Jump to

Keyboard shortcuts

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