Git Repositories
The following tables access a git repository in the current directory by default.
If the --repo flag is specified, they will use the path provided there instead.
A parameter (usually the first) can also be provided to any of the tables below to override the default repo path.
For instance, SELECT * FROM commits('https://github.com/mergestat/mergestat') will clone this repo to a temporary directory on disk and return its commits.
commits
Similar to git log, the commits table includes all commits in the history of the currently checked out commit.
| Column | Type |
|---|---|
| hash | TEXT |
| message | TEXT |
| author_name | TEXT |
| author_email | TEXT |
| author_when | DATETIME |
| committer_name | TEXT |
| committer_email | TEXT |
| committer_when | DATETIME |
| parents | INT |
Params:
repository- path to a local (on disk) or remote (http(s)) repositoryrev- return commits starting at this revision (i.e. branch name or SHA), defaults toHEAD
-- return all commits starting at HEAD
SELECT * FROM commits
-- specify an alternative repo on disk
SELECT * FROM commits('/some/path/to/repo')
-- clone a remote repo and use it
SELECT * FROM commits('https://github.com/mergestat/mergestat')
-- use the default repo, but provide an alternate branch
SELECT * FROM commits('', 'some-ref')
refs
| Column | Type |
|---|---|
| name | TEXT |
| type | TEXT |
| remote | TEXT |
| full_name | TEXT |
| hash | TEXT |
| target | TEXT |
Params:
repository- path to a local (on disk) or remote (http(s)) repository
stats
| Column | Type |
|---|---|
| file_path | TEXT |
| additions | INT |
| deletions | INT |
Params:
repository- path to a local (on disk) or remote (http(s)) repositoryrev- commit hash (or branch/tag name) to use for retrieving stats, defaults toHEADto_rev- commit hash to calculate stats relative to
-- return stats of HEAD
SELECT * FROM stats
-- return stats of a specific commit
SELECT * FROM stats('', 'COMMIT_HASH')
-- return stats for every commit in the current history
SELECT commits.hash, stats.* FROM commits, stats('', commits.hash)
files
| Column | Type |
|---|---|
| path | TEXT |
| executable | BOOL |
| contents | TEXT |
Params:
repository- path to a local (on disk) or remote (http(s)) repositoryrev- commit hash (or branch/tag name) to use for retrieving files in, defaults toHEAD
blame
Similar to git blame, the blame table includes blame information for all files in the current HEAD.
| Column | Type |
|---|---|
| line_no | INT |
| commit_hash | TEXT |
Params:
repository- path to a local (on disk) or remote (http(s)) repositoryrev- commit hash (or branch/tag name) to use for retrieving blame information from, defaults toHEADfile_path- path of file to blame