cache

package
v0.0.0-...-e0a0d6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCache = filepath.Join(os.TempDir(), ".ghstats", "cache")

DefaultCache location for where to cache cloned/fetched repos

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Path() string
	Add(repo, url string) (err error)
	Stats(repo string) (commits int64, lines int64, err error)
}

Cache defines how all caching backends must behave. Caches are required to return stats.

type CommitIface

type CommitIface interface {
	// Tree returns the Tree from the commit.
	Tree() (*object.Tree, error)
	// Patch returns the Patch between the actual commit and the provided one.
	// Error will be return if context expires. Provided context must be non-nil
	PatchContext(ctx context.Context, to *object.Commit) (*object.Patch, error)
	// Patch returns the Patch between the actual commit and the provided one.
	Patch(to *object.Commit) (*object.Patch, error)
	// Parents return a CommitIter to the parent Commits.
	Parents() object.CommitIter
	// NumParents returns the number of parents in a commit.
	NumParents() int
	// Parent returns the ith parent of a commit.
	Parent(i int) (*object.Commit, error)
	// File returns the file with the specified "path" in the commit and a
	// nil error if the file exists. If the file does not exist, it returns
	// a nil file and the ErrFileNotFound error.
	File(path string) (*object.File, error)
	// Files returns a FileIter allowing to iterate over the Tree
	Files() (*object.FileIter, error)
	// ID returns the object ID of the commit. The returned value will always match
	// the current value of Commit.Hash.
	//
	// ID is present to fulfill the Object interface.
	ID() plumbing.Hash
	// Type returns the type of object. It always returns plumbing.CommitObject.
	//
	// Type is present to fulfill the Object interface.
	Type() plumbing.ObjectType
	// Decode transforms a plumbing.EncodedObject into a Commit struct.
	Decode(o plumbing.EncodedObject) (err error)
	// Encode transforms a Commit into a plumbing.EncodedObject.
	Encode(o plumbing.EncodedObject) error
	// Stats shows the status of commit.
	Stats() (object.FileStats, error)
	String() string
	// Verify performs PGP verification of the commit with a provided armored
	// keyring and returns openpgp.Entity associated with verifying key on success.
	Verify(armoredKeyRing string) (*openpgp.Entity, error)
}

CommitIface is interface for Commits since go-git doesn't provide an interface.

type GitCache

type GitCache struct {
	// contains filtered or unexported fields
}

GitCache will store, and process git repos and return stats for serving by the StatsServer

func NewGitCache

func NewGitCache(basepath string) (gc *GitCache)

NewGitCache returns a GitCache object in the location of "basepath". If basepath is zero value then the DefaultCache variable will be used.

func (*GitCache) Add

func (gc *GitCache) Add(reponame, url string) (err error)

Add will add a given repo's name and it's clone URL to the cache for later processing

func (*GitCache) Path

func (gc *GitCache) Path() string

Path returns the basepath location

func (*GitCache) Stats

func (gc *GitCache) Stats(reponame string) (commits int64, lines int64, err error)

Stats processes a given reponame for stats and returns the number of commits and lines of matched members, or domains.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL