Documentation ¶
Overview ¶
Package git provides access to git repositories.
Example ¶
if err := fixtures.Init(); err != nil { panic(err) } defer fixtures.Clean() fixture := fixtures.Basic().One() fs := fixture.DotGit() storer, err := filesystem.NewStorage(fs) if err != nil { panic(err) } // Create the git service with a repository loader that allows it to find // a repository by ID. srv := NewService(&StorerCommitLoader{storer}) changes, err := srv.GetChanges(context.Background(), &lookout.ChangesRequest{ Base: &lookout.ReferencePointer{ InternalRepositoryURL: "file:///myrepo", Hash: "af2d6a6954d532f8ffb47615169c8fdf9d383a1a", }, Head: &lookout.ReferencePointer{ InternalRepositoryURL: "file:///myrepo", Hash: "6ecf0ef2c2dffb796033e5a02219af86ec6584e5", }, }) if err != nil { panic(err) } for changes.Next() { change := changes.Change() fmt.Printf("changed: %s\n", change.Head.Path) } if err := changes.Err(); err != nil { panic(err) } if err := changes.Close(); err != nil { panic(err) }
Output: changed: go/example.go changed: php/crappy.php changed: vendor/foo.go
Index ¶
- Variables
- func NewChangeBlobScanner(scanner lookout.ChangeScanner, base, head *object.Tree) *lookout.FnChangeScanner
- func NewChangeExcludeVendorScanner(scanner lookout.ChangeScanner) *lookout.FnChangeScanner
- func NewChangeFilterScanner(scanner lookout.ChangeScanner, include, exclude string) *lookout.FnChangeScanner
- func NewFileBlobScanner(scanner lookout.FileScanner, tree *object.Tree) *lookout.FnFileScanner
- func NewFileExcludeVendorScanner(scanner lookout.FileScanner) *lookout.FnFileScanner
- func NewFileFilterScanner(scanner lookout.FileScanner, include, exclude string) *lookout.FnFileScanner
- type CommitLoader
- type DiffTreeScanner
- type Library
- type LibraryCommitLoader
- type Service
- type StorerCommitLoader
- type Syncer
- type TreeScanner
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrRepositoryExists = errors.NewKind("repository %s already exists") ErrRepositoryNotExists = errors.NewKind("repository %s not exists") )
Functions ¶
func NewChangeBlobScanner ¶
func NewChangeBlobScanner(scanner lookout.ChangeScanner, base, head *object.Tree) *lookout.FnChangeScanner
NewChangeBlobScanner creates new FnChangeScanner
func NewChangeExcludeVendorScanner ¶
func NewChangeExcludeVendorScanner(scanner lookout.ChangeScanner) *lookout.FnChangeScanner
NewChangeExcludeVendorScanner creates new FnChangeScanner
func NewChangeFilterScanner ¶
func NewChangeFilterScanner(scanner lookout.ChangeScanner, include, exclude string) *lookout.FnChangeScanner
NewChangeFilterScanner creates new FnChangeScanner
func NewFileBlobScanner ¶
func NewFileBlobScanner(scanner lookout.FileScanner, tree *object.Tree) *lookout.FnFileScanner
NewFileBlobScanner creates new FnFileScanner
func NewFileExcludeVendorScanner ¶
func NewFileExcludeVendorScanner(scanner lookout.FileScanner) *lookout.FnFileScanner
NewFileExcludeVendorScanner creates new FnFileScanner
func NewFileFilterScanner ¶
func NewFileFilterScanner(scanner lookout.FileScanner, include, exclude string) *lookout.FnFileScanner
NewFileFilterScanner creates new FnFileScanner
Types ¶
type CommitLoader ¶
type DiffTreeScanner ¶
type DiffTreeScanner struct {
// contains filtered or unexported fields
}
DiffTreeScanner is a scanner for files of diff between git trees
func NewDiffTreeScanner ¶
func NewDiffTreeScanner(base, head *object.Tree) *DiffTreeScanner
NewDiffTreeScanner creates new DiffTreeScanner
func (*DiffTreeScanner) Change ¶
func (s *DiffTreeScanner) Change() *lookout.Change
func (*DiffTreeScanner) Close ¶
func (s *DiffTreeScanner) Close() error
func (*DiffTreeScanner) Err ¶
func (s *DiffTreeScanner) Err() error
func (*DiffTreeScanner) Next ¶
func (s *DiffTreeScanner) Next() bool
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library controls the persistence of multiple git repositories.
func NewLibrary ¶
func NewLibrary(fs billy.Filesystem) *Library
NewLibrary creates a new Library based on the given filesystem.
func (*Library) Get ¶
func (l *Library) Get(url *lookout.RepositoryInfo) (*git.Repository, error)
Get get the requested repository based on the given URL.
func (*Library) GetOrInit ¶
func (l *Library) GetOrInit(url *lookout.RepositoryInfo) ( *git.Repository, error)
GetOrInit get the requested repository based on the given URL, or inits a new repository.
type LibraryCommitLoader ¶
func NewLibraryCommitLoader ¶
func NewLibraryCommitLoader(l *Library, s *Syncer) *LibraryCommitLoader
func (*LibraryCommitLoader) LoadCommits ¶
func (l *LibraryCommitLoader) LoadCommits( ctx context.Context, rps ...lookout.ReferencePointer) ( []*object.Commit, error)
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements data service interface on top of go-git
func (*Service) GetChanges ¶
func (r *Service) GetChanges(ctx context.Context, req *lookout.ChangesRequest) ( lookout.ChangeScanner, error)
GetChanges returns a ChangeScanner that scans all changes according to the request.
func (*Service) GetFiles ¶
func (r *Service) GetFiles(ctx context.Context, req *lookout.FilesRequest) ( lookout.FileScanner, error)
GetFiles returns a FilesScanner that scans all files according to the request.
type StorerCommitLoader ¶
func NewStorerCommitLoader ¶
func NewStorerCommitLoader(storer storer.Storer) *StorerCommitLoader
func (*StorerCommitLoader) LoadCommits ¶
func (l *StorerCommitLoader) LoadCommits(ctx context.Context, rps ...lookout.ReferencePointer) ([]*object.Commit, error)
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer syncs the local copy of git repository for a given CommitRevision.
type TreeScanner ¶
type TreeScanner struct {
// contains filtered or unexported fields
}
TreeScanner is a scanner for files of git tree
func NewTreeScanner ¶
func NewTreeScanner(tree *object.Tree) *TreeScanner
NewTreeScanner creates new TreeScanner
func (*TreeScanner) Change ¶
func (s *TreeScanner) Change() *lookout.Change
func (*TreeScanner) Close ¶
func (s *TreeScanner) Close() error
func (*TreeScanner) Err ¶
func (s *TreeScanner) Err() error
func (*TreeScanner) File ¶
func (s *TreeScanner) File() *lookout.File
func (*TreeScanner) Next ¶
func (s *TreeScanner) Next() bool