Documentation ¶
Index ¶
- Constants
- Variables
- func SerializableError(err error) error
- type Action
- type ApplyParams
- type ChangeFileMode
- type CherryPickCommand
- type CommitParams
- type Conflict
- type ConflictEntry
- type ConflictError
- type ConflictingFilesError
- type ConflictsCommand
- type ConflictsResult
- type CreateDirectory
- type CreateFile
- type DeleteFile
- type DirectoryExistsError
- type EmptyError
- type Executor
- func (b *Executor) Apply(ctx context.Context, repo repository.GitRepo, params ApplyParams) (git.ObjectID, error)
- func (b *Executor) CherryPick(ctx context.Context, repo repository.GitRepo, m CherryPickCommand) (git.ObjectID, error)
- func (b *Executor) Commit(ctx context.Context, repo repository.GitRepo, params CommitParams) (git.ObjectID, error)
- func (b *Executor) Conflicts(ctx context.Context, repo repository.GitRepo, c ConflictsCommand) (ConflictsResult, error)
- func (b *Executor) Merge(ctx context.Context, repo repository.GitRepo, m MergeCommand) (MergeResult, error)
- func (b *Executor) Rebase(ctx context.Context, repo repository.GitRepo, r RebaseCommand) (git.ObjectID, error)
- func (b *Executor) Resolve(ctx context.Context, repo repository.GitRepo, r ResolveCommand) (ResolveResult, error)
- func (b *Executor) Revert(ctx context.Context, repo repository.GitRepo, r RevertCommand) (git.ObjectID, error)
- func (b *Executor) Submodule(ctx context.Context, repo repository.GitRepo, s SubmoduleCommand) (SubmoduleResult, error)
- type FileExistsError
- type FileNotFoundError
- type HasConflictsError
- type IndexError
- type InvalidArgumentError
- type MergeCommand
- type MergeResult
- type MoveFile
- type Patch
- type PatchIterator
- type RebaseCommand
- type ResolveCommand
- type ResolveResult
- type Result
- type RevertCommand
- type Signature
- type SubmoduleCommand
- type SubmoduleResult
- type UpdateFile
Constants ¶
const ( LegacyErrPrefixInvalidBranch = "Invalid branch" LegacyErrPrefixInvalidSubmodulePath = "Invalid submodule path" LegacyErrPrefixFailedCommit = "Failed to create commit" )
Error strings present in the legacy Ruby implementation
const ( // MergeRecursionLimit limits how many virtual merge bases are computed // in a recursive merge. MergeRecursionLimit = 20 )
Variables ¶
var ( // ErrInvalidArgument is returned in case the merge arguments are invalid. ErrInvalidArgument = errors.New("invalid parameters") // BinaryName is a binary name with version suffix . BinaryName = "gitaly-git2go-" + version.GetModuleVersion() )
var ErrMergeConflict = wrapError{Message: "merge conflict"}
ErrMergeConflict is returned when there is a merge conflict.
Functions ¶
func SerializableError ¶
SerializableError returns an error that is Gob serializable. Registered types are serialized directly. Unregistered types are transformed in to an opaque error using their error message. Wrapped errors remain unwrappable.
Types ¶
type Action ¶
type Action interface {
// contains filtered or unexported methods
}
Action represents an action taken to build a commit.
type ApplyParams ¶
type ApplyParams struct { // Repository is the path to the repository. Repository string // Committer is the committer applying the patch. Committer Signature // ParentCommit is the OID of the commit to apply the patches against. ParentCommit string // Patches iterates over all the patches to be applied. Patches PatchIterator }
ApplyParams are the parameters for Apply.
type ChangeFileMode ¶
type ChangeFileMode struct { // Path is the path of the whose mode to change. Path string // ExecutableMode indicates whether the file mode should be changed to executable or not. ExecutableMode bool // contains filtered or unexported fields }
ChangeFileMode sets a file's mode to either regular or executable file. FileNotFoundError is returned when attempting to change a non-existent file's mode.
type CherryPickCommand ¶
type CherryPickCommand struct { // Repository is the path where to execute the cherry pick. Repository string // CommitterName is the committer name for the resulting commit. CommitterName string // CommitterMail is the committer mail for the resulting commit. CommitterMail string // CommitterDate is the committer date of revert commit. CommitterDate time.Time // Message is the message to be used for the resulting commit. Message string // Ours is the commit that the revert is applied to. Ours string // Commit is the commit that is to be picked. Commit string // Mainline is the parent to be considered the mainline Mainline uint }
CherryPickCommand contains parameters to perform a cherry pick.
type CommitParams ¶
type CommitParams struct { // Repository is the path of the repository to operate on. Repository string // Author is the author of the commit. Author Signature // Committer is the committer of the commit. Committer Signature // Message is message of the commit. Message string // Parent is the OID of the commit to use as the parent of this commit. Parent string // Actions are the steps to build the commit. Actions []Action }
CommitParams contains the information and the steps to build a commit.
type Conflict ¶
type Conflict struct { // Ancestor is the conflict entry of the merge-base. Ancestor ConflictEntry // Our is the conflict entry of ours. Our ConflictEntry // Their is the conflict entry of theirs. Their ConflictEntry // Content contains the conflicting merge results. Content []byte }
Conflict represents a merge conflict for a single file.
type ConflictEntry ¶
type ConflictEntry struct { // Path is the path of the conflicting file. Path string // Mode is the mode of the conflicting file. Mode int32 }
ConflictEntry represents a conflict entry which is one of the sides of a conflict.
type ConflictError ¶
type ConflictError struct { // Code is the GRPC error code Code codes.Code // Message is the error message Message string }
ConflictError is an error which happened during conflict resolution.
func (ConflictError) Error ¶
func (e ConflictError) Error() string
type ConflictingFilesError ¶
type ConflictingFilesError struct { // ConflictingFiles is the set of files which have conflicts. ConflictingFiles []string }
ConflictingFilesError is an error raised when there are conflicting files.
func (ConflictingFilesError) Error ¶
func (err ConflictingFilesError) Error() string
type ConflictsCommand ¶
type ConflictsCommand struct { // Repository is the path to execute merge in. Repository string // Ours is the commit that is to be merged into theirs. Ours string // Theirs is the commit into which ours is to be merged. Theirs string }
ConflictsCommand contains parameters to perform a merge and return its conflicts.
type ConflictsResult ¶
type ConflictsResult struct { // Conflicts Conflicts []Conflict // Err is set if an error occurred. Err must exist on all gob serialized // results so that any error can be returned. // // Will be a ConflictError when an error occurred with the conflicts // subcommand. Err error }
ConflictsResult contains all conflicts resulting from a merge.
type CreateDirectory ¶
type CreateDirectory struct { // Path is the path of the directory to create. Path string // contains filtered or unexported fields }
CreateDirectory creates a directory in the given path with a '.gitkeep' file inside. FileExistsError is returned if a file already exists at the provided path. DirectoryExistsError is returned if a directory already exists at the provided path.
type CreateFile ¶
type CreateFile struct { // Path is the path of the file to create. Path string // ExecutableMode indicates whether the file mode should be executable or not. ExecutableMode bool // OID is the id of the object that contains the content of the file. OID string // contains filtered or unexported fields }
CreateFile creates a file using the provided path, mode and oid as the blob. FileExistsError is returned if a file exists at the given path.
type DeleteFile ¶
type DeleteFile struct { // Path is the path of the file to delete. Path string // contains filtered or unexported fields }
DeleteFile deletes a file or a directory from the provided path. FileNotFoundError is returned if the file does not exist.
type DirectoryExistsError ¶
type DirectoryExistsError string
DirectoryExistsError is returned when an action attempts to overwrite a directory.
func (DirectoryExistsError) Error ¶
func (err DirectoryExistsError) Error() string
type EmptyError ¶
type EmptyError struct{}
EmptyError indicates the command, for example cherry-pick, did result in no changes, so the result is empty.
func (EmptyError) Error ¶
func (err EmptyError) Error() string
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor executes gitaly-git2go.
func NewExecutor ¶
func NewExecutor(cfg config.Cfg, gitCmdFactory git.CommandFactory, locator storage.Locator) *Executor
NewExecutor returns a new gitaly-git2go executor using binaries as configured in the given configuration.
func (*Executor) Apply ¶
func (b *Executor) Apply(ctx context.Context, repo repository.GitRepo, params ApplyParams) (git.ObjectID, error)
Apply applies the provided patches and returns the OID of the commit with the patches applied.
func (*Executor) CherryPick ¶
func (b *Executor) CherryPick(ctx context.Context, repo repository.GitRepo, m CherryPickCommand) (git.ObjectID, error)
CherryPick performs a cherry pick via gitaly-git2go.
func (*Executor) Commit ¶
func (b *Executor) Commit(ctx context.Context, repo repository.GitRepo, params CommitParams) (git.ObjectID, error)
Commit builds a commit from the actions, writes it to the object database and returns its object id.
func (*Executor) Conflicts ¶
func (b *Executor) Conflicts(ctx context.Context, repo repository.GitRepo, c ConflictsCommand) (ConflictsResult, error)
Conflicts performs a merge via gitaly-git2go and returns all resulting conflicts.
func (*Executor) Merge ¶
func (b *Executor) Merge(ctx context.Context, repo repository.GitRepo, m MergeCommand) (MergeResult, error)
Merge performs a merge via gitaly-git2go.
func (*Executor) Rebase ¶
func (b *Executor) Rebase(ctx context.Context, repo repository.GitRepo, r RebaseCommand) (git.ObjectID, error)
Rebase performs the rebase via gitaly-git2go
func (*Executor) Resolve ¶
func (b *Executor) Resolve(ctx context.Context, repo repository.GitRepo, r ResolveCommand) (ResolveResult, error)
Resolve will attempt merging and resolving conflicts for the provided request
func (*Executor) Revert ¶
func (b *Executor) Revert(ctx context.Context, repo repository.GitRepo, r RevertCommand) (git.ObjectID, error)
Revert reverts a commit via gitaly-git2go.
func (*Executor) Submodule ¶
func (b *Executor) Submodule(ctx context.Context, repo repository.GitRepo, s SubmoduleCommand) (SubmoduleResult, error)
Submodule attempts to commit the request submodule change
type FileExistsError ¶
type FileExistsError string
FileExistsError is returned when an action attempts to overwrite an existing file.
func (FileExistsError) Error ¶
func (err FileExistsError) Error() string
type FileNotFoundError ¶
type FileNotFoundError string
FileNotFoundError is returned when an action attempts to operate on a non-existing file.
func (FileNotFoundError) Error ¶
func (err FileNotFoundError) Error() string
type HasConflictsError ¶
type HasConflictsError struct{}
HasConflictsError is used when a change, for example a revert, could not be applied due to a conflict.
func (HasConflictsError) Error ¶
func (err HasConflictsError) Error() string
type IndexError ¶
type IndexError string
IndexError is an error that was produced by performing an invalid operation on the index.
func (IndexError) Error ¶
func (err IndexError) Error() string
Error returns the error message of the index error.
type InvalidArgumentError ¶
type InvalidArgumentError string
InvalidArgumentError is returned when an invalid argument is provided.
func (InvalidArgumentError) Error ¶
func (err InvalidArgumentError) Error() string
type MergeCommand ¶
type MergeCommand struct { // Repository is the path to execute merge in. Repository string // AuthorName is the author name of merge commit. AuthorName string // AuthorMail is the author mail of merge commit. AuthorMail string // AuthorDate is the author date of merge commit. AuthorDate time.Time // CommitterName. Can be empty if all Committer* vars are empty. // In that case AuthorName is used instead. CommitterName string // CommitterMail. Can be empty if all Committer* vars are empty. // In that case AuthorMail is used instead. CommitterMail string // CommitterDate. Can be empty if all Committer* vars are empty. // In that case AuthorDate is used instead. CommitterDate time.Time // Message is the message to be used for the merge commit. Message string // Ours is the commit into which theirs is to be merged. Ours string // Theirs is the commit that is to be merged into ours. Theirs string // AllowConflicts controls whether conflicts are allowed. If they are, // then conflicts will be committed as part of the result. AllowConflicts bool // Squash controls whether to perform squash merge. // If set to `true`, then the resulting commit will have `Ours` as its only parent. // Otherwise, a merge commit will be created with `Ours` and `Theirs` as its parents. Squash bool }
MergeCommand contains parameters to perform a merge.
type MergeResult ¶
type MergeResult struct { // CommitID is the object ID of the generated merge commit. CommitID string }
MergeResult contains results from a merge.
type MoveFile ¶
type MoveFile struct { // Path is the path of the file to move. Path string // NewPath is the new path of the file. NewPath string // OID is the id of the object that contains the content of the file. If set, // the file contents are updated to match the object, otherwise the file keeps // the existing content. OID string // contains filtered or unexported fields }
MoveFile moves a file or a directory to the new path. FileNotFoundError is returned if the file does not exist.
type Patch ¶
type Patch struct { // Author is the author of the patch. Author Signature // Message is used as the commit message when applying the patch. Message string // Diff contains the diff of the patch. Diff []byte }
Patch represents a single patch.
type PatchIterator ¶
type PatchIterator interface { // Next returns whether there is a next patch. Next() bool // Value returns the patch being currently iterated upon. Value() Patch // Err returns the iteration error. Err should // be always checked after Next returns false. Err() error }
PatchIterator iterates over a stream of patches.
func NewSlicePatchIterator ¶
func NewSlicePatchIterator(patches []Patch) PatchIterator
NewSlicePatchIterator returns a PatchIterator that iterates over the slice of patches.
type RebaseCommand ¶
type RebaseCommand struct { // Repository is the path to execute rebase in. Repository string // Committer contains the the committer signature. Committer Signature // BranchName is the branch that is rebased. Deprecated, can be removed in the next release. BranchName string // UpstreamRevision is the revision where the branch is rebased onto. Deprecated, can be // removed in the next release. UpstreamRevision string // CommitID is the object ID of the commit that shall be rebased. Deprecates BranchName. CommitID git.ObjectID // UpstreamCommitID is the object ID of the commit which is considered to be the // upstream branch. This parameter determines both the commit onto which we're // about to rebase, which is the merge base of the upstream commit and rebased // commit, and which commits should be rebased, which is the commit range // upstream..commit. Deprecates the UpstreamRevision. UpstreamCommitID git.ObjectID // SkipEmptyCommits will cause commits which have already been applied on the target branch // and which are thus empty to be skipped. If unset, empty commits will cause the rebase to // fail. SkipEmptyCommits bool }
RebaseCommand contains parameters to rebase a branch.
type ResolveCommand ¶
type ResolveCommand struct { MergeCommand Resolutions []conflict.Resolution }
ResolveCommand contains arguments to perform a merge commit and resolve any conflicts produced from that merge commit
type ResolveResult ¶
type ResolveResult struct { MergeResult // Err is set if an error occurred. Err must exist on all gob serialized // results so that any error can be returned. Err error }
ResolveResult returns information about the successful merge and resolution
type Result ¶
type Result struct { // CommitID is the result of the call. CommitID string // Err is set if an error occurred. Err must exist on all gob serialized // results so that all errors can be returned. Err error }
Result is the serialized result.
type RevertCommand ¶
type RevertCommand struct { // Repository is the path to execute the revert in. Repository string // AuthorName is the author name of revert commit. AuthorName string // AuthorMail is the author mail of revert commit. AuthorMail string // AuthorDate is the author date of revert commit. AuthorDate time.Time // Message is the message to be used for the revert commit. Message string // Ours is the commit that the revert is applied to. Ours string // Revert is the commit to be reverted. Revert string // Mainline is the parent to be considered the mainline Mainline uint }
RevertCommand contains parameters required to execute a revert via gitaly-git2go.
type Signature ¶
type Signature struct { // Name of the author or the committer. Name string // Email of the author or the committer. Email string // When is the time of the commit. When time.Time }
Signature represents a commits signature.
type SubmoduleCommand ¶
type SubmoduleCommand struct { // Repository is the path to commit the submodule change Repository string // AuthorName is the author name of submodule commit. AuthorName string // AuthorMail is the author mail of submodule commit. AuthorMail string // AuthorDate is the auithor date of submodule commit. AuthorDate time.Time // Message is the message to be used for the submodule commit. Message string // CommitSHA is where the submodule should point CommitSHA string // Submodule is the actual submodule string to commit to the tree Submodule string // Branch where to commit submodule update Branch string }
SubmoduleCommand instructs how to commit a submodule update to a repo
type SubmoduleResult ¶
type SubmoduleResult struct { // CommitID is the object ID of the generated submodule commit. CommitID string }
SubmoduleResult contains results from a committing a submodule update
type UpdateFile ¶
type UpdateFile struct { // Path is the path of the file to update. Path string // OID is the id of the object that contains the new content of the file. OID string // contains filtered or unexported fields }
UpdateFile updates a file at the given path to point to the provided OID. FileNotFoundError is returned if the file does not exist.