Documentation ¶
Index ¶
- type CustomHookError
- type ErrAlreadyLocked
- type Error
- type Updater
- func (u *Updater) Cancel() error
- func (u *Updater) Commit() error
- func (u *Updater) Create(reference git.ReferenceName, oid git.ObjectID) error
- func (u *Updater) Delete(reference git.ReferenceName) error
- func (u *Updater) Prepare() error
- func (u *Updater) Update(reference git.ReferenceName, newOID, oldOID git.ObjectID) error
- type UpdaterOpt
- type UpdaterWithHooks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomHookError ¶
type CustomHookError struct {
// contains filtered or unexported fields
}
CustomHookError contains an error message when executing a custom hook.
func (CustomHookError) Error ¶
func (e CustomHookError) Error() string
Error returns an error message.
func (CustomHookError) Proto ¶
func (e CustomHookError) Proto() *gitalypb.CustomHookError
Proto returns the Protobuf representation of this error.
func (CustomHookError) Unwrap ¶
func (e CustomHookError) Unwrap() error
Unwrap will return the embedded error.
type ErrAlreadyLocked ¶ added in v15.3.0
type ErrAlreadyLocked struct {
Ref string
}
ErrAlreadyLocked indicates a reference cannot be locked because another process has already locked it.
func (*ErrAlreadyLocked) Error ¶ added in v15.3.0
func (e *ErrAlreadyLocked) Error() string
type Error ¶
type Error struct { // Reference is the name of the reference that would have been updated. Reference git.ReferenceName // OldOID and NewOID are the expected object IDs previous to and after the update if it // would have succeeded. OldOID, NewOID git.ObjectID }
Error reports an error in git update-ref
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, 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 Commit() 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) Cancel ¶
Cancel aborts the transaction. No changes will be written to disk, all lockfiles will be cleaned up and the process will exit.
func (*Updater) Create ¶
Create commands the reference to be created with the given object ID. The ref must not exist.
func (*Updater) Delete ¶
func (u *Updater) Delete(reference git.ReferenceName) error
Delete commands the reference to be removed from the repository. This command will ignore any old state of the reference and just force-remove it.
func (*Updater) Prepare ¶
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 `Commit()`. This call is optional.
func (*Updater) Update ¶
Update commands the reference to be updated to point at the object ID specified in newOID. If newOID is the zero OID, then the branch will be deleted. If oldOID is a non-empty string, then the reference will only be updated if its current value matches the old value. If the old value is the zero OID, then the branch must not exist.
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 ¶
type UpdaterWithHooks struct {
// contains filtered or unexported fields
}
UpdaterWithHooks updates a ref with Git hooks.
func NewUpdaterWithHooks ¶
func NewUpdaterWithHooks( cfg config.Cfg, locator storage.Locator, 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 ¶
func (u *UpdaterWithHooks) UpdateReference( ctx context.Context, repoProto *gitalypb.Repository, user *gitalypb.User, quarantineDir *quarantine.Dir, reference git.ReferenceName, newrev, oldrev git.ObjectID, pushOptions ...string, ) error
UpdateReference updates a branch with a given commit ID using the Git hooks. If a quarantine directory is given, then the pre-receive, update and reference-transaction hook will be invoked with the quarantined repository as returned by the quarantine structure. If these hooks succeed, quarantined objects will be migrated and all subsequent hooks are executed via the unquarantined repository.