Versions in this module Expand all Collapse all v1 v1.999.0 Jan 31, 2020 v1.8.0 Jan 31, 2020 Changes in this version + const BranchPrefix + const DefaultLocale + const EmptySHA + const GitTimeLayout + const HookPathUpdate + const NotesRef + const TagPrefix + var CommitsRangeSize = 50 + var Debug = false + var DefaultCommandExecutionTimeout = 60 * time.Second + var DefaultContext = context.Background() + var ErrNotValidHook = errors.New("not a valid Git hook") + var GitExecutable = "git" + var GitVersionRequired = "1.7.2" + var GlobalCommandArgs []string + var Prefix = "[git-module] " + func AddChanges(repoPath string, all bool, files ...string) error + func AddChangesWithArgs(repoPath string, gloablArgs []string, all bool, files ...string) error + func AllCommitsCount(repoPath string) (int64, error) + func BinVersion() (string, error) + func Checkout(repoPath string, opts CheckoutOptions) error + func Clone(from, to string, opts CloneRepoOptions) (err error) + func CloneWithArgs(from, to string, args []string, opts CloneRepoOptions) (err error) + func CommitChanges(repoPath string, opts CommitChangesOptions) error + func CommitChangesWithArgs(repoPath string, args []string, opts CommitChangesOptions) error + func CommitsCount(repoPath, revision string) (int64, error) + func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLine int) string + func Fsck(repoPath string, timeout time.Duration, args ...string) error + func GetFullCommitID(repoPath, shortID string) (string, error) + func GetLatestCommitTime(repoPath string) (time.Time, error) + func GetNote(repo *Repository, commitID string, note *Note) error + func GetRawDiff(repoPath, commitID string, diffType RawDiffType, writer io.Writer) error + func GetRawDiffForFile(repoPath, startCommit, endCommit string, diffType RawDiffType, file string, ...) error + func GetRepoRawDiffForFile(repo *Repository, startCommit, endCommit string, diffType RawDiffType, ...) error + func Init(ctx context.Context) error + func InitRepository(repoPath string, bare bool) error + func IsBranchExist(repoPath, name string) bool + func IsErrBranchNotExist(err error) bool + func IsErrExecTimeout(err error) bool + func IsErrNotExist(err error) bool + func IsErrUnsupportedVersion(err error) bool + func IsReferenceExist(repoPath, name string) bool + func IsRepoURLAccessible(url string) bool + func IsTagExist(repoPath, name string) bool + func IsValidHookName(name string) bool + func MoveFile(repoPath, oldTreeName, newTreeName string) error + func ParseBool(value string) (result bool, valid bool) + func ParseDiffHunkString(diffhunk string) (leftLine, leftHunk, rightLine, righHunk int) + func Pull(repoPath string, opts PullRemoteOptions) error + func Push(repoPath string, opts PushOptions) error + func RefEndName(refStr string) string + func ResetHEAD(repoPath string, hard bool, revision string) error + func SetExecutablePath(path string) error + func SetUpdateHook(repoPath, content string) (err error) + func SplitRefName(refStr string) (string, string) + func Version() string + type ArchiveType int + const TARGZ + const ZIP + func (a ArchiveType) String() string + type BlamePart struct + Lines []string + Sha string + type BlameReader struct + func CreateBlameReader(repoPath, commitID, file string) (*BlameReader, error) + func (r *BlameReader) Close() error + func (r *BlameReader) NextPart() (*BlamePart, error) + type Blob struct + ID SHA1 + func (b *Blob) DataAsync() (io.ReadCloser, error) + func (b *Blob) GetBlobContent() (string, error) + func (b *Blob) GetBlobContentBase64() (string, error) + func (b *Blob) GetBlobLineCount() (int, error) + func (b *Blob) Name() string + func (b *Blob) Size() int64 + type Branch struct + Name string + Path string + func GetBranchesByPath(path string) ([]*Branch, error) + func (branch *Branch) GetCommit() (*Commit, error) + type CheckAttributeOpts struct + AllAttributes bool + Attributes []string + CachedOnly bool + Filenames []string + type CheckoutOptions struct + Branch string + OldBranch string + Timeout time.Duration + type CloneRepoOptions struct + Bare bool + Branch string + Depth int + Mirror bool + NoCheckout bool + Quiet bool + Shared bool + Timeout time.Duration + type CodeActivityAuthor struct + Commits int64 + Email string + Name string + type CodeActivityStats struct + Additions int64 + AuthorCount int64 + Authors []*CodeActivityAuthor + ChangedFiles int64 + CommitCount int64 + CommitCountInAllBranches int64 + Deletions int64 + type Command struct + func NewCommand(args ...string) *Command + func NewCommandNoGlobals(args ...string) *Command + func (c *Command) AddArguments(args ...string) *Command + func (c *Command) Run() (string, error) + func (c *Command) RunInDir(dir string) (string, error) + func (c *Command) RunInDirBytes(dir string) ([]byte, error) + func (c *Command) RunInDirFullPipeline(dir string, stdout, stderr io.Writer, stdin io.Reader) error + func (c *Command) RunInDirPipeline(dir string, stdout, stderr io.Writer) error + func (c *Command) RunInDirTimeout(timeout time.Duration, dir string) ([]byte, error) + func (c *Command) RunInDirTimeoutEnv(env []string, timeout time.Duration, dir string) ([]byte, error) + func (c *Command) RunInDirTimeoutEnvFullPipeline(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer, ...) error + func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer, ...) error + func (c *Command) RunInDirTimeoutEnvPipeline(env []string, timeout time.Duration, dir string, stdout, stderr io.Writer) error + func (c *Command) RunInDirTimeoutFullPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer, stdin io.Reader) error + func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, stdout, stderr io.Writer) error + func (c *Command) RunInDirWithEnv(dir string, env []string) (string, error) + func (c *Command) RunTimeout(timeout time.Duration) (string, error) + func (c *Command) SetDescription(desc string) *Command + func (c *Command) SetParentContext(ctx context.Context) *Command + func (c *Command) String() string + type Commit struct + Author *Signature + Branch string + CommitMessage string + Committer *Signature + ID SHA1 + Parents []SHA1 + Signature *CommitGPGSignature + func CommitFromReader(gitRepo *Repository, sha plumbing.Hash, reader io.Reader) (*Commit, error) + func (c *Commit) CommitsBefore() (*list.List, error) + func (c *Commit) CommitsBeforeLimit(num int) (*list.List, error) + func (c *Commit) CommitsBeforeUntil(commitID string) (*list.List, error) + func (c *Commit) CommitsByRange(page, pageSize int) (*list.List, error) + func (c *Commit) CommitsCount() (int64, error) + func (c *Commit) CreateArchive(target string, opts CreateArchiveOpts) error + func (c *Commit) FileChangedSinceCommit(filename, pastCommit string) (bool, error) + func (c *Commit) GetBranchName() (string, error) + func (c *Commit) GetCommitByPath(relpath string) (*Commit, error) + func (c *Commit) GetFilesChangedSinceCommit(pastCommit string) ([]string, error) + func (c *Commit) GetRepositoryDefaultPublicGPGKey(forceUpdate bool) (*GPGSettings, error) + func (c *Commit) GetSubModule(entryname string) (*SubModule, error) + func (c *Commit) GetSubModules() (*ObjectCache, error) + func (c *Commit) HasFile(filename string) (bool, error) + func (c *Commit) HasPreviousCommit(commitHash SHA1) (bool, error) + func (c *Commit) ImageInfo(name string) (*ImageMetaData, error) + func (c *Commit) IsImageFile(name string) bool + func (c *Commit) Message() string + func (c *Commit) Parent(n int) (*Commit, error) + func (c *Commit) ParentCount() int + func (c *Commit) ParentID(n int) (SHA1, error) + func (c *Commit) SearchCommits(opts SearchCommitsOptions) (*list.List, error) + func (c *Commit) Summary() string + type CommitChangesOptions struct + Author *Signature + Committer *Signature + Message string + type CommitFileStatus struct + Added []string + Modified []string + Removed []string + func GetCommitFileStatus(repoPath, commitID string) (*CommitFileStatus, error) + func NewCommitFileStatus() *CommitFileStatus + type CommitGPGSignature struct + Payload string + Signature string + type CommitTreeOpts struct + AlwaysSign bool + KeyID string + Message string + NoGPGSign bool + Parents []string + type CompareInfo struct + Commits *list.List + MergeBase string + NumFiles int + type CountObject struct + Count int64 + Garbage int64 + InPack int64 + Packs int64 + PrunePack int64 + Size int64 + SizeGarbage int64 + SizePack int64 + func CountObjects(repoPath string) (*CountObject, error) + type CreateArchiveOpts struct + Format ArchiveType + Prefix bool + type DeleteBranchOptions struct + Force bool + type DivergeObject struct + Ahead int + Behind int + func GetDivergingCommits(repoPath string, baseBranch string, targetBranch string) (DivergeObject, error) + type Entries []*TreeEntry + func (tes Entries) CustomSort(cmp func(s1, s2 string) bool) + func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCommitCache) ([][]interface{}, *Commit, error) + func (tes Entries) Sort() + type EntryMode int + const EntryModeBlob + const EntryModeCommit + const EntryModeExec + const EntryModeSymlink + const EntryModeTree + type ErrBadLink struct + Message string + Name string + func (err ErrBadLink) Error() string + type ErrBranchNotExist struct + Name string + func (err ErrBranchNotExist) Error() string + type ErrExecTimeout struct + Duration time.Duration + func (err ErrExecTimeout) Error() string + type ErrNotExist struct + ID string + RelPath string + func (err ErrNotExist) Error() string + type ErrUnsupportedVersion struct + Required string + func (err ErrUnsupportedVersion) Error() string + type GPGSettings struct + Email string + KeyID string + Name string + PublicKeyContent string + Sign bool + func (gpgSettings *GPGSettings) LoadPublicKeyContent() error + type Hook struct + Content string + IsActive bool + Sample string + func GetHook(repoPath, name string) (*Hook, error) + func ListHooks(repoPath string) (_ []*Hook, err error) + func (h *Hook) Name() string + func (h *Hook) Update() error + type ImageMetaData struct + ByteSize int64 + ColorModel color.Model + Height int + Width int + type LastCommitCache interface + Get func(repoPath, ref, entryPath string) (*Commit, error) + Put func(repoPath, ref, entryPath string, commit *Commit) error + type Note struct + Commit *Commit + Message []byte + type ObjectCache struct + func (oc *ObjectCache) Get(id string) (interface{}, bool) + func (oc *ObjectCache) Set(id string, obj interface{}) + type ObjectType string + const ObjectBlob + const ObjectBranch + const ObjectCommit + const ObjectTag + const ObjectTree + type PullRemoteOptions struct + All bool + Branch string + Rebase bool + Remote string + Timeout time.Duration + type PushOptions struct + Branch string + Env []string + Force bool + Remote string + type RawDiffType string + const RawDiffNormal + const RawDiffPatch + type Reference struct + Name string + Object SHA1 + Type string + func (ref *Reference) Commit() (*Commit, error) + type Repository struct + Path string + func OpenRepository(repoPath string) (*Repository, error) + func (r *Repository) CommitNodeIndex() (cgobject.CommitNodeIndex, *os.File) + func (repo *Repository) AddObjectToIndex(mode string, object SHA1, filename string) error + func (repo *Repository) AddRemote(name, url string, fetch bool) error + func (repo *Repository) CheckAttribute(opts CheckAttributeOpts) (map[string]map[string]string, error) + func (repo *Repository) Close() + func (repo *Repository) CommitTree(sig *Signature, tree *Tree, opts CommitTreeOpts) (SHA1, error) + func (repo *Repository) CommitsBetween(last *Commit, before *Commit) (*list.List, error) + func (repo *Repository) CommitsBetweenIDs(last, before string) (*list.List, error) + func (repo *Repository) CommitsBetweenLimit(last *Commit, before *Commit, limit, skip int) (*list.List, error) + func (repo *Repository) CommitsByFileAndRange(revision, file string, page int) (*list.List, error) + func (repo *Repository) CommitsByFileAndRangeNoFollow(revision, file string, page int) (*list.List, error) + func (repo *Repository) CommitsCountBetween(start, end string) (int64, error) + func (repo *Repository) ConvertToSHA1(commitID string) (SHA1, error) + func (repo *Repository) CreateAnnotatedTag(name, message, revision string) error + func (repo *Repository) CreateBranch(branch, oldbranchOrCommit string) error + func (repo *Repository) CreateTag(name, revision string) error + func (repo *Repository) DeleteBranch(name string, opts DeleteBranchOptions) error + func (repo *Repository) EmptyIndex() error + func (repo *Repository) FileBlame(revision, path, file string) ([]byte, error) + func (repo *Repository) FileChangedBetweenCommits(filename, id1, id2 string) (bool, error) + func (repo *Repository) FileCommitsCount(revision, file string) (int64, error) + func (repo *Repository) FilesCountBetween(startCommitID, endCommitID string) (int, error) + func (repo *Repository) GetAllCommitsCount() (int64, error) + func (repo *Repository) GetAnnotatedTag(sha string) (*Tag, error) + func (repo *Repository) GetBlob(idStr string) (*Blob, error) + func (repo *Repository) GetBranch(branch string) (*Branch, error) + func (repo *Repository) GetBranchCommit(name string) (*Commit, error) + func (repo *Repository) GetBranchCommitID(name string) (string, error) + func (repo *Repository) GetBranches() ([]string, error) + func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) (*CodeActivityStats, error) + func (repo *Repository) GetCommit(commitID string) (*Commit, error) + func (repo *Repository) GetCommitByPath(relpath string) (*Commit, error) + func (repo *Repository) GetCompareInfo(basePath, baseBranch, headBranch string) (_ *CompareInfo, err error) + func (repo *Repository) GetDefaultPublicGPGKey(forceUpdate bool) (*GPGSettings, error) + func (repo *Repository) GetDiff(base, head string, w io.Writer) error + func (repo *Repository) GetDiffFromMergeBase(base, head string, w io.Writer) error + func (repo *Repository) GetDiffOrPatch(base, head string, w io.Writer, formatted bool) error + func (repo *Repository) GetHEADBranch() (*Branch, error) + func (repo *Repository) GetHook(name string) (*Hook, error) + func (repo *Repository) GetMergeBase(tmpRemote string, base, head string) (string, string, error) + func (repo *Repository) GetPatch(base, head string, w io.Writer) error + func (repo *Repository) GetRefCommitID(name string) (string, error) + func (repo *Repository) GetRefType(ref string) ObjectType + func (repo *Repository) GetRefs() ([]*Reference, error) + func (repo *Repository) GetRefsFiltered(pattern string) ([]*Reference, error) + func (repo *Repository) GetTag(name string) (*Tag, error) + func (repo *Repository) GetTagCommit(name string) (*Commit, error) + func (repo *Repository) GetTagCommitID(name string) (string, error) + func (repo *Repository) GetTagID(name string) (string, error) + func (repo *Repository) GetTagInfos() ([]*Tag, error) + func (repo *Repository) GetTagNameBySHA(sha string) (string, error) + func (repo *Repository) GetTagType(id SHA1) (string, error) + func (repo *Repository) GetTags() ([]string, error) + func (repo *Repository) GetTree(idStr string) (*Tree, error) + func (repo *Repository) GoGitRepo() *gogit.Repository + func (repo *Repository) HashObject(reader io.Reader) (SHA1, error) + func (repo *Repository) Hooks() ([]*Hook, error) + func (repo *Repository) IsBranchExist(name string) bool + func (repo *Repository) IsCommitExist(name string) bool + func (repo *Repository) IsEmpty() (bool, error) + func (repo *Repository) IsTagExist(name string) bool + func (repo *Repository) LineBlame(revision, path, file string, line uint) (*Commit, error) + func (repo *Repository) LsFiles(filenames ...string) ([]string, error) + func (repo *Repository) ReadTreeToIndex(treeish string) error + func (repo *Repository) RemoveFilesFromIndex(filenames ...string) error + func (repo *Repository) RemoveRemote(name string) error + func (repo *Repository) SetDefaultBranch(name string) error + func (repo *Repository) WriteTree() (*Tree, error) + type SHA1 = plumbing.Hash + func MustID(b []byte) SHA1 + func MustIDFromString(s string) SHA1 + func NewID(b []byte) (SHA1, error) + func NewIDFromString(s string) (SHA1, error) + type SearchCommitsOptions struct + After string + All bool + Authors []string + Before string + Committers []string + Keywords []string + func NewSearchCommitsOptions(searchString string, forAllRefs bool) SearchCommitsOptions + type Signature = object.Signature + type SubModule struct + Name string + URL string + type SubModuleFile struct + func NewSubModuleFile(c *Commit, refURL, refID string) *SubModuleFile + func (sf *SubModuleFile) RefID() string + func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string + type Tag struct + ID SHA1 + Message string + Name string + Object SHA1 + Tagger *Signature + Type string + func (tag *Tag) Commit() (*Commit, error) + type Tree struct + ID SHA1 + ResolvedID SHA1 + func NewTree(repo *Repository, id SHA1) *Tree + func (t *Tree) GetBlobByPath(relpath string) (*Blob, error) + func (t *Tree) GetTreeEntryByPath(relpath string) (*TreeEntry, error) + func (t *Tree) ListEntries() (Entries, error) + func (t *Tree) ListEntriesRecursive() (Entries, error) + func (t *Tree) SubTree(rpath string) (*Tree, error) + type TreeEntry struct + ID SHA1 + func ParseTreeEntries(data []byte) ([]*TreeEntry, error) + func (te *TreeEntry) Blob() *Blob + func (te *TreeEntry) FollowLink() (*TreeEntry, error) + func (te *TreeEntry) GetSubJumpablePathName() string + func (te *TreeEntry) IsDir() bool + func (te *TreeEntry) IsExecutable() bool + func (te *TreeEntry) IsLink() bool + func (te *TreeEntry) IsRegular() bool + func (te *TreeEntry) IsSubModule() bool + func (te *TreeEntry) Mode() EntryMode + func (te *TreeEntry) Name() string + func (te *TreeEntry) Size() int64 + func (te *TreeEntry) Type() string