Documentation ¶
Index ¶
- Constants
- type BranchCommit
- type ChangeResult
- type Changes
- type ColChangeType
- type Commit
- type CommitSignatory
- type GitModule
- type IssueFields
- type Item
- type ItemChange
- type Items
- type KVOption
- type ListPathValue
- type LocalConfig
- type LocalRepo
- type MergeRequestFields
- type RefFetchArgs
- type ReferenceData
- type ReferenceTxDetails
- type RepoRefsState
- type TxDetail
- func (tp *TxDetail) Bytes() []byte
- func (tp *TxDetail) BytesNoMergeIDAndSig() []byte
- func (tp *TxDetail) BytesNoSig() []byte
- func (tp *TxDetail) Data() *ReferenceData
- func (tp *TxDetail) DecodeMsgpack(dec *msgpack.Decoder) (err error)
- func (tp *TxDetail) EncodeMsgpack(enc *msgpack.Encoder) error
- func (tp *TxDetail) Equal(o *TxDetail) bool
- func (tp *TxDetail) GetGitSigPEMHeader() map[string]string
- func (tp *TxDetail) MustSignatureAsBytes() []byte
Constants ¶
const DefaultNS = "r"
DefaultNS is the default repo namespace
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BranchCommit ¶
type BranchCommit struct { Committer *CommitSignatory `json:"committer"` Author *CommitSignatory `json:"author"` Message string `json:"message"` Hash string `json:"hash"` ParentHashes []string `json:"parents"` }
type ChangeResult ¶
type ChangeResult struct {
Changes []*ItemChange
}
ChangeResult includes information about changes
type Changes ¶
type Changes struct {
References *ChangeResult
}
Changes describes reference changes that happened to a repository from a previous state to its current state.
type ColChangeType ¶
type ColChangeType int
ColChangeType describes a change to a collection item
const ( // ChangeTypeNew represents a new, unique item added to a collection ChangeTypeNew ColChangeType = iota // ChangeTypeRemove represents a removal of a collection item ChangeTypeRemove // ChangeTypeUpdate represents an update to the value of a collection item ChangeTypeUpdate )
type Commit ¶
type Commit interface { object.Object // NumParents returns the number of parents in a commit. NumParents() int // Parent returns the ith parent of a commit. Parent(i int) (Commit, error) // IsParent checks whether the specified hash is a parent of the commit IsParent(hash string) (bool, Commit) // UnWrap returns the underlying commit object UnWrap() *object.Commit // GetCommitter returns the one performing the commit, might be different from Author GetCommitter() *object.Signature // GetAuthor returns the original author of the commit. GetAuthor() *object.Signature // GetTreeHash returns the hash of the root tree of the commit GetTreeHash() plumbing.Hash // GetHash returns the hash of the commit object GetHash() plumbing.Hash // Tree returns the tree from the commit Tree() (*object.Tree, error) // File returns the file with the specified "path" in the commit and a // nil error if the file exists. File(path string) (*object.File, error) }
Commit represents a Commit.
type CommitSignatory ¶
type GitModule ¶
type GitModule interface { RefDelete(refname string) error RefUpdate(refname, commitHash string) error TagDelete(tagname string) error RefGet(refname string) (string, error) GetRecentCommitHash() (string, error) GetHEAD(short bool) (string, error) NumCommits(branch string, noMerges bool) (int, error) CreateEmptyCommit(msg, signingKey string, env ...string) error CreateTagWithMsg(args []string, msg, signingKey string, env ...string) error ListTreeObjects(treename string, recursive bool, env ...string) (map[string]string, error) ListTreeObjectsSlice(treename string, recursive, showTrees bool, env ...string) ([]string, error) RemoveEntryFromNote(notename, objectHash string, env ...string) error AddEntryToNote(notename, objectHash, note string, env ...string) error CreateBlob(content string) (string, error) AmendRecentCommitWithMsg(msg, signingKey string, env ...string) error HasMergeCommits(reference string, env ...string) (bool, error) GetMergeCommits(reference string, env ...string) ([]string, error) CreateSingleFileCommit(filename, content, commitMsg, parent string) (string, error) Checkout(refname string, create, force bool) error GetRefRootCommit(ref string) (string, error) GetRefCommits(ref string, noMerges bool) ([]string, error) Var(name string) (string, error) ExpandShortHash(hash string) (string, error) RefFetch(args RefFetchArgs) error GC(pruneExpire ...string) error Size() (size float64, err error) GetPathUpdateTime(path string) (time.Time, error) }
type IssueFields ¶
type IssueFields struct { // Labels describes and classifies the post using keywords Labels *[]string `yaml:"labels,flow,omitempty" msgpack:"labels,omitempty"` // Assignees are the push keys assigned to the post Assignees *[]string `yaml:"assignees,flow,omitempty" msgpack:"assignees,omitempty"` }
IssueFields contains post body fields specific to issue post
type Item ¶
type Item interface { GetName() string Equal(o interface{}) bool GetData() string GetType() string }
Item represents a git object or reference
type ItemChange ¶
type ItemChange struct { Item Item Action ColChangeType }
ItemChange describes a change event
type Items ¶
type Items interface { Has(name interface{}) bool Get(name interface{}) Item Equal(o interface{}) bool ForEach(func(i Item) bool) Len() int64 Bytes() []byte Hash() util.Bytes32 }
Items represents a collection of git objects or references identified by a name
type KVOption ¶
type KVOption struct { Key string Value interface{} }
KVOption holds key-value structure of options
type ListPathValue ¶
type LocalConfig ¶
func EmptyLocalConfig ¶
func EmptyLocalConfig() *LocalConfig
EmptyLocalConfig returns an instance of LocalConfig with fields initialized to zero values.
type LocalRepo ¶
type LocalRepo interface { GitModule // GetName returns the name of the repo GetName() string // GetNamespaceName returns the namespace this repo is associated to. GetNamespaceName() string // GetNamespace returns the repos's namespace GetNamespace() *state.Namespace // References returns an unsorted ReferenceIter for all references. References() (storer.ReferenceIter, error) // IsContributor checks whether a push key is a contributor to either // the repository or its namespace IsContributor(pushKeyID string) bool // GetGitConfigOption finds and returns git config option value GetGitConfigOption(path string) string // GetRemoteURLs returns remote URLS of the repository. // Use `names` to select specific remotes with matching name. GetRemoteURLs(names ...string) (urls []string) // DeleteObject deletes an object from a repository. DeleteObject(hash plumbing.Hash) error // Reference returns the reference for a given reference name. Reference(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) // Object returns an Object with the given hash. Object(t plumbing.ObjectType, h plumbing.Hash) (object.Object, error) // Objects returns an unsorted ObjectIter with all the objects in the repository. Objects() (*object.ObjectIter, error) // CommitObjects returns an unsorted ObjectIter with all the objects in the repository. CommitObjects() (object.CommitIter, error) // Tags return all tag references in the repository. // If you want to check to see if the tag is an annotated tag, you can call // TagObject on the hash Reference Tags() (storer.ReferenceIter, error) // CommitObject returns a commit. CommitObject(h plumbing.Hash) (*object.Commit, error) // WrappedCommitObject returns commit that implements types.Commit interface. WrappedCommitObject(h plumbing.Hash) (Commit, error) // BlobObject returns a Blob with the given hash. BlobObject(h plumbing.Hash) (*object.Blob, error) // TagObject returns a Tag with the given hash. TagObject(h plumbing.Hash) (*object.Tag, error) // Tag returns a tag from the repository. Tag(name string) (*plumbing.Reference, error) // Config return the repository's git config Config() (*config.Config, error) // SetConfig sets the repo config SetConfig(cfg *config.Config) error // IsAncestor checks whether commitA is an ancestor to commitB. // It returns ErrNotAncestor when not an ancestor. IsAncestor(commitA string, commitB string) error // SetPath sets the repository root path SetPath(path string) // GetReferences returns all references in the repo GetReferences() (refs []plumbing.ReferenceName, err error) // Reload reloads the repository Reload() error // GetPath returns the repository's path GetPath() string // IsClean checks whether the working directory has no un-tracked, staged or modified files IsClean() (bool, error) // GetState returns the repository's network state GetState() *state.Repository // SetState sets the repository's network state SetState(s *state.Repository) // Head returns the reference where HEAD is pointing to. Head() (string, error) // HeadObject returns the object of the HEAD reference. // Returns plumbing.ErrReferenceNotFound if HEAD was not found. HeadObject() (object.Object, error) // ObjectExist checks whether an object exist in the target repository ObjectExist(objHash string) bool // GetObjectSize returns the size of an object GetObjectSize(objHash string) (int64, error) // ObjectsOfCommit returns a hashes of objects a commit is composed of. // This objects a the commit itself, its tree and the tree blobs. ObjectsOfCommit(hash string) ([]plumbing.Hash, error) // GetObject returns an object GetObject(objHash string) (object.Object, error) // GetStorer returns the storage engine of the repository GetStorer() storage.Storer // Prune prunes objects older than the given time Prune(olderThan time.Time) error // NumIssueBranches counts the number of issues branches NumIssueBranches() (count int, err error) // GetAncestors returns the ancestors of the given commit up til the ancestor matching the stop hash. // The stop hash ancestor is not included in the result. // Reverse reverses the result GetAncestors(commit *object.Commit, stopHash string, reverse bool) (ancestors []*object.Commit, err error) // UpdateRepoConfig updates the 'repocfg' configuration file UpdateRepoConfig(cfg *LocalConfig) (err error) // GetRepoConfig returns the 'repocfg' config object GetRepoConfig() (*LocalConfig, error) // ListPath returns a list of entries in a repository's path ListPath(ref, path string) (res []ListPathValue, err error) // GetFileLines returns the lines of a file GetFileLines(ref, path string) (res []string, err error) // GetBranches returns a list of branches GetBranches() (branches []string, err error) // GetBranchCommit returns information about last commit of a branch GetLatestCommit(branch string) (*BranchCommit, error) // GetCommits returns commits of a branch. // - branch: The target branch. // - limit: The number of commit to return. 0 means all. GetCommits(branch string, limit int) (res []*BranchCommit, err error) // GetCommitAncestors returns ancestors of a commit with the given hash. // - commitHash: The hash of the commit. // - limit: The number of commit to return. 0 means all. GetCommitAncestors(commitHash string, limit int) (res []*BranchCommit, err error) }
LocalRepo represents a local git repository on disk
type MergeRequestFields ¶
type MergeRequestFields struct { // BaseBranch is the destination branch name BaseBranch string `yaml:"base,omitempty" msgpack:"base,omitempty"` // BaseBranchHash is the destination branch current hash BaseBranchHash string `yaml:"baseHash,omitempty" msgpack:"baseHash,omitempty"` // TargetBranch is the name of the source branch TargetBranch string `yaml:"target,omitempty" msgpack:"target,omitempty"` // TargetBranchHash is the hash of the source branch TargetBranchHash string `yaml:"targetHash,omitempty" msgpack:"targetHash,omitempty"` }
MergeRequestFields contains post body fields specific to merge request posts
type RefFetchArgs ¶
type ReferenceData ¶
type ReferenceData struct { util.CodecUtil IssueFields MergeRequestFields // Close indicates that the reference is closed Close *bool `json:"close" msgpack:"close,omitempty"` }
ReferenceData stores additional data extracted from a pushed reference.
func (*ReferenceData) DecodeMsgpack ¶
func (rd *ReferenceData) DecodeMsgpack(dec *msgpack.Decoder) (err error)
func (*ReferenceData) EncodeMsgpack ¶
func (rd *ReferenceData) EncodeMsgpack(enc *msgpack.Encoder) error
type ReferenceTxDetails ¶
ReferenceTxDetails represents a collection of transaction details signed by same creator push key, creator nonce, targeting same repository and repository namespace.
func ToReferenceTxDetails ¶
func ToReferenceTxDetails(details []*TxDetail) ReferenceTxDetails
ToReferenceTxDetails converts a slice of TxDetail to a map of TxDetail key by their reference
func (ReferenceTxDetails) Get ¶
func (td ReferenceTxDetails) Get(ref string) *TxDetail
Get gets a detail by reference name
func (ReferenceTxDetails) GetNonce ¶
func (td ReferenceTxDetails) GetNonce() uint64
GetNonce returns the transaction nonce
func (ReferenceTxDetails) GetPushKeyID ¶
func (td ReferenceTxDetails) GetPushKeyID() string
GetPushKeyID returns the push key id of one of the transaction details
func (ReferenceTxDetails) GetRepoName ¶
func (td ReferenceTxDetails) GetRepoName() string
GetRepoName returns the target repository name of one of the transaction details
func (ReferenceTxDetails) GetRepoNamespace ¶
func (td ReferenceTxDetails) GetRepoNamespace() string
GetRepoNamespace returns the target repo namespace of one of the transaction details
type RepoRefsState ¶
type RepoRefsState interface { // GetReferences returns the references. GetReferences() Items // IsEmpty checks whether the state is empty IsEmpty() bool // GetChanges summarizes the changes between GetState s and y. GetChanges(y RepoRefsState) *Changes }
RepoRefsState represents a repositories state
type TxDetail ¶
type TxDetail struct { util.CodecUtil RepoName string `json:"repo" msgpack:"repo,omitempty" mapstructure:"repo"` // The target repo name RepoNamespace string `json:"namespace" msgpack:"namespace,omitempty" mapstructure:"namespace"` // The target repo namespace Reference string `json:"reference" msgpack:"reference,omitempty" mapstructure:"reference"` // The target reference Fee util.String `json:"fee" msgpack:"fee,omitempty" mapstructure:"fee"` // Network fee to be paid for update to the target ref Value util.String `json:"value" msgpack:"value,omitempty" mapstructure:"value"` // Additional value for paying for special operations Nonce uint64 `json:"nonce" msgpack:"nonce,omitempty" mapstructure:"nonce"` // Nonce of the account paying the network fee and signing the update. PushKeyID string `json:"pkID" msgpack:"pkID,omitempty" mapstructure:"pkID"` // The pusher public key ID. Signature string `json:"sig" msgpack:"sig,omitempty" mapstructure:"sig"` // The signature of the tx parameter MergeProposalID string `json:"mergeID" msgpack:"mergeID,omitempty" mapstructure:"mergeID"` // Specifies a merge proposal that the push is meant to fulfil Head string `json:"head" msgpack:"head,omitempty" mapstructure:"head"` // Indicates the [tip] hash of the target reference // FlagCheckAdminUpdatePolicy indicate the pusher's intention to perform admin update // operation that will require an admin update policy specific to the reference FlagCheckAdminUpdatePolicy bool `json:"-" msgpack:"-" mapstructure:"-"` // ReferenceData includes data that were extracted from the pushed reference content. ReferenceData *ReferenceData `json:"-" msgpack:"-" mapstructure:"-"` }
TxDetail represents transaction information required to generate a network transaction for updating a repository. It includes basic network transaction fields, flags and post validation data required to construct a valid push transaction.
func DecodeSignatureHeader ¶
DecodeSignatureHeader decodes the given commit/tag signature and returns a TxDetail
func TxDetailFromGitSigPEMHeader ¶
TxDetailFromGitSigPEMHeader constructs a TxDetail instance from a git signature PEM header
func (*TxDetail) BytesNoMergeIDAndSig ¶
BytesNoMergeIDAndSig returns bytes version of tp excluding the signature and merge ID
func (*TxDetail) BytesNoSig ¶
BytesNoSig returns bytes version of tp excluding the signature
func (*TxDetail) Data ¶
func (tp *TxDetail) Data() *ReferenceData
Data initializes and returns the reference data
func (*TxDetail) DecodeMsgpack ¶
func (*TxDetail) Equal ¶
Equal checks whether this object is equal to the give object. Signature and MergeProposalID fields are excluded from equality check.
func (*TxDetail) GetGitSigPEMHeader ¶
GetGitSigPEMHeader returns headers to be used as git signature PEM headers
func (*TxDetail) MustSignatureAsBytes ¶
MustSignatureAsBytes returns the decoded signature. Panics if signature could not be decoded.