Documentation ¶
Index ¶
- Variables
- func BytesToHash(bz []byte) plumbing.Hash
- func BytesToHex(bz []byte) string
- func ChangesOpt(ch *types.Changes) types.KVOption
- func CreatePostCommit(r types.LocalRepo, args *CreatePostCommitArgs) (isNew bool, reference string, err error)
- func EmptyChangeResult() *types.ChangeResult
- func GetChanges(old, update types.Items) *types.ChangeResult
- func GetCommentPreview(comment *Comment) string
- func GetFreePostID(repo types.LocalRepo, startID int, postRefType string) (int, error)
- func GetKVOpt(key string, options []types.KVOption) interface{}
- func GetObjectFromPack(pack io.ReadSeeker, hash string) (res object.Object, err error)
- func GetPackableObjects(repo types.LocalRepo, obj object.Object, ...) (objs []plumbing.Hash, err error)
- func GetReactionsForComment(reactions ReactionMap, hash string) map[string]int
- func GetReferenceShortName(name string) string
- func GetRepoState(repo types.LocalRepo, options ...types.KVOption) types.RepoRefsState
- func GetTreeEntries(repo types.LocalRepo, treeHash string) ([]string, error)
- func HashToBytes(hexStr string) []byte
- func IsBranch(name string) bool
- func IsIssueReference(name string) bool
- func IsIssueReferencePath(name string) bool
- func IsMergeRequestReference(name string) bool
- func IsMergeRequestReferencePath(name string) bool
- func IsNote(name string) bool
- func IsPostReference(name string) bool
- func IsReference(name string) bool
- func IsTag(name string) bool
- func IsZeroHash(h string) bool
- func MakeCommitHash(data string) plumbing.Hash
- func MakeIssueReference(id interface{}) string
- func MakeIssueReferencePath() string
- func MakeMergeRequestReference(id interface{}) string
- func MakeMergeRequestReferencePath() string
- func MatchOpt(val string) types.KVOption
- func PackObject(repo types.LocalRepo, args *PackObjectArgs) (pack io.Reader, objs []plumbing.Hash, err error)
- func PostBodyToString(body *PostBody) string
- func Revert(repo types.LocalRepo, prevState types.RepoRefsState, options ...types.KVOption) (*types.Changes, error)
- func SidebandErr(msg string) []byte
- func SidebandInfoln(msg string) []byte
- func SidebandProgressln(msg string) []byte
- func SidebandYellowln(msg string) []byte
- func UnpackPackfile(pack io.ReadSeeker, cb UnpackCallback) (err error)
- func UnpackPackfileToRepo(repo types.LocalRepo, pack io2.ReadSeekerCloser) error
- func UpdateReactions(newReactions []string, targetHash, pusherKeyID string, dest ReactionMap)
- func WalkBack(localRepo types.LocalRepo, startHash, endHash string, ...) error
- func WalkCommitHistory(repo types.LocalRepo, commit *object.Commit, stopHash string) (hashes []string, err error)
- func WalkCommitHistoryWithIteratee(repo types.LocalRepo, args *WalkCommitHistoryArgs) error
- type Action
- type ActionType
- type Comment
- type Comments
- type CommitPacker
- type CreatePostCommitArgs
- type FreePostIDFinder
- type Obj
- type ObjCol
- func (oc *ObjCol) Bytes() []byte
- func (oc *ObjCol) Equal(o interface{}) bool
- func (oc *ObjCol) ForEach(iteratee func(i types.Item) bool)
- func (oc *ObjCol) Get(name interface{}) types.Item
- func (oc *ObjCol) Has(name interface{}) bool
- func (oc *ObjCol) Hash() util.Bytes32
- func (oc *ObjCol) Len() int64
- type PackObjectArgs
- type PackObjectFinder
- type PackToRepoUnpacker
- type PackfileUnpacker
- type Post
- type PostBody
- type PostBodyReader
- type PostCommitCreator
- type PostEntry
- type PostGetter
- type Posts
- type ReactionMap
- type RevertFunc
- type State
- type UnpackCallback
- type WalkCommitHistoryArgs
Constants ¶
This section is empty.
Variables ¶
var ( ErrRefNotFound = fmt.Errorf("reference not found") ErrNoCommits = fmt.Errorf("no commits") )
var ( IssueBranchPrefix = "issues" MergeRequestBranchPrefix = "merges" )
var (
ErrFailedToGetTagPointedObject = fmt.Errorf("failed to get pointed object of tag")
)
Functions ¶
func BytesToHash ¶
BytesToHash converts a byte slice to plumbing.Hash.
func ChangesOpt ¶
Changes creates a KVOption with 'changes' as key
func CreatePostCommit ¶
func CreatePostCommit(r types.LocalRepo, args *CreatePostCommitArgs) (isNew bool, reference string, err error)
CreatePostCommit creates a new post reference or adds a comment commit to an existing one.
func EmptyChangeResult ¶
func EmptyChangeResult() *types.ChangeResult
EmptyChangeResult returns an empty ChangeResult
func GetChanges ¶
func GetChanges(old, update types.Items) *types.ChangeResult
GetChanges takes one old collection of items and an updated collection of items and attempts to determine the changes that must be executed against the old collection before it is equal to the updated collection.
func GetCommentPreview ¶
GetCommentPreview returns a preview of a comment
func GetFreePostID ¶
GetFreePostID finds and returns an ID that is unused within the post reference type
func GetObjectFromPack ¶
GetObjectFromPack finds and returns an object from a given pack.
func GetPackableObjects ¶
func GetPackableObjects( repo types.LocalRepo, obj object.Object, objFilter ...func(hash plumbing.Hash) bool) (objs []plumbing.Hash, err error)
GetPackableObjects gets objects related to the given object for creating object-specific packfiles. Commit -> commit object, tree object, tree entries object. Blob -> blob object. Tree -> tree object, tree entries object. Tag -> tag object, pointed object [, objects of pointed object].
func GetReactionsForComment ¶
func GetReactionsForComment(reactions ReactionMap, hash string) map[string]int
GetReactionsForComment returns summed reactions of a comment.
func GetReferenceShortName ¶
GetReferenceShortName returns the short name of a reference
func GetRepoState ¶
GetRepoState returns the state of the repository repo: The target repository options: Allows the caller to configure how and what state are gathered
func GetTreeEntries ¶
GetTreeEntries returns all entries in a tree.
func HashToBytes ¶
HashToBytes decodes an object hash to bytes
func IsIssueReference ¶
IsIssueReference checks whether a branch is an issue branch
func IsIssueReferencePath ¶
IsIssueReferencePath checks if the specified reference matches an issue reference path
func IsMergeRequestReference ¶
IsMergeRequestReference checks whether a branch is a merge request branch
func IsMergeRequestReferencePath ¶
IsMergeRequestReferencePath checks if the specified reference matches a merge request reference path
func IsPostReference ¶
IsPostReference checks whether a reference is a post reference
func IsReference ¶
isReference checks the given name is a reference path or full reference name
func IsZeroHash ¶
isZeroHash checks whether a given hash is a zero git hash
func MakeCommitHash ¶
MakeCommitHash creates and returns a commit hash from the specified data
func MakeIssueReference ¶
func MakeIssueReference(id interface{}) string
MakeIssueReference creates an issue reference
func MakeIssueReferencePath ¶
func MakeIssueReferencePath() string
MakeIssueReferencePath returns the full issue reference path
func MakeMergeRequestReference ¶
func MakeMergeRequestReference(id interface{}) string
MakeMergeRequestReference creates a merge request reference
func MakeMergeRequestReferencePath ¶
func MakeMergeRequestReferencePath() string
MakeIssueReferencePath returns the full merge request reference path
func PackObject ¶
func PackObject(repo types.LocalRepo, args *PackObjectArgs) (pack io.Reader, objs []plumbing.Hash, err error)
PackObject creates a packfile from the given object. A commit is packed along with its tree and blobs. An annotated tag is packed along with its referenced commit object. Caller must ensure commit exist in the repo's object database.
func PostBodyToString ¶
PostBodyToString creates a formatted post body from an PostBody object
func Revert ¶
func Revert( repo types.LocalRepo, prevState types.RepoRefsState, options ...types.KVOption) (*types.Changes, error)
Revert reverts the repository from its current state to the previous state. options: Additional options. prefixOpt forces the operation to ignore any reference that does not contain the provided prefix.
func SidebandInfoln ¶
SidebandInfoln creates a sideband progress info message with a newline prefix
func SidebandProgressln ¶
SidebandProgressln creates a sideband progress message with a newline prefix
func SidebandYellowln ¶
SidebandYellowln is like SidebandInfoln but with yellow colored text
func UnpackPackfile ¶
func UnpackPackfile(pack io.ReadSeeker, cb UnpackCallback) (err error)
UnpackPackfile iterates through object headers in the given packfile, passing the callback the header and a function to read the current object.
The callback can return ErrExit to stop the iteration and exit with a nil error. If a different error is returned, then iteration ends with that error returned.
The packfile reader is reset, so it can be reused by the caller. The caller is responsible for closing the packfile reader.
func UnpackPackfileToRepo ¶
func UnpackPackfileToRepo(repo types.LocalRepo, pack io2.ReadSeekerCloser) error
UnpackPackfileToRepo unpacks the packfile into the given repository.
func UpdateReactions ¶
func UpdateReactions(newReactions []string, targetHash, pusherKeyID string, dest ReactionMap)
UpdateReactions calculates reactions for a target comment. newReactions: are new reactions from a comment. targetHash: the unique hash of the comment being reacted to. pusherKeyID: the unique push key ID of the reactor. dest: the map that contains the reaction data of which this function must update.
func WalkBack ¶
func WalkBack(localRepo types.LocalRepo, startHash, endHash string, cb func(hash string) error) error
WalkBack traverses the history of a commit and returns all objects discovered up til the given end object. If start object is not a commit, no traversing operation happens. but the object, along with its related objects (trees, blobs or target) are returned. End object must exist locally; If it is a tag, its target must be a commit.
func WalkCommitHistory ¶
func WalkCommitHistory(repo types.LocalRepo, commit *object.Commit, stopHash string) (hashes []string, err error)
WalkCommitHistory walks back a commit's history, returning its ancestors and other git objects they contain. stopHash stops the walk when an object matching the hash is found. Ancestors of the stop object will not be traversed.
func WalkCommitHistoryWithIteratee ¶
func WalkCommitHistoryWithIteratee(repo types.LocalRepo, args *WalkCommitHistoryArgs) error
WalkCommitHistoryWithIteratee walks back a commit's history, returning its ancestors and other git objects they contain. repo: The target repository args.Commit: The target/start commit args.StopHash: Stops the walk when an object matching the hash is found. Ancestors
of the stop object will not be traversed.
args.Res: A callback that will be called with any found object. Return ErrExit to stop immediately without error or return other error types to end immediately with the specified error.
Types ¶
type Action ¶
type Action struct { Data string DataItem types.Item Type ActionType }
Action describes a repo action to be effected on a repo object
func GetBranchRevertActions ¶
GetBranchRevertActions returns a set of actions to be executed against repo in other to bring its branch state to a specific target.
branchRef: The reference that was changed in the repo. oldRef: The version of ref that was in the old state (this one we want to Revert to)
func GetNoteRevertActions ¶
GetNoteRevertActions returns actions that represent instruction on how to Revert a repo to a previous state
noteRef: The note reference that was changed in the repo. oldRef: The version of ref that was in the old state (this one we want to Revert to)
func GetTagRevertActions ¶
GetTagRevertActions returns a set of actions to be executed against repo in other to bring its tag state to a specific target.
tagRef: The reference that was changed in the repo. oldRef: The version of ref that was in the old state (this one we want to Revert to)
type ActionType ¶
type ActionType int
ActionType represents a repo altering action
const ( // ActionTypeBranchDelete represents an action to delete a branch reference ActionTypeBranchDelete ActionType = iota // ActionTypeBranchUpdate represents an action to update a branch reference ActionTypeBranchUpdate // ActionTypeTagDelete represents an action to delete an annotated tag ActionTypeTagDelete // ActionTypeTagRefUpdate represents an action to update a tag's reference hash ActionTypeTagRefUpdate // ActionTypeNoteDelete represents an action to delete a note ActionTypeNoteDelete // ActionTypeNoteUpdate represents an action to update a note reference ActionTypeNoteUpdate )
type Comment ¶
type Comment struct { Created time.Time Reference string Hash string Author string AuthorEmail string Signature string Pusher string Body *PostBody GetReactions func() map[string]int }
Comment represent a reference post comment
type CommitPacker ¶
type CommitPacker func(repo types.LocalRepo, args *PackObjectArgs) (io.Reader, []plumbing.Hash, error)
CommitPacker describes a function for packing an object into a packfile.
type CreatePostCommitArgs ¶
type CreatePostCommitArgs struct { // Type is the type of post reference Type string // ID is the unique ID of the target post reference. // If unset, a free ID will be used. // If ID is a string, it is expected that the call // passed a full post reference path. ID interface{} // Body is the post's body file content Body string // IsComment indicates that the post is intended to be a comment IsComment bool // Force indicates that uncommitted changes can be ignored and lost Force bool // GetFreePostID is used to find a free post ID GetFreePostID FreePostIDFinder }
CreatePostCommitArgs includes argument for CreatePostCommit
type FreePostIDFinder ¶
type ObjCol ¶
type ObjCol struct {
// contains filtered or unexported fields
}
ObjCol implements Items. It is a collection of objects.
func (*ObjCol) ForEach ¶
ForEach iterates through the collection. Each item is passed as the only argument to the callback. Return true to break immediately
type PackObjectArgs ¶
type PackObjectArgs struct { // Obj is the target object to pack Obj object.Object // Filter selects objects that should be packed by returning true. Filter func(hash plumbing.Hash) bool }
PackObjectArgs contains arguments for PackObject.
type PackObjectFinder ¶
PackObjectFinder describes a function for finding a given object in a packfile
type PackToRepoUnpacker ¶
type PackToRepoUnpacker func(repo types.LocalRepo, pack io2.ReadSeekerCloser) error
PackToRepoUnpacker describes a function for writing a packfile into a repository
type PackfileUnpacker ¶
type PackfileUnpacker func(pack io.ReadSeeker, cb UnpackCallback) (err error)
PackfileUnpacker describes a function for unpacking a packfile.
type Post ¶
type Post struct { Repo types.LocalRepo // Title is the title of the post Title string // Name is the full reference name of the post Name string // First is the first comment in the post (main comment). First *Comment }
Post represents a reference post
func (*Post) GetComments ¶
GetComment returns the comments in the post
type PostBody ¶
type PostBody struct { // Content is the post's main content Content []byte `yaml:"-" msgpack:"content,omitempty"` // Title is the post's title Title string `yaml:"title,omitempty" msgpack:"title,omitempty"` // ReplyTo is used to set the comment commit hash to reply to. ReplyTo string `yaml:"replyTo,omitempty" msgpack:"replyTo,omitempty"` // Reactions are emoji directed at a comment being replied to Reactions []string `yaml:"reactions,flow,omitempty" msgpack:"reactions,omitempty"` // Close indicates that the post's thread should be closed. Close *bool `yaml:"close,omitempty" msgpack:"close,omitempty"` // Issue Specific Fields types.IssueFields `yaml:",omitempty,inline" msgpack:",omitempty"` // Merge Request Fields types.MergeRequestFields `yaml:",omitempty,inline" msgpack:",omitempty"` }
func PostBodyFromContentFrontMatter ¶
func PostBodyFromContentFrontMatter(cfm *pageparser.ContentFrontMatter) *PostBody
PostBodyFromContentFrontMatter attempts to load the instance from the specified content front matter object; It will find expected fields and try to cast the their expected type. It will not validate or return any error.
func ReadPostBody ¶
ReadPostBody reads the body file of a commit
func (*PostBody) IncludesAdminFields ¶
IncludesAdminFields checks whether administrative fields where set
type PostBodyReader ¶
PostBodyReader represents a function for reading a commit's post body
type PostCommitCreator ¶
type PostCommitCreator func(r types.LocalRepo, args *CreatePostCommitArgs) (isNew bool, reference string, err error)
PostCommitCreator is a function type for creating a post commit or adding comments to an existing post reference
type PostGetter ¶
type PostGetter func(targetRepo types.LocalRepo, filter func(ref plumbing.ReferenceName) bool) (posts Posts, err error)
PostGetter describes a function for finding posts
type Posts ¶
type Posts []PostEntry
Posts is a collection of Post
func GetPosts ¶
func GetPosts(targetRepo types.LocalRepo, filter func(ref plumbing.ReferenceName) bool) (posts Posts, err error)
GetPosts returns references that conform to the post protocol filter is used to check whether a reference is a post reference. Returns a slice of posts
func (*Posts) SortByFirstPostCreationTimeDesc ¶
func (p *Posts) SortByFirstPostCreationTimeDesc()
SortByFirstPostCreationTimeDesc sorts the posts by their first post creation time in descending order
type ReactionMap ¶
ReactionMap represents mapping for reactions of posts. commentHash: (reactionName: (pusherKeyID: count))
type RevertFunc ¶
type State ¶
GetState describes the current state of repository
func MakeStateFromItem ¶
MakeStateFromItem creates a GetState object from an Item. If Item is nil, an empty GetState is returned
func (*State) GetChanges ¶
func (s *State) GetChanges(y types.RepoRefsState) *types.Changes
GetChanges summarizes the changes between GetState s and y.
func (*State) GetReferences ¶
GetReferences returns the current repo references
type UnpackCallback ¶
UnpackCallback is a function for reading and unpacking a packfile object within UnpackPackfile. header is the object header and read is a function for reading the corresponding object.