Categorygithub.com/src-d/gitbase
modulepackage
0.24.0-rc3
Repository: https://github.com/src-d/gitbase.git
Documentation: pkg.go.dev

# README

gitbase GitHub version Build Status codecov GoDoc Go Report Card

gitbase, is a SQL database interface to Git repositories.

This project is now part of source{d} Community Edition, which provides the simplest way to get started with a single command. Visit https://docs.sourced.tech/community-edition for more information.

It can be used to perform SQL queries about the Git history and about the Universal AST of the code itself. gitbase is being built to work on top of any number of git repositories.

gitbase implements the MySQL wire protocol, it can be accessed using any MySQL client or library from any language.

src-d/go-mysql-server is the SQL engine implementation used by gitbase.

Status

The project is currently in alpha stage, meaning it's still lacking performance in a number of cases but we are working hard on getting a performant system able to process thousands of repositories in a single node. Stay tuned!

Examples

You can see some query examples in gitbase documentation.

Motivation and scope

gitbase was born to ease the analysis of git repositories and their source code.

Also, making it MySQL compatible, we provide the maximum compatibility between languages and existing tools.

It comes as a single self-contained binary and it can be used as a standalone service. The service is able to process local repositories and integrates with existing tools and frameworks to simplify source code analysis on a large scale. The integration with Apache Spark is planned and is currently under active development.

Further reading

From here, you can directly go to getting started.

License

Apache License Version 2.0, see LICENSE

# Packages

# Functions

IsGitRepo checks that the given path is a git repository.
IsSivaFile checks that the given file is a siva file.
NewAllCommitBlobsIter returns all commit_blobs.
NewAllCommitFilesIter returns an iterator that will return all commit files.
NewAllCommitsIter returns an iterator that will return all commits that match the given filters.
NewAllCommitTreesIter returns all commit trees.
NewAllRefCommitsIter returns an iterator that will return all ref_commit rows.
NewAllRefsIter returns an iterator that will return all references that match the given filters.
NewAllRemotesIter returns an iterator that will return all remotes that match the given filters.
NewAllReposIter returns an iterator that will return all repositories that match the given filters.
NewAllTreeEntriesIter returns an iterator that will return all tree entries that match the given filters.
NewChainableRowIter converts a ChainableIter into a sql.RowIter.
NewCommitBlobBlobsIter returns the blobs for all commit blobs in the given iterator.
NewCommitBlobsIter returns an iterator that will return all commit blobs of each commit in the given iterator.
NewCommitFileBlobsIter returns all blobs for the commit files in the given iterator.
NewCommitFileFilesIter returns all files for the commit files in the given iterator.
NewCommitFilesIter returns an iterator that will return all commit files for the commits in the given iterator.
NewCommitMainTreeIter returns all main trees from the commits returned by the given commits iterator.
NewCommitTreesIter returns all trees from the commits returned by the given commits iterator.
NewDatabase creates a new Database structure and initializes its tables with the given pool.
NewIndexCommitBlobsIter returns an iterator that will return all results in the given index.
NewIndexCommitFilesIter returns an iterator that will return all commit files for the commits in the given index.
NewIndexCommitsIter returns an iterator that will return all results in the given index.
NewIndexCommitTreesIter returns an iterator that will return all results in the given index.
NewIndexRefCommitsIter returns an iterator that will return all results in the given index.
NewIndexRefsIter returns an iterator that will return all references that match the given filters in the given index.
NewIndexTreeEntriesIter returns an iterator that will return all results in the given index.
NewRefCommitCommitsIter returns an iterator that will return commits based on the ref_commits returned by the previous iterator.
NewRefHEADCommitsIter returns an iterator that will return the commit for the given iter reference heads that match the given filters.
NewRefHeadRefCommitsIter returns an iterator that will return all ref_commit rows of the HEAD commits in references of the given iterator.
NewRefRefCommitsIter returns an iterator that will return all ref_commits for all the references in the given iterator.
NewRemoteRefsIter returns an iterator that will return all references for the remotes returned by the given remotes iterator that match the given filters.
NewRepoBlobsIter returns an iterator that will return all blobs for the repositories in the given iter that match the given filters.
NewRepoCommitsIter is an iterator that returns all commits for the repositories returned by the given iterator.
NewRepoRefsIter returns an iterator that will return all references for the repositories of the given repos iterator that match the given filters.
NewRepoRemotesIter returns an iterator that will return all remotes for the given ReposIter repositories that match the given filters.
NewRepositoryPool holds a repository library and a shared object cache.
NewRepoTreeEntriesIter returns an iterator that will return all tree entries for every repo returned by the given iterator.
NewSchemaMapperIter reorders the rows in the given row iter according to the given column mappings.
NewSession creates a new Session.
NewSessionBuilder creates a SessionBuilder with the given Repository Pool.
NewSquashedTable creates a new SquashedTable.
NewTreeEntryBlobsIter returns an iterator that will return all blobs for the tree entries in the given iter that match the given filters.
NewTreeTreeEntriesIter returns an iterator that will return all tree entries for the trees returned by the given iterator.
PatternMatches returns the paths matched and any error found.
StripPrefix removes the root path from the given path.
WithBaseSession sets the given session as the base session.
WithBblfshEndpoint configures the bblfsh endpoint of the session.
WithSkipGitErrors changes the behavior with go-git error.

# Constants

BlobsTableName is the name of the blobs table.
CommitBlobsTableName is the name of the commit blobs table.
CommitFilesTableName is the name of the commit files table.
CommitsTableName is the name of the commits table.
CommitTreesTableName is the name of the commit trees table.
FilesTableName is the name of the files table.
RefCommitsTableName is the name of the ref commits table.
ReferencesTableName is the name of the refs table.
RemotesTableName is the name of the remotes table.
RepositoriesTableName is the name of the repositories table.
TreeEntriesTableName is the name of the tree entries table.

# Variables

BlobsSchema is the schema for the blobs table.
CommitBlobsSchema is the schema for the commit blobs table.
CommitFilesSchema is the schema for the commit trees table.
CommitsSchema is the schema for the commits table.
CommitTreesSchema is the schema for the commit trees table.
ErrBblfshConnection is returned when it's impossible to connect to bblfsh.
ErrColumnNotFound is returned when a given column is not found in the table's schema.
ErrInvalidContext is returned when some node expected an sql.Context with gitbase session but received something else.
ErrInvalidGitbaseSession is returned when some node expected a gitbase session but received something else.
ErrInvalidObjectType is returned when the received object is not of the correct type.
ErrNoRepositoryPartition is returned when the partition is not a valid repository partition.
ErrPoolRepoNotFound is returned when a repository id is not present in the pool.
ErrSessionCanceled is returned when session context is canceled.
FilesSchema is the schema for the files table.
RefCommitsSchema is the schema for the ref commits table.
RefsSchema is the schema for the refs table.
RegMatchChars matches a string with a glob expression inside.
RemotesSchema is the schema for the remotes table.
RepositoriesSchema is the schema for the repositories table.
TreeEntriesSchema is the schema for the tree entries table.

# Structs

BblfshClient is a wrapper around a bblfsh client to extend its functionality.
CommitFile is all the data needed to represent a file from a commit.
Database holds all git repository tables.
Ref is a git reference with the repo id.
Remote is the info of a single repository remote.
RepositoryIter iterates over all repositories in the pool.
RepositoryPool holds a pool git repository paths and functionality to open and iterate them.
Session is the custom implementation of a gitbase session.
SquashedTable is a table that combines the output of some tables as the inputs of others with chaining so it's less expensive to compute.
TreeEntry is a tree entry object.

# Interfaces

BlobsIter is a chainable iterator that operates on blobs.
ChainableIter is an iterator meant to have a chaining-friendly API.
CommitsIter is a chainable iterator that operates on commits.
FilesIter is a chainable iterator that operates on files.
Indexable represents an indexable gitbase table.
RefCommitsIter is a chainable iterator that operates on ref_commits.
RefsIter is a chainable iterator that operates on references.
RemotesIter is a chainable iterator that operates with remotes.
ReposIter is a chainable iterator that operates with repositories.
Squashable represents a table that can be squashed.
Table represents a gitbase table.
TreeEntriesIter is a chainable iterator that operates on Tree Entries.
TreesIter is a chainable iterator that operates on trees.

# Type aliases

RepositoryPartition represents a partition which is a repository id.
SessionOption is a function that configures the session given some options.