Documentation ¶
Index ¶
- type Error
- type HookError
- type Updater
- func (u *Updater) Cancel() error
- func (u *Updater) Commit() error
- func (u *Updater) Create(reference git.ReferenceName, value string) error
- func (u *Updater) Delete(reference git.ReferenceName) error
- func (u *Updater) Prepare() error
- func (u *Updater) Update(reference git.ReferenceName, newvalue, oldvalue string) error
- type UpdaterOpt
- type UpdaterWithHooks
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
type HookError ¶ added in v14.3.0
type HookError struct {
// contains filtered or unexported fields
}
HookError contains an error message when executing a hook.
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 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 ¶ added in v14.3.0
Cancel aborts the transaction. No changes will be written to disk, all lockfiles will be cleaned up and the process will exit.
func (*Updater) Commit ¶ added in v14.3.0
Commit applies the commands specified in other calls to the Updater
func (*Updater) Create ¶
func (u *Updater) Create(reference git.ReferenceName, value string) error
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 ¶
func (u *Updater) Update(reference git.ReferenceName, newvalue, oldvalue string) error
Update commands the reference to be updated to point at the object ID specified in newvalue. If newvalue is the zero OID, then the branch will be deleted. If oldvalue 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 ¶ 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, 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.