indexer

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2017 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SkipTooLargeBlob = fmt.Errorf("Blob should be skipped: Too large")
	SkipBinaryBlob   = fmt.Errorf("Blob should be skipped: binary")
)

Functions

func DetectBinary

func DetectBinary(data []byte) bool

DetectBinary checks whether the passed-in data contains a NUL byte. Only scan the start of large blobs. This is the same test performed by git to check text/binary

func DetectLanguage

func DetectLanguage(filename string, data []byte) string

DetectLanguage returns a string describing the language of the file. This is programming language, rather than natural language.

If no language is detected, "Text" is returned.

func GenerateBlobID

func GenerateBlobID(parentID, filename string) string

func GenerateCommitID

func GenerateCommitID(parentID, commitSHA string) string

func GenerateDate

func GenerateDate(t time.Time) string

Types

type Blob

type Blob struct {
	Type      string `json:"type"`
	ID        string `json:"-"`
	OID       string `json:"oid"`
	RepoID    string `json:"rid"`
	CommitSHA string `json:"commit_sha"`
	Content   string `json:"content"`
	Path      string `json:"path"`

	// Message copied from gitlab-elasticsearch-git:
	//
	// We're duplicating file_name parameter here because we need another
	// analyzer for it.
	//
	//Ideally this should be done with copy_to: 'blob.file_name' option
	//but it does not work in ES v2.3.*. We're doing it so to not make users
	//install newest versions
	//
	//https://github.com/elastic/elasticsearch-mapper-attachments/issues/124
	Filename string `json:"file_name"`

	Language string `json:"language"`
}

func BuildBlob

func BuildBlob(file *git.File, parentID, commitSHA string) (*Blob, error)

type Commit

type Commit struct {
	Type      string  `json:"type"`
	ID        string  `json:"-"`
	Author    *Person `json:"author"`
	Committer *Person `json:"committer"`
	RepoID    string  `json:"rid"`
	Message   string  `json:"message"`
	SHA       string  `json:"sha"`
}

func BuildCommit

func BuildCommit(c *git.Commit, parentID string) *Commit

type Indexer

type Indexer struct {
	git.Repository
	Submitter
}

func (*Indexer) Index

func (i *Indexer) Index() error

func (*Indexer) IndexBlobs

func (i *Indexer) IndexBlobs() error

func (*Indexer) IndexCommits

func (i *Indexer) IndexCommits() error

func (*Indexer) RemoveBlob

func (i *Indexer) RemoveBlob(file *git.File, _, _ string) error

func (*Indexer) SubmitBlob

func (i *Indexer) SubmitBlob(f *git.File, _, toCommit string) error

func (*Indexer) SubmitCommit

func (i *Indexer) SubmitCommit(c *git.Commit) error

type Person

type Person struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	Time  string `json:"time"` // %Y%m%dT%H%M%S%z
}

func BuildPerson

func BuildPerson(p git.Signature) *Person

type Submitter

type Submitter interface {
	ParentID() string

	Index(id string, thing interface{})
	Remove(id string)

	Flush() error
}

Jump to

Keyboard shortcuts

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