Documentation ¶
Index ¶
- type AlreadyLockedError
- type CustomHookError
- type Error
- type FileDirectoryConflictError
- type InTransactionConflictError
- type InvalidReferenceFormatError
- type NonCommitObjectError
- type NonExistentObjectError
- type Updater
- func (u *Updater) Close() 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) Start() 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 AlreadyLockedError ¶
type AlreadyLockedError struct {
Ref string
}
AlreadyLockedError indicates a reference cannot be locked because another process has already locked it.
func (*AlreadyLockedError) Error ¶
func (e *AlreadyLockedError) Error() string
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 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 FileDirectoryConflictError ¶
type FileDirectoryConflictError struct { // ConflictingReferenceName is the name of the reference that would have conflicted. ConflictingReferenceName string // ExistingReferenceName is the name of the already existing reference. ExistingReferenceName string }
FileDirectoryConflictError is returned when an operation would causes a file-directory conflict in the reference store.
func (FileDirectoryConflictError) Error ¶
func (e FileDirectoryConflictError) Error() string
type InTransactionConflictError ¶
type InTransactionConflictError struct { // FirstReferenceName is the name of the first reference that was modified. FirstReferenceName string // SecondReferenceName is the name of the second reference that was modified. SecondReferenceName string }
InTransactionConflictError is returned when attempting to modify two references in the same transaction in a manner that is not allowed. For example, modifying 'refs/heads/parent' and creating 'refs/heads/parent/child' is not allowed.
func (InTransactionConflictError) Error ¶
func (e InTransactionConflictError) Error() string
type InvalidReferenceFormatError ¶
type InvalidReferenceFormatError struct { // ReferenceName is the invalid reference name. ReferenceName string }
InvalidReferenceFormatError indicates a reference name was invalid.
func (InvalidReferenceFormatError) Error ¶
func (e InvalidReferenceFormatError) Error() string
type NonCommitObjectError ¶
type NonCommitObjectError struct { // ReferenceName is the name of the branch that was being updated. ReferenceName string // ObjectID is the object ID of the non-commit object. ObjectID string }
NonCommitObjectError is returned when attempting to point a branch to an object that is not an object.
func (NonCommitObjectError) Error ¶
func (e NonCommitObjectError) Error() string
type NonExistentObjectError ¶
type NonExistentObjectError struct { // ReferenceName is the name of the reference that was being updated. ReferenceName string // ObjectID is the object ID of the non-existent object. ObjectID string }
NonExistentObjectError is returned when attempting to point a reference to an object that does not exist in the object database.
func (NonExistentObjectError) Error ¶
func (e NonExistentObjectError) 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.
Correct usage of the Updater is as follows:
- Transaction must be started before anything else.
- Transaction can't be started if there is an active transaction.
- Updates can be staged only when there is an unprepared transaction.
- Prepare can be called only with an unprepared transaction.
- Commit can be called only with an active transaction. The transaction can be committed unprepared or prepared.
- Close can be called at any time. The active transaction is aborted.
- Any sort of error causes the updater to close.
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) Close ¶
Close closes the updater and aborts a possible open transaction. No changes will be written to disk, all lockfiles will be cleaned up and the process will exit.
func (*Updater) Commit ¶
Commit applies the commands specified in other calls to the Updater. Commit finishes the reference transaction and another one must be started before further changes can be staged.
func (*Updater) Create ¶
Create commands the reference to be created with the given object ID. The ref must not exist.
A reference transaction must be started before calling Create.
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.
A reference transaction must be started before calling Delete.
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) Start ¶
Start begins a new reference transaction. The reference changes are not perfromed until Commit is explicitly called.
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.
A reference transaction must be started before calling Update.
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.
func WithNoDeref ¶
func WithNoDeref() UpdaterOpt
WithNoDeref disables de-reference while updating ref. If this option is turned on, <ref> itself is overwritten, rather than the result of following the symbolic ref.
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.