Documentation

Overview

    Package git provides access to git repositories.

    Example
    Output:
    
    changed: go/example.go
    changed: php/crappy.php
    changed: vendor/foo.go
    

    Index

    Examples

    Constants

    This section is empty.

    Variables

    View Source
    var (
    	ErrRepositoryExists    = errors.NewKind("repository %s already exists")
    	ErrRepositoryNotExists = errors.NewKind("repository %s not exists")
    )
    View Source
    var ErrRefValidation = errors.NewKind("reference %v does not have a %s")

    Functions

    func NewChangeBlobScanner

    func NewChangeBlobScanner(ctx context.Context, scanner lookout.ChangeScanner, base, head *object.Tree) *lookout.FnChangeScanner

      NewChangeBlobScanner creates new FnChangeScanner

      func NewChangeFilterScanner

      func NewChangeFilterScanner(scanner lookout.ChangeScanner, include, exclude string) *lookout.FnChangeScanner

        NewChangeFilterScanner creates new FnChangeScanner

        func NewFileBlobScanner

        func NewFileBlobScanner(ctx context.Context, scanner lookout.FileScanner, tree *object.Tree) *lookout.FnFileScanner

          NewFileBlobScanner creates new FnFileScanner

          func NewFileFilterScanner

          func NewFileFilterScanner(ctx context.Context, scanner lookout.FileScanner, include, exclude string) *lookout.FnFileScanner

            NewFileFilterScanner creates new FnFileScanner

            Types

            type AuthProvider

            type AuthProvider interface {
            	// GitAuth returns a go-git auth method for a repo
            	GitAuth(ctx context.Context, repoInfo *lookout.RepositoryInfo) transport.AuthMethod
            }

              AuthProvider is an object that provides go-git auth methods

              type CommitLoader

              type CommitLoader interface {
              	LoadCommits(context.Context, ...lookout.ReferencePointer) (
              		[]*object.Commit, error)
              }

              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

                        Get get the requested repository based on the given URL.

                        func (*Library) GetOrInit

                        func (l *Library) GetOrInit(ctx context.Context, url *lookout.RepositoryInfo) (
                        	*git.Repository, error)

                          GetOrInit get the requested repository based on the given URL, or inits a new repository.

                          func (*Library) Has

                          func (l *Library) Has(url *lookout.RepositoryInfo) (bool, error)

                            Has returns true if a repository with the given URL exists.

                            func (*Library) Init

                              Init inits a new repository for the given URL.

                              type LibraryCommitLoader

                              type LibraryCommitLoader struct {
                              	Library ReposCollectionHandler
                              	Syncer  Syncer
                              }

                              func (*LibraryCommitLoader) LoadCommits

                              func (l *LibraryCommitLoader) LoadCommits(
                              	ctx context.Context, rps ...lookout.ReferencePointer) (
                              	[]*object.Commit, error)

                              type LibrarySyncer

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

                                LibrarySyncer syncs the local copy of git repository for a given CommitRevision.

                                func (*LibrarySyncer) Sync

                                  Sync syncs the local git repository to the given reference pointers.

                                  type Service

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

                                    Service implements data service interface on top of go-git

                                    func NewService

                                    func NewService(loader CommitLoader) *Service

                                      NewService creates new git Service

                                      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

                                          type StorerCommitLoader struct {
                                          	Storer storer.Storer
                                          }

                                          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 interface {
                                          	Sync(context.Context, ...lookout.ReferencePointer) error
                                          }

                                          func NewSyncer

                                          func NewSyncer(l *Library, authProvider AuthProvider, fetchTimeout time.Duration) Syncer

                                            NewSyncer returns a Syncer for the given Library. authProvider can be nil. A fetchTimeout of zero means no timeout.

                                            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