diff --git a/Dockerfile b/Dockerfile
index ccea5975..7b1b5d72 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,12 +6,12 @@ RUN ./install_libgit2.sh
COPY go.mod go.sum ./
RUN go mod download
COPY . .
-RUN make build
+RUN make
FROM debian:buster-slim
WORKDIR /app/
RUN mkdir /repo
-COPY --from=builder /app/askgit .
+COPY --from=builder /app/.build/askgit .
RUN apt-get update && apt-get install -y git
diff --git a/Makefile b/Makefile
index e4c84d33..a180d365 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: clean vet test lint lint-ci test-cover bench
+.PHONY: clean update vet test lint lint-ci test-cover bench
# default task invoked while running make
all: clean .build/libaskgit.so .build/askgit
@@ -45,6 +45,9 @@ clean:
# go build tags used by test, vet and more
TAGS = "sqlite_vtable,vtable,sqlite_json1,static,system_libgit2"
+update:
+ go get -tags=$(TAGS) -u ./...
+
vet:
go vet -v -tags=$(TAGS) ./...
diff --git a/README.md b/README.md
index 9d066ad7..11417329 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,7 @@
[![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/askgitdev/askgit/main)](https://www.tickgit.com/browse?repo=github.com/askgitdev/askgit&branch=main)
[![codecov](https://codecov.io/gh/askgitdev/askgit/branch/main/graph/badge.svg)](https://codecov.io/gh/askgitdev/askgit)
-
-# askgit
+# askgit
`askgit` is a command-line tool for running SQL queries on git repositories.
It's meant for ad-hoc querying of git repositories on disk through a common interface (SQL), as an alternative to patching together various shell commands.
@@ -17,33 +16,8 @@ SELECT count(*) FROM commits WHERE author_email = 'user@email.com'
You can try queries on public git repositories without installing anything at [https://try.askgit.com/](https://try.askgit.com/)
-There's also preliminary support for executing queries against the GitHub API.
-
More in-depth examples and documentation can be found below.
-- [Installation](#installation)
- - [Homebrew](#homebrew)
- - [Go](#go)
- - [Using Docker](#using-docker)
- - [Running commands](#running-commands)
- - [Running commands from STDIN](#running-commands-from-stdin)
-- [Usage](#usage)
- - [Tables](#tables)
- - [Local Git Repository](#local-git-repository)
- - [`commits`](#commits)
- - [`blame`](#blame)
- - [`stats`](#stats)
- - [`files`](#files)
- - [`branches`](#branches)
- - [`tags`](#tags)
- - [GitHub Tables](#github-tables)
- - [`github_org_repos` and `github_user_repos`](#github_org_repos-and-github_user_repos)
- - [`github_pull_requests`](#github_pull_requests)
- - [`github_issues`](#github_issues)
- - [Example Queries](#example-queries)
- - [Interactive mode](#interactive-mode)
- - [Exporting](#exporting)
-
## Installation
### Homebrew
@@ -55,18 +29,25 @@ brew install askgit
### Go
+[`libgit2`](https://libgit2.org/) is a build dependency (used via [`git2go`](https://github.com/libgit2/git2go)) and must be available on your system for linking.
+
+The following (long 😬) `go install` commands can be used to install a binary via the go toolchain.
+
+On Mac:
```
-go get -v -tags=sqlite_vtable github.com/askgitdev/askgit
+CGO_CFLAGS=-DUSE_LIBSQLITE3 CGO_LDFLAGS=-Wl,-undefined,dynamic_lookup go install -tags="sqlite_vtable,vtable,sqlite_json1,static,system_libgit2" github.com/askgitdev/askgit@latest
```
-Will use the go tool chain to install a binary to `$GOBIN`.
-
+On Linux:
```
-GOBIN=$(pwd) go get -v -tags=sqlite_vtable github.com/askgitdev/askgit
+CGO_CFLAGS=-DUSE_LIBSQLITE3 CGO_LDFLAGS=-Wl,--unresolved-symbols=ignore-in-object-files go install -tags="sqlite_vtable,vtable,sqlite_json1,static,system_libgit2" github.com/askgitdev/askgit@latest
```
-Will produce a binary in your current directory.
+See the [`Makefile`](https://github.com/askgitdev/askgit/blob/main/Makefile) for more context.
+Checking out this repository and running `make` in the root will produce two files in the `.build` directory:
+ 1. `askgit` - the CLI binary (which can then be moved into your `$PATH` for use)
+ 2. `libaskgit.so` - a shared object file [SQLite extension](https://www.sqlite.org/loadext.html) that can be used by SQLite directly
### Using Docker
@@ -127,11 +108,14 @@ By default, output will be an ASCII table.
Use `--format json` or `--format csv` for alternatives.
See `-h` for all the options.
-### Tables
+### Tables and Functions
#### Local Git Repository
-When a repo is specified (either by the `--repo` flag or from the current directory), the following tables are available to query.
+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/askgitdev/askgit')` will clone this repo to a temporary directory on disk and return its commits.
##### `commits`
@@ -139,211 +123,169 @@ Similar to `git log`, the `commits` table includes all commits in the history of
| Column | Type |
|-----------------|----------|
-| id | TEXT |
+| hash | TEXT |
| message | TEXT |
-| summary | TEXT |
| author_name | TEXT |
| author_email | TEXT |
| author_when | DATETIME |
| committer_name | TEXT |
| committer_email | TEXT |
| committer_when | DATETIME |
-| parent_id | TEXT |
-| parent_count | INT |
+| parents | INT |
-##### `blame`
+Params:
+ 1. `repository` - path to a local (on disk) or remote (http(s)) repository
+ 2. `ref` - return commits starting at this ref (i.e. branch name or SHA), defaults to `HEAD`
-Similar to `git blame`, the `blame` table includes blame information for all files in the current HEAD.
+```sql
+-- 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/askgitdev/askgit')
-| Column | Type |
-|--------------|----------|
-| line_no | INT |
-| file_path | TEXT |
-| commit_id | TEXT |
-| line_content | TEXT |
+-- 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:
+ 1. `repository` - path to a local (on disk) or remote (http(s)) repository
##### `stats`
| Column | Type |
|-----------|------|
-| commit_id | TEXT |
| file_path | TEXT |
| additions | INT |
| deletions | INT |
-##### `files`
+Params:
+ 1. `repository` - path to a local (on disk) or remote (http(s)) repository
+ 2. `ref` - commit hash to use for retrieving stats, defaults to `HEAD`
+ 3. `to_ref` - commit hash to calculate stats relative to
+
+```sql
+-- return stats of HEAD
+SELECT * FROM stats
-The `files` table iterates over _ALL_ the files in a commit history, by default from what's checked out in the repository.
-The full table is every file in every tree of a commit history.
-Use the `commit_id` column to filter for files that belong to the work tree of a specific commit.
+-- 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 |
|------------|------|
-| commit_id | TEXT |
| path | TEXT |
-| contents | TEXT |
| executable | BOOL |
+| contents | TEXT |
+Params:
+ 1. `repository` - path to a local (on disk) or remote (http(s)) repository
+ 2. `ref` - commit hash to use for retrieving files, defaults to `HEAD`
-##### `branches`
+##### `blame`
-| Column | Type |
-|--------|------|
-| name | TEXT |
-| remote | BOOL |
-| target | TEXT |
-| head | BOOL |
+Similar to `git blame`, the `blame` table includes blame information for all files in the current HEAD.
-##### `tags`
+| Column | Type |
+|-------------|----------|
+| line_no | INT |
+| commit_hash | TEXT |
-| Column | Type |
-|--------------|------|
-| full_name | TEXT |
-| name | TEXT |
-| lightweight | BOOL |
-| target | TEXT |
-| tagger_name | TEXT |
-| tagger_email | TEXT |
-| message | TEXT |
-| target_type | TEXT |
+Params:
+ 1. `repository` - path to a local (on disk) or remote (http(s)) repository
+ 2. `ref` - commit hash to use for retrieving files, defaults to `HEAD`
+ 3. `file_path` - path of file to blame
-#### GitHub Tables
+#### Utilities
-**This functionality is under development and likely to change**
+##### JSON
-The following tables make GitHub API requests to retrieve data during query execution.
-As such, you should ensure the `GITHUB_TOKEN` environment variable is set so that API requests are authenticated.
-Unauthenticated API requests (no `GITHUB_TOKEN`) are subject to a stricter rate limit by GitHub, and may take longer to execute (query execution will try to respect the applicable rate limit).
+The [SQLite JSON1 extension](https://www.sqlite.org/json1.html) is included for working with JSON data.
-##### `github_org_repos` and `github_user_repos`
+##### `toml_json`
-These tables can be queried as table-valued functions expecting a single parameter, like so:
+Scalar function that converts `toml` to `json`.
-```sql
--- return all repos from a github *org*
-SELECT * FROM github_org_repos('askgitdev')
-
--- return all repos from a github *user*
-SELECT * FROM github_user_repos('askgitdev')
-```
-
-| Column | Type |
-|-------------------|----------|
-| id | INT |
-| node_id | TEXT |
-| name | TEXT |
-| full_name | TEXT |
-| owner | TEXT |
-| private | BOOL |
-| description | TEXT |
-| fork | BOOL |
-| homepage | TEXT |
-| language | TEXT |
-| forks_count | INT |
-| stargazers_count | INT |
-| watchers_count | INT |
-| size | INT |
-| default_branch | TEXT |
-| open_issues_count | INT |
-| topics | TEXT |
-| has_issues | BOOL |
-| has_projects | BOOL |
-| has_wiki | BOOL |
-| has_pages | BOOL |
-| has_downloads | BOOL |
-| archived | BOOL |
-| pushed_at | DATETIME |
-| created_at | DATETIME |
-| updated_at | DATETIME |
-| permissions | TEXT |
-
-##### `github_pull_requests`
-
-This table expects 2 parameters, `github_pull_requests('askgitdev', 'askgit')`:
+```SQL
+SELECT toml_to_json('[some-toml]')
+
+-- +-----------------------------+
+-- | TOML_TO_JSON('[SOME-TOML]') |
+-- +-----------------------------+
+-- | {"some-toml":{}} |
+-- +-----------------------------+
+```
+
+##### `xml_to_json`
+
+Scalar function that converts `xml` to `json`.
+
+```SQL
+SELECT xml_to_json('hello')
+
+-- +-------------------------------------------+
+-- | XML_TO_JSON('HELLO') |
+-- +-------------------------------------------+
+-- | {"some-xml":"hello"} |
+-- +-------------------------------------------+
+```
+
+##### `yaml_to_json` and `yml_to_json`
+
+Scalar function that converts `yaml` to `json`.
+
+```SQL
+SELECT yaml_to_json('hello: world')
+
+-- +------------------------------+
+-- | YAML_TO_JSON('HELLO: WORLD') |
+-- +------------------------------+
+-- | {"hello":"world"} |
+-- +------------------------------+
+```
+
+##### `str_split`
+
+Helper for splitting strings on some separator.
```sql
-SELECT count(*) FROM github_pull_requests('askgitdev', 'askgit') WHERE state = 'open'
-```
-
-| Column | Type |
-|---------------------------|----------|
-| id | INT |
-| node_id | TEXT |
-| number | INT |
-| state | TEXT |
-| locked | BOOL |
-| title | TEXT |
-| user_login | TEXT |
-| body | TEXT |
-| labels | TEXT |
-| active_lock_reason | TEXT |
-| created_at | DATETIME |
-| updated_at | DATETIME |
-| closed_at | DATETIME |
-| merged_at | DATETIME |
-| merge_commit_sha | TEXT |
-| assignee_login | TEXT |
-| assignees | TEXT |
-| requested_reviewer_logins | TEXT |
-| head_label | TEXT |
-| head_ref | TEXT |
-| head_sha | TEXT |
-| head_repo_owner | TEXT |
-| head_repo_name | TEXT |
-| base_label | TEXT |
-| base_ref | TEXT |
-| base_sha | TEXT |
-| base_repo_owner | TEXT |
-| base_repo_name | TEXT |
-| author_association | TEXT |
-| merged | BOOL |
-| mergeable | BOOL |
-| mergeable_state | BOOL |
-| merged_by_login | TEXT |
-| comments | INT |
-| maintainer_can_modify | BOOL |
-| commits | INT |
-| additions | INT |
-| deletions | INT |
-| changed_files | INT |
-
-##### `github_issues`
-
-This table expects 2 parameters, `github_issues('askgitdev', 'askgit')`:
+SELECT str_split('hello,world', ',', 0)
+
+-- +----------------------------------+
+-- | STR_SPLIT('HELLO,WORLD', ',', 0) |
+-- +----------------------------------+
+-- | hello |
+-- +----------------------------------+
+```
```sql
-SELECT count(*) FROM github_issues('askgitdev', 'askgit') WHERE state = 'open'
-```
-
-
-| Column | Type |
-|---------------------------|----------|
-| id | INT |
-| node_id | TEXT |
-| number | INT |
-| state | TEXT |
-| locked | BOOL |
-| title | TEXT |
-| user_login | TEXT |
-| body | TEXT |
-| labels | TEXT |
-| active_lock_reason | TEXT |
-| created_at | DATETIME |
-| updated_at | DATETIME |
-| closed_at | DATETIME |
-| merged_at | DATETIME |
-| merge_commit_sha | TEXT |
-| assignee_login | TEXT |
-| assignees | TEXT |
-| url | TEXT |
-| html_url | TEXT |
-| comments_url | TEXT |
-| events_url | TEXT |
-| repository_url | TEXT |
-| comments | INT |
-| milestone | TEXT |
-| reactions | INT |
+SELECT str_split('hello,world', ',', 1)
+
+-- +----------------------------------+
+-- | STR_SPLIT('HELLO,WORLD', ',', 1) |
+-- +----------------------------------+
+-- | world |
+-- +----------------------------------+
+```
### Example Queries
@@ -365,38 +307,24 @@ SELECT author_email, count(*) FROM commits GROUP BY author_email ORDER BY count(
Same as above, but excluding merge commits:
```sql
-SELECT author_email, count(*) FROM commits WHERE parent_count < 2 GROUP BY author_email ORDER BY count(*) DESC
+SELECT author_email, count(*) FROM commits WHERE parents < 2 GROUP BY author_email ORDER BY count(*) DESC
```
-This is an expensive query.
-It will iterate over every file in every tree of every commit in the current history:
+Outputs the set of files in the current tree:
```sql
SELECT * FROM files
```
-Outputs the set of files in the tree of a certain commit:
-```sql
-SELECT * FROM files WHERE commit_id='some_commit_id'
-```
-
-
-Same as above if you just have the commit short id:
-```sql
-SELECT * FROM files WHERE commit_id LIKE 'shortened_commit_id%'
-```
-
-
Returns author emails with lines added/removed, ordered by total number of commits in the history (excluding merges):
```sql
-SELECT count(DISTINCT commits.id) AS commits, SUM(additions) AS additions, SUM(deletions) AS deletions, author_email
-FROM commits LEFT JOIN stats ON commits.id = stats.commit_id
-WHERE commits.parent_count < 2
+SELECT count(DISTINCT commits.hash) AS commits, SUM(additions) AS additions, SUM(deletions) AS deletions, author_email
+FROM commits LEFT JOIN stats('', commits.hash)
+WHERE commits.parents < 2
GROUP BY author_email ORDER BY commits
```
-
Returns commit counts by author, broken out by day of the week:
```sql
@@ -413,14 +341,6 @@ SELECT
FROM commits GROUP BY author_email ORDER BY commits
```
-
-#### Interactive mode
-```
-askgit --interactive
-```
-
-Will display a basic terminal UI for composing and executing queries, powered by [gocui](https://github.com/jroimartin/gocui).
-
#### Exporting
You can use the `askgit export` sub command to save the output of queries into a sqlite database file.
diff --git a/cmd/export.go b/cmd/export.go
index 66d7f606..2e05f7fa 100644
--- a/cmd/export.go
+++ b/cmd/export.go
@@ -1,12 +1,11 @@
package cmd
import (
- "errors"
+ "database/sql"
"fmt"
- "os"
+ "log"
"path/filepath"
- "github.com/askgitdev/askgit/pkg/askgit"
"github.com/spf13/cobra"
)
@@ -28,12 +27,14 @@ var exportCmd = &cobra.Command{
Long: `Use this command to export queries into a SQLite database file on disk`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
+ var err error
+
if len(exports) == 0 {
- handleError(errors.New("please supply at least one export pair"))
+ log.Fatal("please supply at least one export pair")
}
if len(exports)%2 != 0 {
- handleError(fmt.Errorf("expected even number of export pairs, got %d", len(exports)))
+ log.Fatalf("expected even number of export pairs, got %d", len(exports))
}
pairs := make([]export, len(exports)/2)
@@ -45,25 +46,21 @@ var exportCmd = &cobra.Command{
}
}
- exportFile, err := filepath.Abs(args[0])
- handleError(err)
-
- dir, cleanup := determineRepo()
- defer cleanup()
+ var fileName string
+ if fileName, err = filepath.Abs(args[0]); err != nil {
+ log.Fatalf("failed to resolve file path: %v", err)
+ }
- ag, err := askgit.New(&askgit.Options{
- RepoPath: dir,
- UseGitCLI: useGitCLI,
- GitHubToken: os.Getenv("GITHUB_TOKEN"),
- DBFilePath: exportFile,
- })
- handleError(err)
+ var db *sql.DB
+ if db, err = sql.Open("sqlite3", fileName); err != nil {
+ log.Fatalf("failed to open sqlite database: %v", err)
+ }
for _, pair := range pairs {
- s := fmt.Sprintf("CREATE TABLE %s AS %s", pair.table, pair.query)
-
- _, err := ag.DB().Exec(s)
- handleError(err)
+ var query = fmt.Sprintf("CREATE TABLE %s AS %s", pair.table, pair.query)
+ if _, err = db.Exec(query); err != nil {
+ log.Fatalf("failed to execute query: %v", err)
+ }
}
},
diff --git a/cmd/root.go b/cmd/root.go
index d19e14e6..bdada58e 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -1,153 +1,93 @@
package cmd
import (
- "bufio"
- "fmt"
+ "database/sql"
"io/ioutil"
+ "log"
"os"
- "path/filepath"
- "github.com/askgitdev/askgit/pkg/askgit"
- "github.com/askgitdev/askgit/pkg/tui"
- "github.com/gitsight/go-vcsurl"
- git "github.com/libgit2/git2go/v31"
+ "github.com/askgitdev/askgit/pkg/display"
+ . "github.com/askgitdev/askgit/pkg/query"
"github.com/spf13/cobra"
)
-//define flags in here
-var (
- repo string
- format string
- useGitCLI bool
- cui bool
- presetQuery string
-)
+var format string // output format flag
+var presetQuery string // named / preset query flag
+var repo string // path to repo on disk
func init() {
- // global flags
- rootCmd.PersistentFlags().StringVarP(&repo, "repo", "r", ".", "path to git repository (defaults to current directory).\nA remote repo may be specified, it will be cloned to a temporary directory before query execution.")
- rootCmd.PersistentFlags().BoolVar(&useGitCLI, "use-git-cli", false, "whether to use the locally installed git command (if it's available). Defaults to false.")
-
// local (root command only) flags
rootCmd.Flags().StringVarP(&format, "format", "f", "table", "specify the output format. Options are 'csv' 'tsv' 'table' 'single' and 'json'")
- rootCmd.Flags().BoolVarP(&cui, "interactive", "i", false, "whether to run in interactive mode, which displays a terminal UI")
rootCmd.Flags().StringVarP(&presetQuery, "preset", "p", "", "used to pick a preset query")
+ rootCmd.Flags().StringVarP(&repo, "repo", "r", ".", "specify a path to a default repo on disk. This will be used if no repo is supplied as an argument to a git table")
- // add the export sub command
- rootCmd.AddCommand(exportCmd)
-}
-
-func handleError(err error) {
- if err != nil {
- fmt.Println(err)
- os.Exit(1)
- }
-}
-
-func determineRepo() (string, func()) {
- // the directory on disk of the repository
- var dir string
-
- cwd, err := os.Getwd()
- handleError(err)
-
- // if a repo path is not supplied as a flag, use the current directory
- if repo == "" {
- repo = cwd
+ // register the sqlite extension ahead of any command
+ rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
+ registerExt()
}
- // if the repo can be parsed as a remote git url, clone it to a temporary directory and use that as the repo path
- if remote, err := vcsurl.Parse(repo); err == nil { // if it can be parsed
- dir, err = ioutil.TempDir("", "repo")
- handleError(err)
-
- cloneOptions := askgit.CreateAuthenticationCallback(remote)
- _, err = git.Clone(repo, dir, cloneOptions)
- handleError(err)
-
- dir, err = filepath.Abs(dir)
- handleError(err)
-
- return dir, func() {
- err := os.RemoveAll(dir)
- handleError(err)
- }
- } else {
- dir, err = filepath.Abs(repo)
- handleError(err)
-
- return dir, func() {}
- }
+ // add the export sub command
+ rootCmd.AddCommand(exportCmd)
}
var rootCmd = &cobra.Command{
- Use: `askgit "SELECT * FROM commits"`,
+ Use: `display "SELECT * FROM commits"`,
Args: cobra.MaximumNArgs(2),
Long: `
askgit is a CLI for querying git repositories with SQL, using SQLite virtual tables.
Example queries can be found in the GitHub repo: https://github.com/askgitdev/askgit`,
Short: `query your github repos with SQL`,
Run: func(cmd *cobra.Command, args []string) {
- info, err := os.Stdin.Stat()
- handleError(err)
+ var err error
+
+ var info os.FileInfo
+ if info, err = os.Stdin.Stat(); err != nil {
+ log.Fatalf("failed to read stdin stat: %v", err)
+ }
var query string
if len(args) > 0 {
query = args[0]
- } else if info.Mode()&os.ModeCharDevice == 0 {
- query, err = readStdin()
- handleError(err)
- } else if cui {
- query = ""
+ } else if isPiped(info) {
+ var stdin []byte
+ if stdin, err = ioutil.ReadAll(os.Stdin); err != nil {
+ log.Fatalf("failed to read from stdin: %v", err)
+ }
+ query = string(stdin)
} else if presetQuery != "" {
- if val, ok := tui.Queries[presetQuery]; ok {
- query = val
- } else {
- handleError(fmt.Errorf("Unknown Preset Query: %s", presetQuery))
+ var found bool
+ if query, found = Find(presetQuery); !found {
+ log.Fatalf("unknown preset query: %s", presetQuery)
}
} else {
- err = cmd.Help()
- handleError(err)
+ if err = cmd.Help(); err != nil {
+ log.Fatal(err.Error())
+ }
os.Exit(0)
}
- dir, cleanup := determineRepo()
- defer cleanup()
-
- ag, err := askgit.New(&askgit.Options{
- RepoPath: dir,
- UseGitCLI: useGitCLI,
- GitHubToken: os.Getenv("GITHUB_TOKEN"),
- QueryOnly: true,
- })
- handleError(err)
-
- if cui {
- tui.RunGUI(ag, query)
- return
+ var db *sql.DB
+ if db, err = sql.Open("sqlite3", ":memory:"); err != nil {
+ log.Fatalf("failed to initialize database connection: %v", err)
}
- rows, err := ag.DB().Query(query)
- handleError(err)
+ var rows *sql.Rows
+ if rows, err = db.Query(query); err != nil {
+ log.Fatalf("query execution failed: %v", err)
+ }
+ defer rows.Close()
- err = askgit.DisplayDB(rows, os.Stdout, format, false)
- handleError(err)
+ if err = display.WriteTo(rows, os.Stdout, format, false); err != nil {
+ log.Fatalf("failed to output resultset: %v", err)
+ }
},
}
-// Execute runs the root command
+func isPiped(info os.FileInfo) bool { return info.Mode()&os.ModeCharDevice == 0 }
+
+// Execute executes the root command
func Execute() {
if err := rootCmd.Execute(); err != nil {
- handleError(err)
- }
-}
-
-func readStdin() (string, error) {
- reader := bufio.NewReader(os.Stdin)
- output, err := ioutil.ReadAll(reader)
- if err != nil {
- return "", err
+ log.Fatalf("execution failed: %v", err)
}
- returnString := string(output)
- return returnString, nil
}
diff --git a/cmd/setup.go b/cmd/setup.go
new file mode 100644
index 00000000..b4614577
--- /dev/null
+++ b/cmd/setup.go
@@ -0,0 +1,21 @@
+package cmd
+
+import (
+ "github.com/askgitdev/askgit/pkg/locator"
+ "github.com/askgitdev/askgit/tables"
+ "go.riyazali.net/sqlite"
+
+ // bring in sqlite 🙌
+ _ "github.com/askgitdev/askgit/pkg/sqlite"
+ _ "github.com/mattn/go-sqlite3"
+)
+
+func registerExt() {
+ sqlite.Register(
+ tables.RegisterFn(
+ tables.WithExtraFunctions(),
+ tables.WithRepoLocator(locator.CachedLocator(locator.MultiLocator())),
+ tables.WithContextValue("defaultRepoPath", repo),
+ ),
+ )
+}
diff --git a/go.mod b/go.mod
index 45b475de..5409e9b9 100644
--- a/go.mod
+++ b/go.mod
@@ -5,33 +5,28 @@ go 1.13
require (
github.com/BurntSushi/toml v0.3.1
github.com/DATA-DOG/go-sqlmock v1.5.0
- github.com/augmentable-dev/tickgit v0.0.14
- github.com/clbanning/mxj/v2 v2.5.2
+ github.com/Microsoft/go-winio v0.5.0 // indirect
+ github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c // indirect
+ github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
+ github.com/augmentable-dev/vtab v0.0.0-20210717200339-0c8dcfe2033b
+ github.com/clbanning/mxj/v2 v2.5.5
github.com/ghodss/yaml v1.0.0
- github.com/gitsight/go-vcsurl v1.0.0
- github.com/go-openapi/errors v0.19.9 // indirect
- github.com/go-openapi/strfmt v0.19.11 // indirect
- github.com/golang/protobuf v1.4.3 // indirect
- github.com/google/go-github v17.0.0+incompatible
- github.com/google/go-querystring v1.0.0 // indirect
+ github.com/go-git/go-billy/v5 v5.3.1
+ github.com/go-git/go-git/v5 v5.4.2
+ github.com/go-openapi/errors v0.20.0 // indirect
+ github.com/go-openapi/strfmt v0.20.1 // indirect
github.com/jedib0t/go-pretty v4.3.0+incompatible
- github.com/jroimartin/gocui v0.4.0
- github.com/libgit2/git2go/v31 v31.4.7
- github.com/mattn/go-sqlite3 v1.14.6
- github.com/mitchellh/mapstructure v1.4.0 // indirect
- github.com/nsf/termbox-go v0.0.0-20201124104050-ed494de23a00 // indirect
+ github.com/kevinburke/ssh_config v1.1.0 // indirect
+ github.com/libgit2/git2go/v31 v31.4.14
+ github.com/mattn/go-runewidth v0.0.13 // indirect
+ github.com/mattn/go-sqlite3 v1.14.8
github.com/pkg/errors v0.9.1
- github.com/spf13/cobra v1.1.1
- go.mongodb.org/mongo-driver v1.4.4 // indirect
- go.riyazali.net/sqlite v0.0.0-20210413174544-3cf76b5afbdc
- golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
- golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
- golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5
- golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
- golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect
- golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
- golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
- google.golang.org/appengine v1.6.7 // indirect
+ github.com/sergi/go-diff v1.2.0 // indirect
+ github.com/spf13/cobra v1.2.1
+ go.mongodb.org/mongo-driver v1.6.0 // indirect
+ go.riyazali.net/sqlite v0.0.0-20210707161919-414349b4032a
+ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
+ golang.org/x/net v0.0.0-20210716203947-853a461950ff // indirect
+ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
+ golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
)
-
-replace github.com/mattn/go-sqlite3 v1.14.6 => github.com/patrickdevivo/go-sqlite3 v1.14.6-0.20201229155540-f024bb44eb6d
diff --git a/go.sum b/go.sum
index 4a52c922..5a85c76d 100644
--- a/go.sum
+++ b/go.sum
@@ -13,6 +13,11 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
+cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
+cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
+cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
+cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
+cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
@@ -37,79 +42,82 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
-github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
-github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
-github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
-github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
+github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
+github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
+github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU=
+github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
+github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
+github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c h1:FP7mMdsXy0ybzar1sJeIcZtaJka0U/ZmLTW4wRpolYk=
+github.com/ProtonMail/go-crypto v0.0.0-20210707164159-52430bf6b52c/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
+github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
+github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
+github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
+github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
-github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
-github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg=
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
-github.com/augmentable-dev/lege v0.0.0-20191028004410-79cb985065a1/go.mod h1:DtuvAW6+SE9e44O6eLaMJp8PFiadmk6NfXslCKYCiB0=
-github.com/augmentable-dev/tickgit v0.0.14 h1:9g9ujucK0idpdh/67/e2R01sG9H4wbYUYKgQ7rfmA34=
-github.com/augmentable-dev/tickgit v0.0.14/go.mod h1:OYy4z8FxGHj9HfmnMFKFc0+WEiIcZlVTGsT3sZ7HC1c=
+github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d h1:Byv0BzEl3/e6D5CLfI0j/7hiIEtvGVFPCZ7Ei2oq8iQ=
+github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
+github.com/augmentable-dev/vtab v0.0.0-20210717200339-0c8dcfe2033b h1:xVsjuNw65RgZUneKMX8awGD+uEiwQu6y8n5to4MvT+g=
+github.com/augmentable-dev/vtab v0.0.0-20210717200339-0c8dcfe2033b/go.mod h1:nW8zI//bDNKyXrKJgzdezNl3XzWYsBHm3JBaxB/ZTSU=
github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
-github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
-github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
-github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
-github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
+github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
-github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
-github.com/clbanning/mxj/v2 v2.5.2 h1:3ye58oYh6YJMR3NUXhM0prMmcFW9Ell73DXGpGonny4=
-github.com/clbanning/mxj/v2 v2.5.2/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
+github.com/clbanning/mxj/v2 v2.5.5 h1:oT81vUeEiQQ/DcHbzSytRngP6Ky9O+L+0Bw0zSJag9E=
+github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
-github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
-github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
-github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
-github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
+github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
-github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
-github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
-github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
-github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
-github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
+github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
+github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
-github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
+github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
-github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
-github.com/gitsight/go-vcsurl v1.0.0 h1:5tPEZWW6eN4cACq6IPV7ThikoLO1HnZtS0oMVJ0yIxA=
-github.com/gitsight/go-vcsurl v1.0.0/go.mod h1:qRFdKDa/0Lh9MT0xE+qQBYZ/01+mY1H40rZUHR24X9U=
+github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
-github.com/go-enry/go-enry/v2 v2.5.2/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ=
-github.com/go-enry/go-oniguruma v1.2.1/go.mod h1:bWDhYP+S6xZQgiRL7wlTScFYBe023B6ilRZbCAD5Hf4=
+github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
+github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
+github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
+github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34=
+github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
+github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8=
+github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0=
+github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4=
+github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
-github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
-github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
-github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
-github.com/go-openapi/errors v0.19.9 h1:9SnKdGhiPZHF3ttwFMiCBEb8jQ4IDdrK+5+a0oTygA4=
-github.com/go-openapi/errors v0.19.9/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
-github.com/go-openapi/strfmt v0.19.11 h1:0+YvbNh05rmBkgztd6zHp4OCFn7Mtu30bn46NQo2ZRw=
-github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc=
+github.com/go-openapi/errors v0.20.0 h1:Sxpo9PjEHDzhs3FbnGNonvDgWcMW2U7wGTcDDSFSceM=
+github.com/go-openapi/errors v0.20.0/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M=
+github.com/go-openapi/strfmt v0.20.1 h1:1VgxvehFne1mbChGeCmZ5pc0LxUf6yaACVSIYAR91Xc=
+github.com/go-openapi/strfmt v0.20.1/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
@@ -137,10 +145,9 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe
github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ=
github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0=
github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw=
-github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
-github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
+github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
-github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -151,6 +158,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
+github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
@@ -164,8 +172,10 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
-github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
+github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
+github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
+github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@@ -176,14 +186,15 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
-github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
-github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
-github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
-github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
+github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
+github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
+github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
@@ -191,19 +202,20 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
+github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
+github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
-github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
+github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
-github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
-github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
-github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
-github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
-github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
@@ -225,61 +237,61 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
+github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jedib0t/go-pretty v4.3.0+incompatible h1:CGs8AVhEKg/n9YbUenWmNStRW2PHJzaeDodcfvRAbIo=
github.com/jedib0t/go-pretty v4.3.0+incompatible/go.mod h1:XemHduiw8R651AF9Pt4FwCTKeG3oo7hrHJAoznj9nag=
-github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
+github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
-github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
-github.com/jroimartin/gocui v0.4.0 h1:52jnalstgmc25FmtGcWqa0tcbMEWS6RpFLsOIO+I+E8=
-github.com/jroimartin/gocui v0.4.0/go.mod h1:7i7bbj99OgFHzo7kB2zPb8pXLqMBSQegY7azfqXMkyY=
-github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
-github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
-github.com/karrick/godirwalk v1.15.6/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
-github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
-github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
+github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
+github.com/kevinburke/ssh_config v1.1.0 h1:pH/t1WS9NzT8go394IqZeJTMHVm6Cr6ZJ6AQ+mdNo/o=
+github.com/kevinburke/ssh_config v1.1.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
+github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
-github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
+github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
-github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
-github.com/libgit2/git2go/v31 v31.4.7 h1:P85qB5at5un4qPqUcvOZbAom7P0G4KAG/OLVyD29kQ0=
-github.com/libgit2/git2go/v31 v31.4.7/go.mod h1:c/rkJcBcUFx6wHaT++UwNpKvIsmPNqCeQ/vzO4DrEec=
-github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
-github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/libgit2/git2go/v31 v31.4.14 h1:6GOd3965D9e/+gjxCwZF4eQ+vB9kKB4yKFqdQr6XZ2E=
+github.com/libgit2/git2go/v31 v31.4.14/go.mod h1:c/rkJcBcUFx6wHaT++UwNpKvIsmPNqCeQ/vzO4DrEec=
+github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
+github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
+github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
-github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
-github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
-github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
-github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
-github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
-github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
-github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
-github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
-github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
+github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
+github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
+github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
+github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
@@ -287,122 +299,113 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
-github.com/mitchellh/mapstructure v1.4.0 h1:7ks8ZkOP5/ujthUsT07rNv+nkLXCQWKNHuwzOAesEks=
-github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
-github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
+github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
-github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
-github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
-github.com/nsf/termbox-go v0.0.0-20201124104050-ed494de23a00 h1:Rl8NelBe+n7SuLbJyw13ho7CGWUt2BjGGKIoreCWQ/c=
-github.com/nsf/termbox-go v0.0.0-20201124104050-ed494de23a00/go.mod h1:T0cTdVuOwf7pHQNtfhnEbzHbcNyCEcVU4YPpouCbVxo=
+github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
-github.com/patrickdevivo/go-sqlite3 v1.14.6-0.20201229155540-f024bb44eb6d h1:le16PxRK5I1Sqmx+wMQ0PINfi9X0kIkRxU8V5eB5s9c=
-github.com/patrickdevivo/go-sqlite3 v1.14.6-0.20201229155540-f024bb44eb6d/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
-github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
-github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
+github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
-github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
-github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
-github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
-github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
-github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
-github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
-github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
-github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
-github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
-github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
+github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
+github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
+github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
-github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
+github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
+github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
-github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
-github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
-github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
-github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
-github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
+github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
-github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
-github.com/spf13/cobra v1.1.1 h1:KfztREH0tPxJJ+geloSLaAkaPkr4ki2Er5quFV1TDo4=
-github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
-github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
+github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
+github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
-github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
-github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
-github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI=
+github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
-github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
-github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
-github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
-github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
-github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
-github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
-github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
-github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
+github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
+github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
+github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
+github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
+github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
-go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
-go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc=
-go.mongodb.org/mongo-driver v1.4.4 h1:bsPHfODES+/yx2PCWzUYMH8xj6PVniPI8DQrsJuSXSs=
-go.mongodb.org/mongo-driver v1.4.4/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
+go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
+go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
+go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw=
+go.mongodb.org/mongo-driver v1.6.0 h1:ccc26ylcoRWJQRbjU7GvqfxNzwKcoIcEL3BPuFR/pJ0=
+go.mongodb.org/mongo-driver v1.6.0/go.mod h1:Q4oFMbo1+MSNqICAdYMlC/zSTrwCogR4R8NzkI+yfU8=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
-go.riyazali.net/sqlite v0.0.0-20210413174544-3cf76b5afbdc h1:H0iCRhfcR/mlWB9KZd81mcyrH3y2fjLHdmo66VyQu4Q=
-go.riyazali.net/sqlite v0.0.0-20210413174544-3cf76b5afbdc/go.mod h1:UVocl0mLwS0QKUKa5mI6lppmBjvQnUEkFjFfoWqFWQU=
-go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
-go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
-go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
+go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
+go.riyazali.net/sqlite v0.0.0-20210707161919-414349b4032a h1:OMc4dyudGBBW5u4zTpD97FG2fUHxlCiRPfr0r4BuEzI=
+go.riyazali.net/sqlite v0.0.0-20210707161919-414349b4032a/go.mod h1:UVocl0mLwS0QKUKa5mI6lppmBjvQnUEkFjFfoWqFWQU=
+go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
+go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
-golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
-golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
+golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
+golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
+golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -425,6 +428,8 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
+golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
@@ -433,19 +438,19 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
-golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -461,19 +466,32 @@ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200528225125-3c3fba18258b/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw=
-golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
+golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
+golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
+golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
+golang.org/x/net v0.0.0-20210716203947-853a461950ff h1:j2EK/QoxYNBsXI4R7fQkkRUk8y6wnOBI+6hgPdP/6Ds=
+golang.org/x/net v0.0.0-20210716203947-853a461950ff/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5 h1:Lm4OryKCca1vehdsWogr9N4t7NfZxLbJoc/H0w4K4S4=
+golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
+golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -483,17 +501,14 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
-golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -505,12 +520,13 @@ golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -523,25 +539,43 @@ golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
-golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
+golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
-golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
+golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE=
-golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
@@ -559,7 +593,6 @@ golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgw
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@@ -586,9 +619,18 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
+golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
+golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
+golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -610,13 +652,18 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
+google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
+google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
+google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
+google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU=
+google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94=
+google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
-google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -641,15 +688,26 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
+google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
+google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
-google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
@@ -660,6 +718,14 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
+google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
+google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
+google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
+google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
+google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -669,30 +735,30 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
-google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
-gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
+google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
+google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
+gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
-gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
-gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
-gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
-gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
-gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=
+gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
-gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
-gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
+gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
-gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c h1:grhR+C34yXImVGp7EzNk+DTIk+323eIUWOmEevy6bDo=
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
+gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/pkg/ghqlite/ghqlite_test.go b/pkg/.ghqlite/ghqlite_test.go
similarity index 100%
rename from pkg/ghqlite/ghqlite_test.go
rename to pkg/.ghqlite/ghqlite_test.go
diff --git a/pkg/ghqlite/github_iterator.go b/pkg/.ghqlite/github_iterator.go
similarity index 100%
rename from pkg/ghqlite/github_iterator.go
rename to pkg/.ghqlite/github_iterator.go
diff --git a/pkg/ghqlite/issue_iterator.go b/pkg/.ghqlite/issue_iterator.go
similarity index 100%
rename from pkg/ghqlite/issue_iterator.go
rename to pkg/.ghqlite/issue_iterator.go
diff --git a/pkg/ghqlite/issue_vtab.go b/pkg/.ghqlite/issue_vtab.go
similarity index 100%
rename from pkg/ghqlite/issue_vtab.go
rename to pkg/.ghqlite/issue_vtab.go
diff --git a/pkg/ghqlite/issues_iterator_test.go b/pkg/.ghqlite/issues_iterator_test.go
similarity index 100%
rename from pkg/ghqlite/issues_iterator_test.go
rename to pkg/.ghqlite/issues_iterator_test.go
diff --git a/pkg/ghqlite/issues_vtab_test.go b/pkg/.ghqlite/issues_vtab_test.go
similarity index 100%
rename from pkg/ghqlite/issues_vtab_test.go
rename to pkg/.ghqlite/issues_vtab_test.go
diff --git a/pkg/ghqlite/pull_request_iterator.go b/pkg/.ghqlite/pull_request_iterator.go
similarity index 100%
rename from pkg/ghqlite/pull_request_iterator.go
rename to pkg/.ghqlite/pull_request_iterator.go
diff --git a/pkg/ghqlite/pull_request_iterator_test.go b/pkg/.ghqlite/pull_request_iterator_test.go
similarity index 100%
rename from pkg/ghqlite/pull_request_iterator_test.go
rename to pkg/.ghqlite/pull_request_iterator_test.go
diff --git a/pkg/ghqlite/pull_requests_vtab.go b/pkg/.ghqlite/pull_requests_vtab.go
similarity index 100%
rename from pkg/ghqlite/pull_requests_vtab.go
rename to pkg/.ghqlite/pull_requests_vtab.go
diff --git a/pkg/ghqlite/pull_requests_vtab_test.go b/pkg/.ghqlite/pull_requests_vtab_test.go
similarity index 100%
rename from pkg/ghqlite/pull_requests_vtab_test.go
rename to pkg/.ghqlite/pull_requests_vtab_test.go
diff --git a/pkg/ghqlite/repo_iterator.go b/pkg/.ghqlite/repo_iterator.go
similarity index 100%
rename from pkg/ghqlite/repo_iterator.go
rename to pkg/.ghqlite/repo_iterator.go
diff --git a/pkg/ghqlite/repo_iterator_test.go b/pkg/.ghqlite/repo_iterator_test.go
similarity index 100%
rename from pkg/ghqlite/repo_iterator_test.go
rename to pkg/.ghqlite/repo_iterator_test.go
diff --git a/pkg/ghqlite/repos_vtab.go b/pkg/.ghqlite/repos_vtab.go
similarity index 100%
rename from pkg/ghqlite/repos_vtab.go
rename to pkg/.ghqlite/repos_vtab.go
diff --git a/pkg/ghqlite/repos_vtab_test.go b/pkg/.ghqlite/repos_vtab_test.go
similarity index 100%
rename from pkg/ghqlite/repos_vtab_test.go
rename to pkg/.ghqlite/repos_vtab_test.go
diff --git a/pkg/askgit/askgit.go b/pkg/askgit/askgit.go
deleted file mode 100644
index d4b094c2..00000000
--- a/pkg/askgit/askgit.go
+++ /dev/null
@@ -1,205 +0,0 @@
-package askgit
-
-import (
- "context"
- "crypto/md5"
- "database/sql"
- "database/sql/driver"
- "fmt"
- "os"
- "os/user"
- "path"
- "time"
-
- "github.com/askgitdev/askgit/pkg/ghqlite"
- _ "github.com/askgitdev/askgit/pkg/sqlite"
- _ "github.com/askgitdev/askgit/tables"
- "github.com/gitsight/go-vcsurl"
- git "github.com/libgit2/git2go/v31"
- "github.com/mattn/go-sqlite3"
- "github.com/pkg/errors"
- "golang.org/x/time/rate"
-)
-
-type AskGit struct {
- db *sql.DB
- options *Options
-}
-
-type Options struct {
- RepoPath string
- UseGitCLI bool
- GitHubToken string
- DBFilePath string
- QueryOnly bool
- HardHeapLimit int64
- SoftHeapLimit int64
-}
-
-type driverConnector struct {
- dsn string
- d *sqlite3.SQLiteDriver
-}
-
-func newDriverConnector(dsn string, d *sqlite3.SQLiteDriver) (driver.Connector, error) {
- return &driverConnector{dsn, d}, nil
-}
-
-func (dc *driverConnector) Connect(context.Context) (driver.Conn, error) {
- conn, err := dc.d.Open(dc.dsn)
- if err != nil {
- return nil, err
- }
- return conn, nil
-}
-
-func (dc *driverConnector) Driver() driver.Driver {
- return dc.d
-}
-
-// New creates an instance of AskGit
-func New(options *Options) (*AskGit, error) {
- // TODO with the addition of the GitHub API virtual tables, repoPath should no longer be required for creating
- // as *AskGit instance, as the caller may just be interested in querying against the GitHub API (or some other
- // to be define virtual table that doesn't need a repo on disk).
- // This should be reformulated, as it means currently the askgit command requires a local git repo, even if the query
- // only executes agains the GitHub API
-
- // ensure the repository exists by trying to open it
- _, err := git.OpenRepository(options.RepoPath)
- if err != nil {
- return nil, err
- }
-
- var dataSource string
- if options.DBFilePath == "" {
- // see https://github.com/mattn/go-sqlite3/issues/204
- // also mentioned in the FAQ of the README: https://github.com/mattn/go-sqlite3#faq
- dataSource = fmt.Sprintf("file:%x?mode=memory&cache=shared", md5.Sum([]byte(options.RepoPath)))
- } else {
- dataSource = options.DBFilePath
- }
-
- a := &AskGit{options: options}
-
- d := sqlite3.SQLiteDriver{
- ConnectHook: func(conn *sqlite3.SQLiteConn) (err error) {
- if err = a.loadGitModules(conn); err != nil {
- return err
- }
- return a.loadGitHubModules(conn)
- },
- }
-
- dc, err := newDriverConnector(dataSource, &d)
- if err != nil {
- return nil, err
- }
-
- a.db = sql.OpenDB(dc)
- if a.options.QueryOnly {
- _, err = a.db.Exec("PRAGMA query_only=true")
- if err != nil {
- return nil, err
- }
- }
-
- if a.options.SoftHeapLimit > 0 {
- _, err = a.db.Exec(fmt.Sprintf("PRAGMA soft_heap_limit=%d", a.options.SoftHeapLimit))
- if err != nil {
- return nil, err
- }
- }
-
- if a.options.HardHeapLimit > 0 {
- _, err = a.db.Exec(fmt.Sprintf("PRAGMA hard_heap_limit=%d", a.options.HardHeapLimit))
- if err != nil {
- return nil, err
- }
- }
-
- return a, nil
-}
-
-func (a *AskGit) DB() *sql.DB {
- return a.db
-}
-
-func (a *AskGit) RepoPath() string {
- return a.options.RepoPath
-}
-
-func (a *AskGit) loadGitModules(conn *sqlite3.SQLiteConn) error {
- var sp = fmt.Sprintf
- var stmts = []string{
- sp("CREATE VIRTUAL TABLE commits USING git_log(path=%q)", a.RepoPath()),
- sp("CREATE VIRTUAL TABLE branches USING git_branches(path=%q)", a.RepoPath()),
- sp("CREATE VIRTUAL TABLE blame USING git_blame(path=%q)", a.RepoPath()),
- sp("CREATE VIRTUAL TABLE files USING git_files(path=%q)", a.RepoPath()),
- sp("CREATE VIRTUAL TABLE stats USING git_stats(path=%q)", a.RepoPath()),
- sp("CREATE VIRTUAL TABLE tags USING git_tags(path=%q)", a.RepoPath()),
- }
-
- for _, stmt := range stmts {
- if _, err := conn.Exec(stmt, nil); err != nil {
- return errors.Wrap(err, "failed to create virtual table")
- }
- }
-
- return nil
-}
-
-func (a *AskGit) loadGitHubModules(conn *sqlite3.SQLiteConn) error {
- githubToken := os.Getenv("GITHUB_TOKEN")
- rateLimiter := rate.NewLimiter(rate.Every(2*time.Second), 1)
-
- err := conn.CreateModule("github_org_repos", ghqlite.NewReposModule(ghqlite.OwnerTypeOrganization, ghqlite.ReposModuleOptions{
- Token: githubToken,
- RateLimiter: rateLimiter,
- }))
- if err != nil {
- return err
- }
-
- err = conn.CreateModule("github_user_repos", ghqlite.NewReposModule(ghqlite.OwnerTypeUser, ghqlite.ReposModuleOptions{
- Token: githubToken,
- RateLimiter: rateLimiter,
- }))
- if err != nil {
- return err
- }
-
- err = conn.CreateModule("github_pull_requests", ghqlite.NewPullRequestsModule(ghqlite.PullRequestsModuleOptions{
- Token: githubToken,
- RateLimiter: rateLimiter,
- }))
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func CreateAuthenticationCallback(remote *vcsurl.VCS) *git.CloneOptions {
- cloneOptions := &git.CloneOptions{}
-
- if _, err := remote.Remote(vcsurl.SSH); err == nil { // if SSH, use "default" credentials
- // use FetchOptions instead of directly RemoteCallbacks
- // https://github.com/libgit2/git2go/commit/36e0a256fe79f87447bb730fda53e5cbc90eb47c
- cloneOptions.FetchOptions = &git.FetchOptions{
- RemoteCallbacks: git.RemoteCallbacks{
- CredentialsCallback: func(url string, username string, allowedTypes git.CredType) (*git.Cred, error) {
- usr, _ := user.Current()
- publicSSH := path.Join(usr.HomeDir, ".ssh/id_rsa.pub")
- privateSSH := path.Join(usr.HomeDir, ".ssh/id_rsa")
-
- cred, ret := git.NewCredSshKey("git", publicSSH, privateSSH, "")
- return cred, ret
- },
- CertificateCheckCallback: func(cert *git.Certificate, valid bool, hostname string) git.ErrorCode {
- return git.ErrOk
- },
- }}
- }
- return cloneOptions
-}
diff --git a/pkg/askgit/askgit_test.go b/pkg/askgit/askgit_test.go
deleted file mode 100644
index d9679e61..00000000
--- a/pkg/askgit/askgit_test.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package askgit
-
-import (
- "database/sql"
- "fmt"
- "io/ioutil"
- "os"
- "testing"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-var (
- fixtureRepoCloneURL = "https://github.com/augmentable-dev/tickgit"
- fixtureRepo *git.Repository
- fixtureRepoDir string
-)
-
-func TestMain(m *testing.M) {
- close, err := initFixtureRepo()
- if err != nil {
- panic(err)
- }
- code := m.Run()
-
- err = close()
- if err != nil {
- panic(err)
- }
-
- os.Exit(code)
-}
-
-func initFixtureRepo() (func() error, error) {
- dir, err := ioutil.TempDir("", "repo")
- if err != nil {
- return nil, err
- }
- fixtureRepo, err = git.Clone(fixtureRepoCloneURL, dir, &git.CloneOptions{})
-
- if err != nil {
- fmt.Println(err)
- return nil, err
- }
-
- fixtureRepoDir = dir
-
- return func() error {
- err := os.RemoveAll(dir)
- if err != nil {
- return err
- }
- return nil
- }, nil
-}
-
-func GetContents(rows *sql.Rows) (int, [][]string, error) {
- count := 0
- columns, err := rows.Columns()
- if err != nil {
- return count, nil, err
- }
-
- pointers := make([]interface{}, len(columns))
- container := make([]sql.NullString, len(columns))
- var ret [][]string
-
- for i := range pointers {
- pointers[i] = &container[i]
- }
-
- for rows.Next() {
- err = rows.Scan(pointers...)
- if err != nil {
- return count, nil, err
- }
-
- r := make([]string, len(columns))
- for i, c := range container {
- if c.Valid {
- r[i] = c.String
- } else {
- r[i] = "NULL"
- }
- }
- ret = append(ret, r)
- }
- return count, ret, err
-
-}
-func TestDB(t *testing.T) {
- ag, err := New(&Options{
- RepoPath: fixtureRepoDir,
- UseGitCLI: false,
- GitHubToken: os.Getenv("GITHUB_TOKEN"),
- QueryOnly: true,
- })
- if err != nil {
- t.Fatal(err)
- }
- _, err = ag.db.Exec("CREATE TABLE test (one TEXT, two TEXT)")
- if err.Error() != "attempt to write a readonly database" {
- t.Fatal(err)
- }
- ag, err = New(&Options{
- RepoPath: fixtureRepoDir,
- UseGitCLI: false,
- GitHubToken: os.Getenv("GITHUB_TOKEN"),
- QueryOnly: false,
- })
- if err != nil {
- t.Fatal(err)
- }
- _, err = ag.db.Exec("CREATE TABLE test (one TEXT, two TEXT)")
- if err != nil {
- t.Fatal(err)
- }
-
-}
diff --git a/pkg/askgit/display.go b/pkg/display/display.go
similarity index 97%
rename from pkg/askgit/display.go
rename to pkg/display/display.go
index e20a439a..1348b1cf 100644
--- a/pkg/askgit/display.go
+++ b/pkg/display/display.go
@@ -1,4 +1,4 @@
-package askgit
+package display
import (
"database/sql"
@@ -10,7 +10,7 @@ import (
"golang.org/x/term"
)
-func DisplayDB(rows *sql.Rows, w io.Writer, format string, interactive bool) error {
+func WriteTo(rows *sql.Rows, w io.Writer, format string, interactive bool) error {
switch format {
case "single":
err := single(rows, w)
diff --git a/pkg/askgit/display_test.go b/pkg/display/display_test.go
similarity index 71%
rename from pkg/askgit/display_test.go
rename to pkg/display/display_test.go
index 14f1a301..45a2138f 100644
--- a/pkg/askgit/display_test.go
+++ b/pkg/display/display_test.go
@@ -1,4 +1,4 @@
-package askgit
+package display
import (
"bufio"
@@ -23,7 +23,7 @@ func TestDisplayTable(t *testing.T) {
rows, _ := db.Query("select")
var b bytes.Buffer
- err := DisplayDB(rows, &b, "table", false)
+ err := WriteTo(rows, &b, "table", false)
if err != nil {
t.Fatal(err)
}
@@ -53,7 +53,7 @@ func TestDisplayCSV(t *testing.T) {
rows, _ := db.Query("select")
var b bytes.Buffer
- err := DisplayDB(rows, &b, "csv", false)
+ err := WriteTo(rows, &b, "csv", false)
if err != nil {
t.Fatal(err)
}
@@ -78,6 +78,45 @@ func TestDisplayCSV(t *testing.T) {
// TODO perhaps test the actual content of the lines?
}
+func TestDisplayTSV(t *testing.T) {
+ db, mock, _ := sqlmock.New()
+
+ mockRows := sqlmock.NewRows([]string{"id", "name", "value"}).
+ AddRow("1", "name 1", "value 1").
+ AddRow("2", "name 2", "value 2").
+ AddRow("3", "name 3", "value 3")
+
+ mock.ExpectQuery("select").WillReturnRows(mockRows)
+
+ rows, _ := db.Query("select")
+
+ var b bytes.Buffer
+ err := WriteTo(rows, &b, "tsv", false)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ r := csv.NewReader(strings.NewReader(b.String()))
+ r.Comma = '\t'
+
+ records, err := r.ReadAll()
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ lineCount := len(records)
+
+ if lineCount != 4 {
+ t.Fatalf("expected 4 lines of output, got: %d", lineCount)
+ }
+
+ if len(records[0]) != 3 {
+ t.Fatalf("expected 3 columns of output, got: %d", len(records[0]))
+ }
+
+ // TODO perhaps test the actual content of the lines?
+}
+
func TestDisplayJSON(t *testing.T) {
db, mock, _ := sqlmock.New()
@@ -91,7 +130,7 @@ func TestDisplayJSON(t *testing.T) {
rows, _ := db.Query("select")
var b bytes.Buffer
- err := DisplayDB(rows, &b, "json", false)
+ err := WriteTo(rows, &b, "json", false)
if err != nil {
t.Fatal(err)
}
@@ -115,7 +154,7 @@ func TestDisplaySingle(t *testing.T) {
rows, _ := db.Query("select")
var b bytes.Buffer
- err := DisplayDB(rows, &b, "single", false)
+ err := WriteTo(rows, &b, "single", false)
if err != nil {
t.Fatal(err)
}
diff --git a/pkg/gitlog/parse.go b/pkg/gitlog/parse.go
deleted file mode 100644
index ec697090..00000000
--- a/pkg/gitlog/parse.go
+++ /dev/null
@@ -1,155 +0,0 @@
-package gitlog
-
-import (
- "bufio"
- "io"
- "os/exec"
- "strconv"
- "strings"
- "time"
-)
-
-type Commit struct {
- SHA string
- ParentID string
- TreeID string
- Message string
- AuthorName string
- AuthorEmail string
- AuthorWhen time.Time
- CommitterName string
- CommitterEmail string
- CommitterWhen time.Time
- Additions int
- Deletions int
-}
-type Result []*Commit
-
-type CommitIter struct {
- reader io.ReadCloser
- scanner *bufio.Scanner
- current *Commit
-}
-
-func newCommitIter(reader io.ReadCloser) *CommitIter {
- return &CommitIter{
- reader: reader,
- scanner: bufio.NewScanner(reader),
- current: nil,
- }
-}
-
-// line prefixes for the `fuller` formatted output
-const (
- commit = "commit "
- tree = "tree "
- parent = "parent "
- author = "Author: "
- authorDate = "AuthorDate: "
- message = "Message: "
- committer = "Commit: "
- commitDate = "CommitDate: "
-)
-
-func (iter *CommitIter) Next() (*Commit, error) {
- for iter.scanner.Scan() {
- line := iter.scanner.Text()
- switch {
- case strings.HasPrefix(line, commit):
- current := iter.current // save the previous current
- iter.current = &Commit{ // set the iterator's current to the new commit we see
- SHA: strings.TrimPrefix(line, commit),
- }
- if current != nil { // if we're seeing a new commit but already have a current commit, we've finished a commit and should return it
- return current, nil
- }
- case strings.HasPrefix(line, tree):
- iter.current.TreeID = strings.TrimPrefix(line, tree)
- case strings.HasPrefix(line, parent):
- iter.current.ParentID = strings.TrimPrefix(line, parent)
- case strings.HasPrefix(line, author):
- s := strings.TrimPrefix(line, author)
- spl := strings.Split(s, " ")
- email := strings.Trim(spl[len(spl)-1], "<>")
- name := strings.Join(spl[:len(spl)-1], " ")
- iter.current.AuthorEmail = strings.Trim(email, "<>")
- iter.current.AuthorName = strings.TrimSpace(name)
- case strings.HasPrefix(line, authorDate):
- authorDateString := strings.TrimPrefix(line, authorDate)
- aD, err := time.Parse(time.RFC3339, authorDateString)
- if err != nil {
- return nil, err
- }
- iter.current.AuthorWhen = aD
- case strings.HasPrefix(line, committer):
- s := strings.TrimPrefix(line, committer)
- spl := strings.Split(s, " ")
- email := strings.Trim(spl[len(spl)-1], "<>")
- name := strings.Join(spl[:len(spl)-1], " ")
- iter.current.CommitterEmail = strings.Trim(email, "<>")
- iter.current.CommitterName = strings.TrimSpace(name)
- case strings.HasPrefix(line, commitDate):
- commitDateString := strings.TrimPrefix(line, commitDate)
- cD, err := time.Parse(time.RFC3339, commitDateString)
- if err != nil {
- return nil, err
- }
- iter.current.CommitterWhen = cD
- case strings.HasPrefix(line, message):
- iter.current.Message = strings.TrimPrefix(line, message)
- case strings.TrimSpace(line) == "": // ignore empty lines
- default:
- s := strings.Split(line, "\t")
- if s[0] != "-" {
- additions, err := strconv.Atoi(s[0])
- if err != nil {
- return nil, err
- }
- iter.current.Additions += additions
- }
- if s[1] != "-" {
- deletions, err := strconv.Atoi(s[1])
- if err != nil {
- return nil, err
- }
- iter.current.Deletions += deletions
- }
- }
- }
-
- if iter.current != nil {
- c := iter.current
- iter.current = nil
- return c, nil
- }
-
- err := iter.reader.Close()
- if err != nil {
- return nil, err
- }
- return nil, io.EOF
-}
-
-func Execute(repoPath string) (*CommitIter, error) {
- gitPath, err := exec.LookPath("git")
- if err != nil {
- return nil, err
- }
-
- args := []string{"log"}
- args = append(args, "--format=commit %H%ntree %T%nparent %P%nAuthor: %an %ae%nAuthorDate: %aI%nCommit: %cn %ce%nCommitDate: %cI%nMessage: %s", "--numstat", "-m", "-c", "--date-order")
-
- cmd := exec.Command(gitPath, args...)
- cmd.Dir = repoPath
-
- stdout, err := cmd.StdoutPipe()
- if err != nil {
- return nil, err
- }
-
- if err := cmd.Start(); err != nil {
- return nil, err
- }
-
- return newCommitIter(stdout), nil
-}
diff --git a/pkg/gitlog/parse_test.go b/pkg/gitlog/parse_test.go
deleted file mode 100644
index 18e679ba..00000000
--- a/pkg/gitlog/parse_test.go
+++ /dev/null
@@ -1,136 +0,0 @@
-package gitlog
-
-import (
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "os/user"
- "path"
- "testing"
-
- "github.com/gitsight/go-vcsurl"
- git "github.com/libgit2/git2go/v31"
-)
-
-var (
- fixtureRepoCloneURL = "https://github.com/askgitdev/askgit"
- fixtureRepo *git.Repository
- fixtureRepoDir string
-)
-
-func TestMain(m *testing.M) {
- close, err := initFixtureRepo()
- if err != nil {
- panic(err)
- }
- code := m.Run()
-
- err = close()
- if err != nil {
- panic(err)
- }
-
- os.Exit(code)
-}
-
-func initFixtureRepo() (func() error, error) {
- dir, err := ioutil.TempDir("", "repo")
- if err != nil {
- return nil, err
- }
-
- remote, err := vcsurl.Parse(fixtureRepoCloneURL)
- if err != nil {
- return nil, err
- }
- cloneOptions := CreateAuthenticationCallback(remote)
- fixtureRepo, err = git.Clone(fixtureRepoCloneURL, dir, cloneOptions)
- if err != nil {
- fmt.Println(err)
- return nil, err
- }
- fixtureRepoDir = dir
-
- return func() error {
- err := os.RemoveAll(dir)
- if err != nil {
- return err
- }
- return nil
- }, nil
-}
-
-func TestParse(t *testing.T) {
- iter, err := Execute(fixtureRepoDir)
- if err != nil {
- t.Fatal(err)
- }
-
- count := 0
- for {
- commit, err := iter.Next()
- if err != nil {
- if err == io.EOF {
- break
- }
- t.Fatal(err)
- }
- if commit.SHA == "" {
- t.Fatal("expected SHA, got ")
- }
- count++
- }
-
- if err != nil {
- t.Fatal(err)
- }
-
- revWalk, err := fixtureRepo.Walk()
- if err != nil {
- t.Fatal(err)
- }
- defer revWalk.Free()
-
- err = revWalk.PushHead()
- if err != nil {
- t.Fatal(err)
- }
-
- shouldBeCount := 0
- err = revWalk.Iterate(func(*git.Commit) bool {
- shouldBeCount++
- return true
- })
- if err != nil {
- t.Fatal(err)
- }
-
- if count != shouldBeCount {
- t.Fatalf("incorrect number of commits, expected: %d got: %d", shouldBeCount, count)
- }
-}
-
-func CreateAuthenticationCallback(remote *vcsurl.VCS) *git.CloneOptions {
- cloneOptions := &git.CloneOptions{}
-
- if _, err := remote.Remote(vcsurl.SSH); err == nil { // if SSH, use "default" credentials
- // use FetchOptions instead of directly RemoteCallbacks
- // https://github.com/libgit2/git2go/commit/36e0a256fe79f87447bb730fda53e5cbc90eb47c
- cloneOptions.FetchOptions = &git.FetchOptions{
- RemoteCallbacks: git.RemoteCallbacks{
- CredentialsCallback: func(url string, username string, allowedTypes git.CredType) (*git.Cred, error) {
- usr, _ := user.Current()
- publicSSH := path.Join(usr.HomeDir, ".ssh/id_rsa.pub")
- privateSSH := path.Join(usr.HomeDir, ".ssh/id_rsa")
-
- cred, ret := git.NewCredSshKey("git", publicSSH, privateSSH, "")
- return cred, ret
- },
- CertificateCheckCallback: func(cert *git.Certificate, valid bool, hostname string) git.ErrorCode {
- return git.ErrOk
- },
- }}
- }
- return cloneOptions
-}
diff --git a/pkg/locator/locator.go b/pkg/locator/locator.go
new file mode 100644
index 00000000..d0d3f2eb
--- /dev/null
+++ b/pkg/locator/locator.go
@@ -0,0 +1,90 @@
+// Package locator provides various different implementations of
+// git.RepoLocator service. The locator service is used by the implementations
+// of Git virtual modules to query for / locate a given repository.
+//
+// The various different implementations of this interface provided in this package
+// provide different ways to locate the service, while some provides additional services
+// such as caching or switching between implementations.
+package locator
+
+import (
+ "context"
+ "io/ioutil"
+ "net/url"
+ "os"
+ "strings"
+
+ "github.com/askgitdev/askgit/tables"
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/go-git/go-billy/v5/osfs"
+ "github.com/go-git/go-git/v5"
+ "github.com/go-git/go-git/v5/plumbing/cache"
+ "github.com/go-git/go-git/v5/storage/filesystem"
+ "github.com/pkg/errors"
+)
+
+// DiskLocator is a repo locator implementation that opens on-disk repository at the specified path.
+func DiskLocator() services.RepoLocator {
+ return tables.RepoLocatorFn(func(_ context.Context, path string) (*git.Repository, error) {
+ return git.PlainOpen(path)
+ })
+}
+
+// CachedLocator is decorator function that takes a RepoLocator instance
+// and returns another one that caches output from the underlying locator
+// using path as the key.
+func CachedLocator(rl services.RepoLocator) services.RepoLocator {
+ var cache = make(map[string]*git.Repository)
+
+ return tables.RepoLocatorFn(func(ctx context.Context, path string) (*git.Repository, error) {
+ if cached, ok := cache[path]; ok {
+ return cached, nil
+ }
+
+ repo, err := rl.Open(ctx, path)
+ if err != nil {
+ return nil, err
+ }
+
+ cache[path] = repo
+ return repo, nil
+ })
+}
+
+// HttpLocator returns a repo locator capable of cloning remote
+// http repositories on-demand into temporary storage. It is recommended
+// that you club it with something like CachedLocator to improve performance
+// and remove the need to clone a single repository multiple times.
+func HttpLocator() services.RepoLocator {
+ return tables.RepoLocatorFn(func(ctx context.Context, path string) (*git.Repository, error) {
+ var err error
+ if _, err = url.ParseRequestURI(path); err != nil {
+ return nil, errors.Wrap(err, "invalid remote url")
+ }
+
+ var dir string
+ if dir, err = ioutil.TempDir(os.TempDir(), "askgit"); err != nil {
+ return nil, errors.Wrap(err, "failed to create a temporary directory")
+ }
+
+ var storer = filesystem.NewStorage(osfs.New(dir), cache.NewObjectLRUDefault())
+ return git.CloneContext(ctx, storer, storer.Filesystem(), &git.CloneOptions{URL: path, NoCheckout: true})
+ })
+}
+
+// MultiLocator returns a locator service that work with multiple git protocols
+// and is able to pick the correct underlying locator based on path provided.
+func MultiLocator() services.RepoLocator {
+ var locators = map[string]func() services.RepoLocator{
+ "http": HttpLocator,
+ "file": DiskLocator,
+ }
+
+ return tables.RepoLocatorFn(func(ctx context.Context, path string) (*git.Repository, error) {
+ var fn = locators["file"] // file is the default locator
+ if strings.HasPrefix(path, "http") || strings.HasPrefix(path, "https") {
+ fn = locators["http"]
+ }
+ return fn().Open(ctx, path)
+ })
+}
diff --git a/pkg/query/queries.go b/pkg/query/queries.go
new file mode 100644
index 00000000..ac416f76
--- /dev/null
+++ b/pkg/query/queries.go
@@ -0,0 +1,35 @@
+package query
+
+var queries = map[string]string{
+ // show all commit information from repository, in the current directory
+ "commit-info": "SELECT * FROM commits",
+
+ // list all distinct author information from commits in current directory
+ "distinct-author-emails": "SELECT DISTINCT( author_email ) FROM commits",
+
+ // list all count of commits, grouping by authors, in descending author
+ "commits-per-author": `SELECT
+ author_email, count(*)
+ FROM commits GROUP BY author_email
+ ORDER BY count(*) DESC`,
+
+ "author-stats": `SELECT count(DISTINCT commits.hash) AS commits, SUM(additions) AS additions, SUM(deletions) AS deletions, author_email
+ FROM commits, stats('', commits.hash)
+ WHERE commits.parents < 2
+ GROUP BY author_email ORDER BY commits`,
+
+ "author-commits-dow": `SELECT
+ count(*) AS commits,
+ count(CASE WHEN strftime('%w',author_when)='0' THEN 1 END) AS sunday,
+ count(CASE WHEN strftime('%w',author_when)='1' THEN 1 END) AS monday,
+ count(CASE WHEN strftime('%w',author_when)='2' THEN 1 END) AS tuesday,
+ count(CASE WHEN strftime('%w',author_when)='3' THEN 1 END) AS wednesday,
+ count(CASE WHEN strftime('%w',author_when)='4' THEN 1 END) AS thursday,
+ count(CASE WHEN strftime('%w',author_when)='5' THEN 1 END) AS friday,
+ count(CASE WHEN strftime('%w',author_when)='6' THEN 1 END) AS saturday,
+ author_email
+ FROM commits GROUP BY author_email ORDER BY commits`,
+}
+
+// Find finds and return the named query
+func Find(name string) (string, bool) { q, ok := queries[name]; return q, ok }
diff --git a/pkg/tui/conf.go b/pkg/tui/conf.go
deleted file mode 100644
index 86808063..00000000
--- a/pkg/tui/conf.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package tui
-
-var (
- Queries = map[string]string{
-
- "commit-info": "SELECT * FROM commits",
-
- "distinct-authors": "SELECT DISTINCT author_email FROM commits",
-
- "commits-per-author": `SELECT
- author_email, count(*)
- FROM commits GROUP BY author_email
- ORDER BY count(*) DESC`,
-
- "author-stats": `SELECT count(DISTINCT commits.id) AS commits, SUM(additions) AS additions, SUM(deletions) AS deletions, author_email
- FROM commits LEFT JOIN stats ON commits.id = stats.commit_id
- WHERE commits.parent_count < 2
- GROUP BY author_email ORDER BY commits`,
-
- "author-commits-dow": `SELECT
- count(*) AS commits,
- count(CASE WHEN strftime('%w',author_when)='0' THEN 1 END) AS sunday,
- count(CASE WHEN strftime('%w',author_when)='1' THEN 1 END) AS monday,
- count(CASE WHEN strftime('%w',author_when)='2' THEN 1 END) AS tuesday,
- count(CASE WHEN strftime('%w',author_when)='3' THEN 1 END) AS wednesday,
- count(CASE WHEN strftime('%w',author_when)='4' THEN 1 END) AS thursday,
- count(CASE WHEN strftime('%w',author_when)='5' THEN 1 END) AS friday,
- count(CASE WHEN strftime('%w',author_when)='6' THEN 1 END) AS saturday,
- author_email
- FROM commits GROUP BY author_email ORDER BY commits`,
-
- "tables": `
- SELECT name FROM sqlite_master
- WHERE
- type IN ('table','view') AND
- name NOT LIKE 'sqlite_%'
- `,
- }
-)
diff --git a/pkg/tui/helpers.go b/pkg/tui/helpers.go
deleted file mode 100644
index 852cb21b..00000000
--- a/pkg/tui/helpers.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package tui
-
-import (
- "fmt"
- "path/filepath"
- "text/tabwriter"
- "time"
-
- "github.com/askgitdev/askgit/pkg/askgit"
- "github.com/jroimartin/gocui"
-)
-
-//Displays a selection of information into the Info view
-func DisplayInformation(g *gocui.Gui, ag *askgit.AskGit, length time.Duration) error {
- out, err := g.View("Info")
- if err != nil {
- return err
- }
- w := tabwriter.NewWriter(out, 0, 0, 1, ' ', 0)
- out.Clear()
- path, err := filepath.Abs(usrInpt)
- if err != nil {
- return err
- }
- fmt.Fprintln(w, "Repo \t "+path+"\t")
-
- row := ag.DB().QueryRow("select count(*) from commits")
- var commitCount int
- err = row.Scan(&commitCount)
- if err != nil {
- return err
- }
- fmt.Fprintln(w, "# Commits \t", commitCount, "\t")
-
- row = ag.DB().QueryRow("select count(distinct author_name) from commits")
- var distinctAuthorCount int
- err = row.Scan(&distinctAuthorCount)
- if err != nil {
- return err
- }
- fmt.Fprintln(w, "# Authors \t", distinctAuthorCount, "\t")
-
- row = ag.DB().QueryRow("select count(distinct name) from branches where remote = 1")
- var distinctRemotes int
- err = row.Scan(&distinctRemotes)
- if err != nil {
- return err
- }
- fmt.Fprintln(w, "# Remote branches \t", distinctRemotes, "\t")
-
- row = ag.DB().QueryRow("select count(distinct name) from branches where remote = 0")
- var distinctLocals int
- err = row.Scan(&distinctLocals)
- if err != nil {
- return err
- }
- fmt.Fprintln(w, "# Local branches \t", distinctLocals, "\t")
-
- fmt.Fprintln(w, "Query time (ms)\t", length.String(), "\t")
- w.Flush()
- return nil
-
-}
diff --git a/pkg/tui/keybind.go b/pkg/tui/keybind.go
deleted file mode 100644
index ed80f6af..00000000
--- a/pkg/tui/keybind.go
+++ /dev/null
@@ -1,248 +0,0 @@
-package tui
-
-import (
- "fmt"
- "time"
-
- "github.com/askgitdev/askgit/pkg/askgit"
- "github.com/jroimartin/gocui"
-)
-
-var (
- viewArr = []string{"Query", "Output"}
-)
-
-func SetCurrentViewOnTop(g *gocui.Gui, name string) (*gocui.View, error) {
- if _, err := g.SetCurrentView(name); err != nil {
- return nil, err
- }
- return g.SetViewOnTop(name)
-}
-
-//Clear's the query view
-func ClearQuery(g *gocui.Gui, v *gocui.View) error {
- q, err := g.View("Query")
- if err != nil {
- return err
- }
- q.Clear()
- q.Rewind()
- return nil
-}
-
-// goes to the next view in the viewArr
-func NextView(g *gocui.Gui, v *gocui.View) error {
- nextIndex := (active + 1) % len(viewArr)
- name := viewArr[nextIndex]
- if _, err := SetCurrentViewOnTop(g, name); err != nil {
- return err
- }
- // since going to next this actually sets g.Cursor to true for the Query view
- if v.Name() == "Output" {
- g.Cursor = true
- } else {
- g.Cursor = false
- }
- v.Rewind()
- active = nextIndex
- return nil
-}
-
-//handles Left click.
-func HandleClick(g *gocui.Gui, v *gocui.View) error {
- if v.Name() == "Default" {
- _, y := v.Cursor()
- key := v.BufferLines()[y]
- if val, ok := Queries[key]; ok {
- input, err := g.View("Query")
- if err != nil {
- return err
- }
- input.Clear()
- fmt.Fprint(input, val)
-
- }
- } else if v.Name() != "Info" && v.Name() != "Keybinds" {
- if _, err := g.SetCurrentView(v.Name()); err != nil {
- return err
- }
- if v.Name() == "Query" {
- g.Cursor = true
- } else {
- g.Cursor = false
- }
- err := HandleCursor(g, v)
- if err != nil {
- return nil
- }
- }
- return nil
-}
-
-//Makes sure Cursor is not more right or more down than allowed
-func HandleCursor(g *gocui.Gui, v *gocui.View) error {
- if v.Buffer() == "" {
- err := v.SetCursor(0, 0)
- if err != nil {
- return err
- }
- return nil
- }
-
- b := v.BufferLines()
- var y int
- var x int
- xb, yb := v.Cursor()
- y = len(b) - 1
- if y < 0 {
- y = 0
- }
- if yb > y {
- yb = y
- }
- x = len(b[yb])
- if x < 0 {
- x = 0
- }
- if xb > x {
- xb = x
- }
-
- err := v.SetCursor(xb, yb)
- if err != nil {
- fmt.Fprintf(v, "%s, xb: %d, yb: %d x: %d, y: %d", err, xb, yb, x, y)
- return nil
- }
- return nil
-}
-
-//Run's the query
-func RunQuery(g *gocui.Gui, v *gocui.View) error {
- input, err := g.View("Query")
- if err != nil {
- return err
- }
- if input.Buffer() != "" {
- out, err := g.View("Output")
- if err != nil {
- return err
- }
- out.Clear()
- err = out.SetOrigin(0, 0)
- if err != nil {
- return err
- }
- query = input.Buffer()
- start := time.Now()
- rows, err := ag.DB().Query(query)
- if err != nil {
- fmt.Fprint(out, err)
- return nil
- }
-
- err = askgit.DisplayDB(rows, out, "", true)
- if err != nil {
- return err
- }
- total := time.Since(start)
- err = DisplayInformation(g, ag, total)
- if err != nil {
- return err
- }
- }
- return nil
-}
-
-//Goes to the previous line
-func PreviousLine(g *gocui.Gui, v *gocui.View) error {
-
- x, y := v.Origin()
- err := v.SetOrigin(x, y-1)
- if err != nil {
- //do nothing print for lint
- fmt.Print()
- }
-
- return nil
-}
-
-func NextLine(g *gocui.Gui, v *gocui.View) error {
-
- x, y := v.Origin()
- err := v.SetOrigin(x, y+1)
- if err != nil {
- //do nothing print for lint
-
- fmt.Print()
- }
-
- return nil
-}
-func GoLeft(g *gocui.Gui, v *gocui.View) error {
-
- x, y := v.Origin()
- var err error
- if x-1 > 0 {
- err = v.SetOrigin(x-1, y)
- }
- if err != nil {
- return err
- }
-
- return nil
-}
-func GoRight(g *gocui.Gui, v *gocui.View) error {
-
- x, y := v.Origin()
- err := v.SetOrigin(x+1, y)
- if err != nil {
- return err
- }
- return nil
-}
-func JumpRight(g *gocui.Gui, v *gocui.View) error {
- x, y := v.Origin()
- width, _ := v.Size()
- err := v.SetOrigin(x+width, y)
- if err != nil {
- return err
- }
- return nil
-}
-func JumpLeft(g *gocui.Gui, v *gocui.View) error {
- x, y := v.Origin()
- width, _ := v.Size()
- var err error
- if x-width > 0 {
- err = v.SetOrigin(x-width, y)
- } else {
- err = v.SetOrigin(0, y)
- }
- if err != nil {
- return err
- }
- return nil
-}
-func JumpUp(g *gocui.Gui, v *gocui.View) error {
- x, y := v.Origin()
- _, height := v.Size()
- var err error
- if y-height >= 0 {
- err = v.SetOrigin(x, y-height)
- } else {
- err = v.SetOrigin(x, 0)
- }
- if err != nil {
- return err
- }
- return nil
-}
-func JumpDown(g *gocui.Gui, v *gocui.View) error {
- x, y := v.Origin()
- _, height := v.Size()
- err := v.SetOrigin(x, y+height)
- if err != nil {
- return err
- }
- return nil
-}
diff --git a/pkg/tui/tui.go b/pkg/tui/tui.go
deleted file mode 100644
index b3676493..00000000
--- a/pkg/tui/tui.go
+++ /dev/null
@@ -1,152 +0,0 @@
-package tui
-
-import (
- "fmt"
- "log"
- "text/tabwriter"
-
- "github.com/askgitdev/askgit/pkg/askgit"
- "github.com/jroimartin/gocui"
-)
-
-var (
- active = 0
- query = ""
- usrInpt = ""
- ag *askgit.AskGit
-)
-
-func layout(g *gocui.Gui) error {
- maxX, maxY := g.Size()
- if v, err := g.SetView("Query", 0, 0, maxX/2-1, maxY*2/10); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- v.Title = "Query"
- v.Editable = true
- v.Wrap = true
- fmt.Fprint(v, query)
- if _, err = SetCurrentViewOnTop(g, "Query"); err != nil {
- return err
- }
-
- }
- if v, err := g.SetView("Keybinds", 0, maxY*2/10+1, maxX/2-1, maxY*4/10); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- v.Title = "Keybinds"
- w := tabwriter.NewWriter(v, 0, 0, 1, ' ', 0)
-
- fmt.Fprint(w, "Ctrl+C\t exit \nCtrl+E\t execute query \nCtrl+Q\t clear query box\nDefault L-click \t select a default to be displayed in the query view\nHome\tjump left\nEnd\tjump right\nPgUp\tjump up\nPgDn\tjump down\n\n")
-
- }
- if v, err := g.SetView("Info", maxX/2, maxY*2/10+1, maxX-1, maxY*4/10); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- v.Title = "Info"
- err = DisplayInformation(g, ag, 0)
- if err != nil {
- return err
- }
-
- }
- if v, err := g.SetView("Output", 0, maxY*4/10+1, maxX, maxY-1); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- v.Title = "Output"
- v.Wrap = false
-
- }
- if v, err := g.SetView("Default", maxX/2, 0, maxX-1, maxY*2/10); err != nil {
- if err != gocui.ErrUnknownView {
- return err
- }
- v.Title = "Preset Queries"
- for i := range Queries {
- fmt.Fprintf(v, "%s\n", i)
- }
-
- }
- return nil
-}
-func test(g *gocui.Gui, v *gocui.View) error {
- //for use with testing uses ctrl+t
- return nil
-}
-func quit(g *gocui.Gui, v *gocui.View) error {
- return gocui.ErrQuit
-}
-func RunGUI(askgitInstance *askgit.AskGit, q string) {
- g, err := gocui.NewGui(gocui.OutputNormal)
- if err != nil {
- log.Panicln(err)
- }
- defer g.Close()
- query = q
- ag = askgitInstance
- g.Highlight = true
- g.Cursor = true
- g.SelFgColor = gocui.ColorGreen
- g.Mouse = true
-
- g.SetManagerFunc(layout)
-
- if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.KeyTab, gocui.ModNone, NextView); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.KeyCtrlQ, gocui.ModNone, ClearQuery); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.MouseLeft, gocui.ModNone, HandleClick); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.KeyCtrlE, gocui.ModNone, RunQuery); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.MouseRelease, gocui.ModNone, HandleCursor); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.MouseWheelUp, gocui.ModNone, PreviousLine); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.MouseWheelDown, gocui.ModNone, NextLine); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.KeyArrowUp, gocui.ModNone, PreviousLine); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.KeyArrowDown, gocui.ModNone, NextLine); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("Output", gocui.KeyArrowRight, gocui.ModNone, GoRight); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("Output", gocui.KeyArrowLeft, gocui.ModNone, GoLeft); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("Output", gocui.KeyEnd, gocui.ModNone, JumpRight); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("Output", gocui.KeyHome, gocui.ModNone, JumpLeft); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("Output", gocui.KeyPgup, gocui.ModNone, JumpUp); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("Output", gocui.KeyPgdn, gocui.ModNone, JumpDown); err != nil {
- log.Panicln(err)
- }
- if err := g.SetKeybinding("", gocui.KeyCtrlT, gocui.ModNone, test); err != nil {
- log.Panicln(err)
- }
-
- if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
- log.Panicln(err)
- }
-}
diff --git a/shared.go b/shared.go
index 42a2d76a..6b636b4b 100644
--- a/shared.go
+++ b/shared.go
@@ -4,6 +4,17 @@
// It imports github.com/askgitdev/askgit/tables which provides the actual extension implementation.
package main
-import _ "github.com/askgitdev/askgit/tables"
+import (
+ "github.com/askgitdev/askgit/pkg/locator"
+ "github.com/askgitdev/askgit/tables"
+ "go.riyazali.net/sqlite"
+)
+
+func init() {
+ sqlite.Register(tables.RegisterFn(
+ tables.WithExtraFunctions(),
+ tables.WithRepoLocator(locator.CachedLocator(locator.MultiLocator())),
+ ))
+}
func main() { /* noting here fellas */ }
diff --git a/tables/internal/funcs/str_split_test.go b/tables/internal/funcs/str_split_test.go
index a219fe9c..e92901c1 100644
--- a/tables/internal/funcs/str_split_test.go
+++ b/tables/internal/funcs/str_split_test.go
@@ -33,4 +33,4 @@ func TestStrSplit(t *testing.T) {
if contents[0][0] != "NULL" {
t.Fatalf("expected: %s, got %s", "NULL", contents[0][0])
}
-}
\ No newline at end of file
+}
diff --git a/tables/internal/funcs/toml_to_json.go b/tables/internal/funcs/toml_to_json.go
index fee4be11..163bfa36 100644
--- a/tables/internal/funcs/toml_to_json.go
+++ b/tables/internal/funcs/toml_to_json.go
@@ -2,6 +2,7 @@ package funcs
import (
"encoding/json"
+
"github.com/BurntSushi/toml"
"go.riyazali.net/sqlite"
)
diff --git a/tables/internal/funcs/xml_to_json_test.go b/tables/internal/funcs/xml_to_json_test.go
index ffda4c4d..825361e9 100644
--- a/tables/internal/funcs/xml_to_json_test.go
+++ b/tables/internal/funcs/xml_to_json_test.go
@@ -1,12 +1,19 @@
package funcs
import (
- "github.com/askgitdev/askgit/tables/internal/tools"
"testing"
+
+ "github.com/askgitdev/askgit/tables/internal/tools"
)
-func TestYmlToJson(t *testing.T) {
- rows, err := FixtureDatabase.Query(`SELECT yml_to_json('doe: "a deer, a female deer"')`)
+func TestXmlToJson(t *testing.T) {
+ rows, err := FixtureDatabase.Query(`SELECT xml_to_json('
+
+
+ john
+ doe
+ neverland
+ ')`)
if err != nil {
t.Fatal(err)
}
@@ -14,7 +21,7 @@ func TestYmlToJson(t *testing.T) {
if err != nil {
t.Fatalf("err %d at row Number %d", err, rowNum)
}
- if contents[0][0] != `{"doe":"a deer, a female deer"}` {
+ if contents[0][0] != `{"employee":{"fname":"john","home":"neverland","lname":"doe"}}` {
t.Fatalf("expected string: %s, got %s", "", contents[0][0])
}
-}
\ No newline at end of file
+}
diff --git a/tables/internal/funcs/yaml_to_json_test.go b/tables/internal/funcs/yaml_to_json_test.go
index 9e06666e..692a6322 100644
--- a/tables/internal/funcs/yaml_to_json_test.go
+++ b/tables/internal/funcs/yaml_to_json_test.go
@@ -1,18 +1,13 @@
package funcs
import (
- "github.com/askgitdev/askgit/tables/internal/tools"
"testing"
+
+ "github.com/askgitdev/askgit/tables/internal/tools"
)
-func TestXmlToJson(t *testing.T) {
- rows, err := FixtureDatabase.Query(`SELECT xml_to_json('
-
-
- john
- doe
- neverland
- ')`)
+func TestYmlToJson(t *testing.T) {
+ rows, err := FixtureDatabase.Query(`SELECT yml_to_json('doe: "a deer, a female deer"')`)
if err != nil {
t.Fatal(err)
}
@@ -20,7 +15,7 @@ func TestXmlToJson(t *testing.T) {
if err != nil {
t.Fatalf("err %d at row Number %d", err, rowNum)
}
- if contents[0][0] != `{"employee":{"fname":"john","home":"neverland","lname":"doe"}}` {
+ if contents[0][0] != `{"doe":"a deer, a female deer"}` {
t.Fatalf("expected string: %s, got %s", "", contents[0][0])
}
}
diff --git a/tables/internal/git/blame.go b/tables/internal/git/blame.go
deleted file mode 100644
index 03dd3912..00000000
--- a/tables/internal/git/blame.go
+++ /dev/null
@@ -1,100 +0,0 @@
-package git
-
-import (
- "fmt"
- "go.riyazali.net/sqlite"
- "io"
- "strconv"
- "strings"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-// BlameModule implements sqlite.Module that provides the "blame" virtual table
-type BlameModule struct{}
-
-func (m *BlameModule) Connect(_ *sqlite.Conn, args []string, declare func(string) error) (sqlite.VirtualTable, error) {
- var repo, _ = strconv.Unquote(strings.SplitN(args[3], "=", 2)[1])
-
- var schema = fmt.Sprintf(`CREATE TABLE %q (line_no INT, file_path TEXT, commit_id TEXT, line_content TEXT)`, args[0])
- return &gitBlameTable{repoPath: repo}, declare(schema)
-}
-
-type gitBlameTable struct{ repoPath string }
-
-func (v *gitBlameTable) BestIndex(_ *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
- // TODO: this should actually be implemented!
- return &sqlite.IndexInfoOutput{}, nil
-}
-
-func (v *gitBlameTable) Open() (sqlite.VirtualCursor, error) {
- repo, err := git.OpenRepository(v.repoPath)
- if err != nil {
- return nil, err
- }
-
- return &blameCursor{repo: repo}, nil
-}
-
-func (v *gitBlameTable) Disconnect() error { return nil }
-func (v *gitBlameTable) Destroy() error { return nil }
-
-type blameCursor struct {
- repo *git.Repository
- current *BlamedLine
- iter *BlameIterator
-}
-
-func (vc *blameCursor) Filter(_ int, _ string, _ ...sqlite.Value) error {
- iterator, err := NewBlameIterator(vc.repo)
- if err != nil {
- return err
- }
-
- blamedLine, err := iterator.Next()
- if err != nil {
- if err == io.EOF {
- vc.current = nil
- return nil
- }
- return err
- }
-
- vc.iter = iterator
- vc.current = blamedLine
- return nil
-}
-
-
-func (vc *blameCursor) Next() error {
- blamedLine, err := vc.iter.Next()
- if err != nil {
- if err == io.EOF {
- vc.current = nil
- return nil
- }
- return err
- }
- vc.current = blamedLine
- return nil
-}
-
-func (vc *blameCursor) Column(c *sqlite.Context, col int) error {
- blamedLine := vc.current
- switch col {
- case 0:
- c.ResultInt(blamedLine.Line)
- case 1:
- c.ResultText(blamedLine.File)
- case 2:
- c.ResultText(blamedLine.CommitID)
- case 3:
- c.ResultText(blamedLine.Content)
- }
-
- return nil
-}
-
-func (vc *blameCursor) Eof() bool { return vc.current == nil }
-func (vc *blameCursor) Rowid() (int64, error) { return int64(0), nil }
-func (vc *blameCursor) Close() error { return nil }
diff --git a/tables/internal/git/blame_iter.go b/tables/internal/git/blame_iter.go
deleted file mode 100644
index 613e351d..00000000
--- a/tables/internal/git/blame_iter.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package git
-
-import (
- "errors"
- "strings"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-type BlameIterator struct {
- repo *git.Repository
- fileIter *commitFileIter
- currentBlamedLines []*BlamedLine
- currentBlamedLineIdx int
-}
-
-type BlamedLine struct {
- File string
- Line int
- CommitID string
- Content string
-}
-
-func NewBlameIterator(repo *git.Repository) (*BlameIterator, error) {
- head, err := repo.Head()
- if err != nil {
- return nil, err
- }
- defer head.Free()
-
- // get a new iterator from repo and use the head commit
- fileIter, err := NewCommitFileIter(repo, &commitFileIterOptions{head.Target().String()})
- if err != nil {
- return nil, err
- }
-
- return &BlameIterator{
- repo,
- fileIter,
- nil,
- 0,
- }, nil
-}
-
-func (iter *BlameIterator) nextFile() error {
- iter.currentBlamedLines = make([]*BlamedLine, 0)
-
- // grab the next file
- file, err := iter.fileIter.Next()
- if err != nil {
- return err
- }
- defer file.Free()
-
- // blame the file
- opts, err := git.DefaultBlameOptions()
- if err != nil {
- return err
- }
- blame, err := iter.repo.BlameFile(file.path+file.Name, &opts)
- if err != nil {
- return err
- }
- defer func() {
- err := blame.Free()
- if err != nil {
- panic(err)
- }
- }()
-
- // store the lines of the file, used as we iterate over hunks
- fileContents := file.Contents()
- lines := strings.Split(string(fileContents), "\n")
-
- // iterate over the blame hunks
- fileLine := 1
-
- for {
- hunk, err := blame.HunkByLine(fileLine)
- if err != nil {
- if errors.Is(err, git.ErrInvalid) {
- break
- }
- return err
- }
- blamedLine := &BlamedLine{
- File: file.path + file.Name,
- CommitID: hunk.OrigCommitId.String(),
- Line: fileLine,
- Content: lines[fileLine-1],
- }
- // add it to the list for the current file
- iter.currentBlamedLines = append(iter.currentBlamedLines, blamedLine)
- // increment the file line by 1
- fileLine++
-
- }
- iter.currentBlamedLineIdx = 0
-
- return nil
-}
-
-func (iter *BlameIterator) Next() (*BlamedLine, error) {
- // if there's no currently blamed lines, grab the next file
- if iter.currentBlamedLines == nil {
- err := iter.nextFile()
- if err != nil {
- return nil, err
- }
- }
-
- // if we've exceeded the number of lines then go to next file
- if iter.currentBlamedLineIdx >= len(iter.currentBlamedLines) {
- err := iter.nextFile()
- if err != nil {
- return nil, err
- }
- }
-
- // if there's no blamed lines
- if len(iter.currentBlamedLines) == 0 {
- return iter.Next()
- }
-
- blamedLine := iter.currentBlamedLines[iter.currentBlamedLineIdx]
- iter.currentBlamedLineIdx++
-
- return blamedLine, nil
-}
diff --git a/tables/internal/git/blame_test.go b/tables/internal/git/blame_test.go
deleted file mode 100644
index ca6b8110..00000000
--- a/tables/internal/git/blame_test.go
+++ /dev/null
@@ -1,121 +0,0 @@
-package git
-
-import (
- "context"
- "io"
- "strconv"
- "strings"
- "testing"
-
- "github.com/augmentable-dev/tickgit/pkg/blame"
-)
-
-func TestBlameDistinctFiles(t *testing.T) {
-
- rows, err := fixtureDB.Query("SELECT count(distinct file_path) from blame")
- if err != nil {
- t.Fatal(err)
- }
- defer rows.Close()
- _, contents, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
- }
-
- gotFileCount, err := strconv.Atoi(contents[0][0])
- if err != nil {
- t.Fatal(err)
- }
-
- head, err := fixtureRepo.Head()
- if err != nil {
- t.Fatal(err)
- }
- defer head.Free()
-
- iter, err := NewCommitFileIter(fixtureRepo, &commitFileIterOptions{head.Target().String()})
- if err != nil {
- t.Fatal(err)
- }
-
- var expectedFileCount int
- for {
- _, err := iter.Next()
- if err != nil {
- if err == io.EOF {
- break
- }
- t.Fatal(err)
- }
- expectedFileCount++
- }
-
- if gotFileCount != expectedFileCount {
- t.Fatalf("expected %d distinct file paths in blame, got %d", expectedFileCount, gotFileCount)
- }
-
-}
-func TestBlameCommitID(t *testing.T) {
- iterator, err := NewBlameIterator(fixtureRepo)
- if err != nil {
- t.Fatal(err)
- }
- rows, err := fixtureDB.Query("SELECT line_no,commit_id from blame limit 100")
- if err != nil {
- t.Fatal(err)
- }
- _, lines, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
- }
- for i, line := range lines {
- cont, err := iterator.Next()
- if err != nil {
- t.Fatal(err)
- }
- results, err := blame.Exec(context.Background(), cont.File, &blame.Options{Directory: fixtureRepoDir})
- if err != nil {
- t.Fatal(err)
- }
- lineNo, err := strconv.Atoi(line[0])
- if err != nil {
- t.Fatal(err)
- }
- if strings.Compare(line[1], results[lineNo].SHA) != 0 {
- t.Fatalf("expected %s SHA in blame at line %d, got %s", results[i+1].SHA, i+1, line[0])
- }
- }
-}
-
-// TODO implement this with a join on commits
-func TestBlameAuthorEmail(t *testing.T) {
- iterator, err := NewBlameIterator(fixtureRepo)
- if err != nil {
- t.Fatal(err)
- }
- rows, err := fixtureDB.Query("SELECT b.line_no,c.author_email, b.commit_id FROM commits as c INNER JOIN blame as b on b.commit_id = c.id")
- if err != nil {
- t.Fatal(err)
- }
- _, lines, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
- }
- for i, line := range lines {
- cont, err := iterator.Next()
- if err != nil {
- t.Fatal(err)
- }
- results, err := blame.Exec(context.Background(), cont.File, &blame.Options{Directory: fixtureRepoDir})
- if err != nil {
- t.Fatal(err)
- }
- lineNo, err := strconv.Atoi(line[0])
- if err != nil {
- t.Fatal(err)
- }
- if strings.Compare(line[1], results[lineNo].Author.Email) != 0 {
- t.Fatalf("expected %s SHA in blame at line %d, got %s", results[lineNo].Author.Email, i+1, line[1])
- }
- }
-}
diff --git a/tables/internal/git/branches.go b/tables/internal/git/branches.go
deleted file mode 100644
index 844fb8f4..00000000
--- a/tables/internal/git/branches.go
+++ /dev/null
@@ -1,125 +0,0 @@
-package git
-
-import (
- "fmt"
- "go.riyazali.net/sqlite"
- "strconv"
- "strings"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-type BranchesModule struct{}
-
-func (m *BranchesModule) Connect(_ *sqlite.Conn, args []string, declare func(string) error) (sqlite.VirtualTable, error) {
- // TODO(@riyaz): parse args to extract repo
- var repo, _ = strconv.Unquote(strings.SplitN(args[3], "=", 2)[1])
-
- var schema = fmt.Sprintf(`CREATE TABLE %q (name TEXT, remote BOOL, target TEXT, head BOOL)`, args[0])
- return &gitBranchesTable{repoPath: repo}, declare(schema)
-}
-
-type gitBranchesTable struct {
- repoPath string
-}
-
-func (v *gitBranchesTable) BestIndex(_ *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
- // TODO: this should actually be implemented!
- return &sqlite.IndexInfoOutput{}, nil
-}
-
-func (v *gitBranchesTable) Open() (sqlite.VirtualCursor, error) {
- repo, err := git.OpenRepository(v.repoPath)
- if err != nil {
- return nil, err
- }
-
- return &branchesCursor{repo: repo}, nil
-}
-
-func (v *gitBranchesTable) Disconnect() error { return nil }
-func (v *gitBranchesTable) Destroy() error { return nil }
-
-type currentBranch struct {
- *git.Branch
- branchType git.BranchType
-}
-
-type branchesCursor struct {
- repo *git.Repository
- current *currentBranch
- iter *git.BranchIterator
-}
-
-func (vc *branchesCursor) Filter(_ int, _ string, _ ...sqlite.Value) error {
- branchIter, err := vc.repo.NewBranchIterator(git.BranchAll)
- if err != nil {
- return err
- }
-
- vc.iter = branchIter
-
- branch, branchType, err := vc.iter.Next()
- if err != nil {
- return err
- }
-
- vc.current = ¤tBranch{branch, branchType}
-
- return nil
-}
-
-func (vc *branchesCursor) Next() error {
- branch, branchType, err := vc.iter.Next()
- if err != nil {
- if branch == nil {
- vc.current = nil
- return nil
- }
- return err
- }
-
- vc.current.Free()
- vc.current = ¤tBranch{branch, branchType}
- return nil
-}
-
-func (vc *branchesCursor) Column(c *sqlite.Context, col int) error {
- branch := vc.current
- switch col {
- case 0:
- //branch name
- name, err := branch.Name()
- if err != nil {
- return err
- }
- c.ResultText(name)
- case 1:
- c.ResultInt(boolToInt(branch.IsRemote()))
- case 2:
- switch branch.Type() {
- case git.ReferenceSymbolic:
- c.ResultText(branch.SymbolicTarget())
- case git.ReferenceOid:
- c.ResultText(branch.Target().String())
- }
- case 3:
- isHead, err := branch.IsHead()
- if err != nil {
- return err
- }
- c.ResultInt(boolToInt(isHead))
- }
- return nil
-}
-
-func (vc *branchesCursor) Close() error {
- if vc.current != nil {
- vc.current.Free()
- }
- vc.iter.Free()
- return nil
-}
-
-func (vc *branchesCursor) Eof() bool { return vc.current == nil }
-func (vc *branchesCursor) Rowid() (int64, error) { return int64(0), nil }
diff --git a/tables/internal/git/branches_test.go b/tables/internal/git/branches_test.go
deleted file mode 100644
index 6a8ad015..00000000
--- a/tables/internal/git/branches_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package git
-
-import (
- "testing"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-func TestBranches(t *testing.T) {
- branchIter, err := fixtureRepo.NewBranchIterator(git.BranchAll)
- if err != nil {
- t.Fatal(err)
- }
- defer branchIter.Free()
-
- branchRows, err := fixtureDB.Query("SELECT * FROM branches")
- if err != nil {
- t.Fatal(err)
- }
-
- rowNum, contents, err := GetRowContents(branchRows)
- if err != nil {
- t.Fatalf("err %d at row Number %d", err, rowNum)
- }
-
- for i, c := range contents {
- branch, _, err := branchIter.Next()
- if err != nil {
- if branch != nil {
- t.Fatal(err)
- }
- }
-
- name, err := branch.Name()
- if err != nil {
- t.Fatal(err)
- }
-
- if name != c[0] {
- t.Fatalf("exepcted %s at row %d got %s", name, i, c[0])
- }
-
- switch branch.Type() {
- case git.ReferenceSymbolic:
- if branch.SymbolicTarget() != c[2] {
- t.Fatalf("expected %s at row %d got %s", branch.SymbolicTarget(), i, c[2])
- }
- case git.ReferenceOid:
- if branch.Target().String() != c[2] {
- t.Fatalf("expected %s at row %d got %s", branch.Target().String(), i, c[2])
- }
- }
-
- }
-}
-
-func BenchmarkBranchCount(b *testing.B) {
- for i := 0; i < b.N; i++ {
- rows, err := fixtureDB.Query("SELECT * FROM branches")
- if err != nil {
- b.Fatal(err)
- }
- rowNum, _, err := GetRowContents(rows)
- if err != nil {
- b.Fatalf("err %d at row Number %d", err, rowNum)
- }
- }
-}
diff --git a/tables/internal/git/file_iter.go b/tables/internal/git/file_iter.go
deleted file mode 100644
index e4128a84..00000000
--- a/tables/internal/git/file_iter.go
+++ /dev/null
@@ -1,169 +0,0 @@
-package git
-
-import (
- "io"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-type treeEntryWithPath struct {
- *git.TreeEntry
- path string
- treeID string
-}
-
-type commitFile struct {
- *git.Blob
- *treeEntryWithPath
- commitID string
-}
-
-type commitFileIter struct {
- repo *git.Repository
- commitIter *git.RevWalk
- currentCommit *git.Commit
- treeEntries []*treeEntryWithPath
- currentTreeEntryIndex int
-}
-
-type commitFileIterOptions struct {
- commitID string
-}
-
-func NewCommitFileIter(repo *git.Repository, opt *commitFileIterOptions) (*commitFileIter, error) {
- if opt.commitID == "" {
- revWalk, err := repo.Walk()
- if err != nil {
- return nil, err
- }
-
- err = revWalk.PushHead()
- if err != nil {
- return nil, err
- }
-
- revWalk.Sorting(git.SortNone)
-
- return &commitFileIter{
- repo: repo,
- commitIter: revWalk,
- currentCommit: nil,
- treeEntries: make([]*treeEntryWithPath, 10),
- currentTreeEntryIndex: 100, // init with an index greater than above array, so that the first call to Next() sets up the first commit, rather than trying to return a current Blob
- }, nil
-
- } else {
- commitID, err := git.NewOid(opt.commitID)
- if err != nil {
- return nil, err
- }
-
- commit, err := repo.LookupCommit(commitID)
- if err != nil {
- return nil, err
- }
-
- tree, err := commit.Tree()
- if err != nil {
- return nil, err
- }
- defer tree.Free()
-
- treeEntries := make([]*treeEntryWithPath, 0)
- treeID := tree.Id().String()
- err = tree.Walk(func(path string, treeEntry *git.TreeEntry) int {
- if treeEntry.Type == git.ObjectBlob {
- treeEntries = append(treeEntries, &treeEntryWithPath{treeEntry, path, treeID})
- }
- return 0
- })
- if err != nil {
- return nil, err
- }
-
- return &commitFileIter{
- repo: repo,
- commitIter: nil,
- currentCommit: commit,
- treeEntries: treeEntries,
- currentTreeEntryIndex: 0,
- }, nil
- }
-}
-
-func (iter *commitFileIter) Next() (*commitFile, error) {
- defer func() {
- iter.currentTreeEntryIndex++
- }()
-
- if iter.currentTreeEntryIndex < len(iter.treeEntries) {
-
- f := iter.treeEntries[iter.currentTreeEntryIndex]
- blob, err := iter.repo.LookupBlob(f.Id)
- if err != nil {
- return nil, err
- }
-
- return &commitFile{blob, f, iter.currentCommit.Id().String()}, nil
- }
-
- // if the commitIter is nil, there are no commits to iterate over, end
- // this assumes that a currentCommit was set when this was first called, with treeEntries already populated
- if iter.commitIter == nil {
- return nil, io.EOF
- }
-
- id := new(git.Oid)
- err := iter.commitIter.Next(id)
- if err != nil {
- if id.IsZero() {
- return nil, io.EOF
- }
-
- return nil, err
- }
-
- commit, err := iter.repo.LookupCommit(id)
- if err != nil {
- return nil, err
- }
-
- iter.currentCommit = commit
-
- tree, err := commit.Tree()
- if err != nil {
- return nil, err
- }
- defer tree.Free()
-
- iter.treeEntries = make([]*treeEntryWithPath, 0)
- iter.currentTreeEntryIndex = 0
- treeID := tree.Id().String()
- err = tree.Walk(func(path string, treeEntry *git.TreeEntry) int {
- if treeEntry.Type == git.ObjectBlob {
- iter.treeEntries = append(iter.treeEntries, &treeEntryWithPath{treeEntry, path, treeID})
- }
- return 0
- })
- if err != nil {
- return nil, err
- }
-
- f := iter.treeEntries[iter.currentTreeEntryIndex]
- blob, err := iter.repo.LookupBlob(f.Id)
- if err != nil {
- return nil, err
- }
-
- return &commitFile{blob, f, iter.currentCommit.Id().String()}, nil
-}
-
-func (iter *commitFileIter) Close() {
- if iter == nil {
- return
- }
- iter.currentCommit.Free()
- if iter.commitIter != nil {
- iter.commitIter.Free()
- }
-}
diff --git a/tables/internal/git/files.go b/tables/internal/git/files.go
deleted file mode 100644
index fab9b4fe..00000000
--- a/tables/internal/git/files.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package git
-
-import (
- "fmt"
- "go.riyazali.net/sqlite"
- "io"
- "path"
- "strconv"
- "strings"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-type FilesModule struct{}
-
-func (m *FilesModule) Connect(_ *sqlite.Conn, args []string, declare func(string) error) (sqlite.VirtualTable, error) {
- // TODO(@riyaz): parse args to extract repo
- var repo, _ = strconv.Unquote(strings.SplitN(args[3], "=", 2)[1])
-
- var schema = fmt.Sprintf(`CREATE TABLE %q(commit_id TEXT, path TEXT, contents TEXT, executable BOOL)`, args[0])
- return &gitFilesTable{repoPath: repo}, declare(schema)
-}
-
-type gitFilesTable struct {
- repoPath string
- repo *git.Repository
-}
-
-func (v *gitFilesTable) BestIndex(input *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
- var usage = make([]*sqlite.ConstraintUsage, len(input.Constraints))
-
- // TODO implement an index for file name glob patterns?
- // TODO this loop construct won't work well for multiple constraints...
- for c, constraint := range input.Constraints {
- // check if filtered by "WHERE commit_id = 'xxx'" ..
- if constraint.Usable && constraint.ColumnIndex == 0 && constraint.Op == sqlite.INDEX_CONSTRAINT_EQ {
- usage[c] = &sqlite.ConstraintUsage{ArgvIndex: 1, Omit: false}
- return &sqlite.IndexInfoOutput{ConstraintUsage: usage, IndexNumber: 1, IndexString: "files-by-commit-id", EstimatedCost: 1.0, EstimatedRows: 1}, nil
- }
- }
-
- return &sqlite.IndexInfoOutput{ConstraintUsage: usage, EstimatedCost: 100}, nil
-}
-
-func (v *gitFilesTable) Open() (sqlite.VirtualCursor, error) {
- repo, err := git.OpenRepository(v.repoPath)
- if err != nil {
- return nil, err
- }
- v.repo = repo
-
- return &gitFilesCursor{repo: v.repo}, nil
-}
-
-func (v *gitFilesTable) Disconnect() error { return nil }
-func (v *gitFilesTable) Destroy() error { return nil }
-
-type gitFilesCursor struct {
- repo *git.Repository
- iterator *commitFileIter
- current *commitFile
-}
-
-func (vc *gitFilesCursor) Filter(i int, _ string, values ...sqlite.Value) error {
- var opt *commitFileIterOptions
-
- switch i {
- case 0:
- opt = &commitFileIterOptions{}
- case 1:
- opt = &commitFileIterOptions{commitID: values[0].Text()}
- }
-
- iter, err := NewCommitFileIter(vc.repo, opt)
- if err != nil {
- return err
- }
-
- vc.iterator = iter
-
- file, err := vc.iterator.Next()
- if err != nil {
- if err == io.EOF {
- vc.current = nil
- return nil
- }
- return err
- }
-
- vc.current = file
- return nil
-}
-
-func (vc *gitFilesCursor) Next() error {
- // iterates to next file
- file, err := vc.iterator.Next()
- if err != nil {
- if err == io.EOF {
- vc.current = nil
- return nil
- }
- return err
- }
- vc.current = file
- return nil
-}
-
-func (vc *gitFilesCursor) Column(c *sqlite.Context, col int) error {
- file := vc.current
-
- switch col {
- case 0:
- //commit id
- c.ResultText(file.commitID)
- case 1:
- //tree name
- c.ResultText(path.Join(file.path, file.Name))
- case 2:
- c.ResultText(string(file.Contents()))
- case 3:
- c.ResultInt(boolToInt(file.Filemode == git.FilemodeBlobExecutable))
- }
-
- return nil
-}
-
-func (vc *gitFilesCursor) Eof() bool { return vc.current == nil }
-func (vc *gitFilesCursor) Rowid() (int64, error) { return int64(0), nil }
-func (vc *gitFilesCursor) Close() error { vc.iterator.Close(); return nil }
diff --git a/tables/internal/git/files_test.go b/tables/internal/git/files_test.go
deleted file mode 100644
index a30fa533..00000000
--- a/tables/internal/git/files_test.go
+++ /dev/null
@@ -1,146 +0,0 @@
-package git
-
-import (
- "fmt"
- "path"
- "strconv"
- "testing"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-func TestFileCounts(t *testing.T) {
-
- commitChecker, err := fixtureRepo.Walk()
- if err != nil {
- t.Fatal(err)
- }
-
- err = commitChecker.PushHead()
- if err != nil {
- t.Fatal(err)
- }
-
- defer commitChecker.Free()
-
- numFiles := 0
- err = commitChecker.Iterate(func(commit *git.Commit) bool {
- numFiles++
- return true
- })
- if err != nil {
- t.Fatal(err)
- }
-
- fileRows, err := fixtureDB.Query("SELECT DISTINCT commit_id FROM files")
- if err != nil {
- t.Fatal(err)
- }
- defer fileRows.Close()
-
- numFileRows := GetRowsCount(fileRows)
- if numFileRows != numFiles {
- t.Fatalf("expected %d rows got : %d", numFiles, numFileRows)
- }
-}
-
-func TestFileColumns(t *testing.T) {
-
- columnQuery, err := fixtureDB.Query("SELECT * FROM files LIMIT 1")
- if err != nil {
- t.Fatal(err)
- }
- defer columnQuery.Close()
-
- columns, err := columnQuery.Columns()
- if err != nil {
- t.Fatal(err)
- }
-
- if len(columns) != 4 {
- t.Fatalf("expected %d columns got : %d", 4, len(columns))
- }
-
- _, contents, err := GetRowContents(columnQuery)
- if err != nil {
- t.Fatal(err)
- }
-
- commitID, err := git.NewOid(contents[0][0])
- if err != nil {
- t.Fatal(err)
- }
-
- commit, err := fixtureRepo.LookupCommit(commitID)
- if err != nil {
- t.Fatal(err)
- }
- defer commit.Free()
-
- tree, err := commit.Tree()
- if err != nil {
- t.Fatal(err)
- }
- defer tree.Free()
-
- entry, err := tree.EntryByPath(contents[0][1])
- if err != nil {
- t.Fatal(err)
- }
-
- if entry.Name != path.Base(contents[0][1]) {
- t.Fatalf("expected file_name to be %s got %s", entry.Name, path.Base(contents[0][1]))
- }
-}
-
-func TestFileByID(t *testing.T) {
-
- o, err := fixtureRepo.RevparseSingle("HEAD~3")
- if err != nil {
- t.Fatal(err)
- }
- defer o.Free()
-
- commit, err := o.AsCommit()
- if err != nil {
- t.Fatal(err)
- }
- defer commit.Free()
-
- rows, err := fixtureDB.Query(fmt.Sprintf("SELECT count(*) FROM files WHERE commit_id = '%s'", commit.Id().String()))
- if err != nil {
- t.Fatal(err)
- }
- defer rows.Close()
-
- tree, err := commit.Tree()
- if err != nil {
- t.Fatal(err)
- }
- defer tree.Free()
-
- count := 0
- err = tree.Walk(func(path string, entry *git.TreeEntry) int {
- if entry.Type == git.ObjectBlob {
- count++
- }
- return 0
- })
- if err != nil {
- t.Fatal(err)
- }
-
- _, contents, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
- }
-
- gotCount, err := strconv.Atoi(contents[0][0])
- if err != nil {
- t.Fatal(err)
- }
-
- if gotCount != count {
- t.Fatalf("expected %d, got %d", count, gotCount)
- }
-}
diff --git a/tables/internal/git/git_test.go b/tables/internal/git/git_test.go
new file mode 100644
index 00000000..7c6aa0e0
--- /dev/null
+++ b/tables/internal/git/git_test.go
@@ -0,0 +1,42 @@
+package git_test
+
+import (
+ "database/sql"
+ "github.com/askgitdev/askgit/pkg/locator"
+ _ "github.com/askgitdev/askgit/pkg/sqlite"
+ "github.com/askgitdev/askgit/tables"
+ _ "github.com/mattn/go-sqlite3"
+ "go.riyazali.net/sqlite"
+ "os"
+ "testing"
+)
+
+func init() {
+ // register sqlite extension when this package is loaded
+ sqlite.Register(tables.RegisterFn(
+ tables.WithExtraFunctions(), tables.WithRepoLocator(locator.CachedLocator(locator.MultiLocator())),
+ ))
+}
+
+// tests' entrypoint that registers the extension
+// automatically with all loaded database connections
+func TestMain(m *testing.M) { os.Exit(m.Run()) }
+
+// Memory represents a uri to an in-memory database
+const Memory = "file:testing.db?mode=memory"
+
+// Connect opens a connection with the sqlite3 database using
+// the given data source address and pings it to check liveliness.
+func Connect(t *testing.T, dataSourceName string) *sql.DB {
+ t.Helper()
+ db, err := sql.Open("sqlite3", dataSourceName)
+ if err != nil {
+ t.Fatalf("failed to open connection: %v", err.Error())
+ }
+
+ if err = db.Ping(); err != nil {
+ t.Fatalf("failed to open connection: %v", err.Error())
+ }
+
+ return db
+}
diff --git a/tables/internal/git/gitqlite_test.go b/tables/internal/git/gitqlite_test.go
deleted file mode 100644
index 0edbf8af..00000000
--- a/tables/internal/git/gitqlite_test.go
+++ /dev/null
@@ -1,148 +0,0 @@
-package git
-
-import (
- "context"
- "database/sql"
- "fmt"
- "io/ioutil"
- "log"
- "os"
- "testing"
-
- "github.com/pkg/errors"
- "go.riyazali.net/sqlite"
-
- _ "github.com/askgitdev/askgit/pkg/sqlite"
- git "github.com/libgit2/git2go/v31"
- _ "github.com/mattn/go-sqlite3"
-)
-
-var (
- fixtureRepoCloneURL = "https://github.com/augmentable-dev/tickgit"
- fixtureRepo *git.Repository
- fixtureRepoDir string
- fixtureDB *sql.DB
-)
-
-func init() {
- // register sqlite extension when this package is loaded
- sqlite.Register(func(ext *sqlite.ExtensionApi) (_ sqlite.ErrorCode, err error) {
- var modules = map[string]sqlite.Module{
- "git_blame": &BlameModule{},
- "git_branches": &BranchesModule{},
- "git_files": &FilesModule{},
- "git_log": &LogModule{},
- "git_stats": &StatsModule{},
- "git_tags": &TagsModule{},
- }
-
- for name, mod := range modules {
- if err = ext.CreateModule(name, mod); err != nil {
- return sqlite.SQLITE_ERROR, errors.Wrap(err, "failed to register 'git_blame' module")
- }
- }
-
- return sqlite.SQLITE_OK, nil
- })
-}
-
-func TestMain(m *testing.M) {
- var err error
-
- var done func() error
- if done, err = initFixtureRepo(); err != nil {
- log.Fatalf("failed to initialize fixture repository: %v", err)
- }
- defer func() {
- err := done()
- log.Fatal(err)
- }()
-
- if err = initFixtureDB(fixtureRepoDir); err != nil {
- log.Fatalf("failed to initialize fixture database: %v", err)
- }
-
- os.Exit(m.Run())
-}
-
-func initFixtureRepo() (_ func() error, err error) {
- if fixtureRepoDir, err = ioutil.TempDir("", "repo"); err != nil {
- return nil, err
- }
- if fixtureRepo, err = git.Clone(fixtureRepoCloneURL, fixtureRepoDir, &git.CloneOptions{}); err != nil {
- return nil, err
- }
- return func() error { return os.RemoveAll(fixtureRepoDir) }, nil
-}
-
-func initFixtureDB(repoPath string) (err error) {
- if fixtureDB, err = sql.Open("sqlite3", ":memory:"); err != nil {
- return err
- }
-
- conn, err := fixtureDB.Conn(context.Background())
- if err != nil {
- return err
- }
- defer conn.Close()
-
- var sp = fmt.Sprintf
- var stmts = []string{
- sp("CREATE VIRTUAL TABLE commits USING git_log(path=%q)", repoPath),
- sp("CREATE VIRTUAL TABLE branches USING git_branches(path=%q)", repoPath),
- sp("CREATE VIRTUAL TABLE blame USING git_blame(path=%q)", repoPath),
- sp("CREATE VIRTUAL TABLE files USING git_files(path=%q)", repoPath),
- sp("CREATE VIRTUAL TABLE stats USING git_stats(path=%q)", repoPath),
- sp("CREATE VIRTUAL TABLE tags USING git_tags(path=%q)", repoPath),
- }
-
- for _, stmt := range stmts {
- if _, err := conn.ExecContext(context.Background(), stmt, nil); err != nil {
- return errors.Wrap(err, "failed to create virtual table")
- }
- }
-
- return nil
-}
-
-func GetRowsCount(rows *sql.Rows) int {
- count := 0
- for rows.Next() {
- count++
- }
-
- return count
-}
-
-func GetRowContents(rows *sql.Rows) (colCount int, contents [][]string, err error) {
- columns, err := rows.Columns()
- if err != nil {
- return colCount, nil, err
- }
-
- pointers := make([]interface{}, len(columns))
- container := make([]sql.NullString, len(columns))
-
- for i := range pointers {
- pointers[i] = &container[i]
- }
-
- for rows.Next() {
- err = rows.Scan(pointers...)
- if err != nil {
- return colCount, nil, err
- }
-
- r := make([]string, len(columns))
- for i, c := range container {
- if c.Valid {
- r[i] = c.String
- } else {
- r[i] = "NULL"
- }
- }
- contents = append(contents, r)
- }
- return colCount, contents, rows.Err()
-
-}
diff --git a/tables/internal/git/log.go b/tables/internal/git/log.go
index b37f98d3..959f9a4d 100644
--- a/tables/internal/git/log.go
+++ b/tables/internal/git/log.go
@@ -1,190 +1,286 @@
package git
import (
- "fmt"
- "go.riyazali.net/sqlite"
- "strconv"
- "strings"
+ "context"
"time"
- git "github.com/libgit2/git2go/v31"
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/go-git/go-git/v5"
+ "github.com/go-git/go-git/v5/plumbing"
+ "github.com/go-git/go-git/v5/plumbing/object"
+ "github.com/go-git/go-git/v5/plumbing/storer"
+ "github.com/pkg/errors"
+ "go.riyazali.net/sqlite"
)
-type LogModule struct{}
+type LogModule struct {
+ Locator services.RepoLocator
+ Context services.Context
+}
-func (l LogModule) Connect(_ *sqlite.Conn, args []string, declare func(string) error) (sqlite.VirtualTable, error) {
- // TODO(@riyaz): parse args to extract repo
- var repo, _ = strconv.Unquote(strings.SplitN(args[3], "=", 2)[1])
+func (mod *LogModule) Connect(_ *sqlite.Conn, _ []string, declare func(string) error) (sqlite.VirtualTable, error) {
+ const schema = `
+ CREATE TABLE commits (
+ hash TEXT,
+ message TEXT,
+ author_name TEXT,
+ author_email TEXT,
+ author_when DATETIME,
+ committer_name TEXT,
+ committer_email TEXT,
+ committer_when DATETIME,
+ parents INT,
- var schema = fmt.Sprintf(`CREATE TABLE %s (id TEXT, message TEXT, summary TEXT,
- author_name TEXT, author_email TEXT, author_when DATETIME,
- committer_name TEXT, committer_email TEXT, committer_when DATETIME,
- parent_id TEXT, parent_count INT)`, args[0])
+ repository HIDDEN,
+ ref HIDDEN,
+ PRIMARY KEY ( hash )
+ ) WITHOUT ROWID`
- return &gitLogTable{repoPath: repo}, declare(schema)
+ return &gitLogTable{repoLocator: mod.Locator, ctx: mod.Context}, declare(schema)
}
type gitLogTable struct {
- repoPath string
+ repoLocator services.RepoLocator
+ ctx services.Context
}
-func (v *gitLogTable) BestIndex(input *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
- var usage = make([]*sqlite.ConstraintUsage, len(input.Constraints))
+func (tab *gitLogTable) Disconnect() error { return nil }
+func (tab *gitLogTable) Destroy() error { return nil }
+func (tab *gitLogTable) Open() (sqlite.VirtualCursor, error) {
+ return &gitLogCursor{locator: tab.repoLocator, ctx: tab.ctx}, nil
+}
+
+// BestIndex analyses the input constraint and generates the best possible query plan for sqlite3.
+//
+// xFilter Contract:
+// The BestIndex and Filter function (defined below) follows an informal contract to pass
+// between them the information about the available constraints and how the filter function can configure
+// the git log routine to generate most accurate output, in a performant manner.
+//
+// The contract is defined using a bitmap that is generated by the index function and is passed
+// onto to the filter function by sqlite. Each single byte at index n in the bitmap defines
+// what column the passed in value in the argv corresponds to (at n-th position in argv) and
+// what operation is being performed on it (EQ, LE, GE?)
+//
+// In other words, for value at position n in argv the byte at index n in the bitmap provides
+// column and operation information which the filter routine can then consume to ensure most performant
+// query execution.
+//
+// For every byte in the bitset, following is how the information is encoded:
+//
+// | Op | | Idx |
+// 8 7 6 5 4 3 2 1
+//
+// where idx is the 0-based index from the table's schema
+// and op code is an integer constant for the operation.
+//
+// A potential issue with such framing is the small count of columns we can map,
+// which comes to about 2^4 = 16 .. we have already got 11 columns in current implementation.
+// And so, this contract must be revisited if we exceed the count of columns.
+func (tab *gitLogTable) BestIndex(input *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
+ var argv = 0
+ var bitmap []byte
+ var set = func(op, col int) { bitmap = append(bitmap, byte(op<<4|col)) } // not foolproof! use with caution (and small values only)
+
+ var out = &sqlite.IndexInfoOutput{}
+ out.ConstraintUsage = make([]*sqlite.ConstraintUsage, len(input.Constraints))
+
+ for i, constraint := range input.Constraints {
+ idx := constraint.ColumnIndex
- // TODO this loop construct won't work well for multiple constraints...
- for c, constraint := range input.Constraints {
- if constraint.Usable && constraint.ColumnIndex == 0 && constraint.Op == sqlite.INDEX_CONSTRAINT_EQ {
- usage[c] = &sqlite.ConstraintUsage{ArgvIndex: 1, Omit: false}
- return &sqlite.IndexInfoOutput{ConstraintUsage: usage, IndexNumber: 1, IndexString: "commit-by-id", EstimatedCost: 1.0, EstimatedRows: 1}, nil
+ // if hash is provided, it must be usable
+ if idx == 0 && !constraint.Usable {
+ return nil, sqlite.SQLITE_CONSTRAINT
}
- }
- return &sqlite.IndexInfoOutput{ConstraintUsage: usage, EstimatedCost: 100}, nil
-}
+ if !constraint.Usable {
+ continue
+ }
+
+ argv += 1 // increment pro-actively .. if unused we decrement it later
+
+ switch {
+ // user has specified WHERE hash = 'xxx' .. we just need to pick a single commit here
+ case idx == 0 && constraint.Op == sqlite.INDEX_CONSTRAINT_EQ:
+ {
+ set(1, idx)
+ out.ConstraintUsage[i] = &sqlite.ConstraintUsage{ArgvIndex: argv}
+ out.EstimatedCost, out.EstimatedRows = 1, 1
+ out.IdxFlags |= sqlite.INDEX_SCAN_UNIQUE // we only visit at most one row or commit
+ }
+
+ // user has specified which repository and / or reference to use
+ case (idx == 9 || idx == 10) && constraint.Op == sqlite.INDEX_CONSTRAINT_EQ:
+ {
+ set(1, idx)
+ out.ConstraintUsage[i] = &sqlite.ConstraintUsage{ArgvIndex: argv, Omit: true}
+ }
+
+ // user has specified < or > constraint on committer_when column
+ case idx == 7 && (constraint.Op == sqlite.INDEX_CONSTRAINT_LT || constraint.Op == sqlite.INDEX_CONSTRAINT_GT):
+ {
+ if constraint.Op == sqlite.INDEX_CONSTRAINT_LT {
+ set(2, idx)
+ } else {
+ set(3, idx)
+ }
+ out.ConstraintUsage[i] = &sqlite.ConstraintUsage{ArgvIndex: argv}
+ }
-func (v *gitLogTable) Open() (sqlite.VirtualCursor, error) {
- repo, err := git.OpenRepository(v.repoPath)
- if err != nil {
- return nil, err
+ default:
+ argv -= 1 // constraint not used .. decrement back the argv
+ }
+ }
+
+ // since we already return the commits ordered by descending order of commit time
+ // if the user specifies an ORDER BY committer_when DESC we can signal to sqlite3
+ // that the output would already be ordered and it doesn't have to program a separate sort routine
+ if len(input.OrderBy) == 1 && input.OrderBy[0].ColumnIndex == 7 && input.OrderBy[0].Desc {
+ out.OrderByConsumed = true
}
- return &commitCursor{repo: repo}, nil
+
+ // validate passed in constraint to ensure there combination stays logical
+ out.IndexString = enc(bitmap)
+
+ return out, nil
}
-func (v *gitLogTable) Disconnect() error { return nil }
-func (v *gitLogTable) Destroy() error { return nil }
+type gitLogCursor struct {
+ ctx services.Context
+ locator services.RepoLocator
+
+ repo *git.Repository
+ rev *plumbing.Revision
-type commitCursor struct {
- repo *git.Repository
- current *git.Commit
- commitIter *git.RevWalk
+ commit *object.Commit // the current commit
+ commits object.CommitIter
}
-func (vc *commitCursor) Filter(i int, _ string, values ...sqlite.Value) error {
- switch i {
- case 0:
- // no index is used, walk over all commits
- revWalk, err := vc.repo.Walk()
- if err != nil {
- return err
+func (cur *gitLogCursor) Filter(_ int, s string, values ...sqlite.Value) (err error) {
+ // values extracted from constraints
+ var hash, path, refName string
+ var start, end string
+
+ var bitmap, _ = dec(s)
+ for i, val := range values {
+ switch b := bitmap[i]; b {
+ case 0b00010000:
+ hash = val.Text()
+ case 0b00011001:
+ path = val.Text()
+ case 0b00011010:
+ refName = val.Text()
+ case 0b0100111:
+ end = val.Text()
+ case 0b0110111:
+ start = val.Text()
}
+ }
- err = revWalk.PushHead()
- if err != nil {
- return err
+ var repo *git.Repository
+ { // open the git repository
+ if path == "" {
+ path, err = GetDefaultRepoFromCtx(cur.ctx)
+ if err != nil {
+ return err
+ }
}
- revWalk.Sorting(git.SortNone)
+ if repo, err = cur.locator.Open(context.Background(), path); err != nil {
+ return errors.Wrapf(err, "failed to open %q", path)
+ }
+ cur.repo = repo
+ }
- vc.commitIter = revWalk
+ if hash != "" {
+ // we only need to get a single commit
+ cur.commits = object.NewCommitIter(repo.Storer, storer.NewEncodedObjectLookupIter(
+ repo.Storer, plumbing.CommitObject, []plumbing.Hash{plumbing.NewHash(hash)}))
+ return cur.Next()
+ }
- id := new(git.Oid)
- err = revWalk.Next(id)
- if err != nil {
- return err
- }
+ var opts = &git.LogOptions{Order: git.LogOrderCommitterTime}
- commit, err := vc.repo.LookupCommit(id)
+ rev := plumbing.Revision(refName)
+ cur.rev = &rev
+ if refName != "" {
+ rev, err := repo.ResolveRevision(rev)
if err != nil {
- return err
+ return errors.Errorf("failed to resolve %q", refName)
}
-
- vc.current = commit
- case 1:
- // commit-by-id - lookup a commit by the ID used in the query
- revWalk, err := vc.repo.Walk()
- if err != nil {
- return err
+ opts.From = *rev
+ } else {
+ var ref *plumbing.Reference
+ if ref, err = repo.Head(); err != nil {
+ return errors.Wrapf(err, "failed to resolve head")
}
- // nothing is pushed to this revWalk
- vc.commitIter = revWalk
+ opts.From = ref.Hash()
+ }
- id, err := git.NewOid(values[0].Text())
- if err != nil {
- return err
+ if start != "" {
+ var t time.Time
+ if t, err = time.Parse(time.RFC3339, start); err == nil {
+ opts.Since = &t
}
- commit, err := vc.repo.LookupCommit(id)
- if err != nil {
- return err
+ }
+
+ if end != "" {
+ var t time.Time
+ if t, err = time.Parse(time.RFC3339, end); err == nil {
+ opts.Until = &t
}
- vc.current = commit
}
- return nil
+ if cur.commits, err = repo.Log(opts); err != nil {
+ return errors.Wrap(err, "failed to create iterator")
+ }
+
+ return cur.Next()
}
-func (vc *commitCursor) Column(c *sqlite.Context, col int) error {
- commit := vc.current
- author := commit.Author()
- committer := commit.Committer()
+func (cur *gitLogCursor) Column(c *sqlite.Context, col int) error {
+ commit := cur.commit
switch col {
case 0:
- //commit id
- c.ResultText(commit.Id().String())
+ c.ResultText(commit.Hash.String())
case 1:
- //commit message
- c.ResultText(commit.Message())
+ c.ResultText(commit.Message)
case 2:
- //commit summary
- c.ResultText(commit.Summary())
+ c.ResultText(commit.Author.Name)
case 3:
- //commit author name
- c.ResultText(author.Name)
+ c.ResultText(commit.Author.Email)
case 4:
- //commit author email
- c.ResultText(author.Email)
+ c.ResultText(commit.Author.When.Format(time.RFC3339))
case 5:
- //author when
- c.ResultText(author.When.Format(time.RFC3339Nano))
+ c.ResultText(commit.Committer.Name)
case 6:
- //committer name
- c.ResultText(committer.Name)
+ c.ResultText(commit.Committer.Email)
case 7:
- //committer email
- c.ResultText(committer.Email)
+ c.ResultText(commit.Committer.When.Format(time.RFC3339))
case 8:
- //committer when
- c.ResultText(committer.When.Format(time.RFC3339Nano))
- case 9:
- //parent_id
- if int(commit.ParentCount()) > 0 {
- p := commit.Parent(0)
- c.ResultText(p.Id().String())
- p.Free()
- } else {
- c.ResultNull()
- }
- case 10:
- //parent_count
- c.ResultInt(int(commit.ParentCount()))
- case 11:
- //tree_id
- c.ResultText(commit.TreeId().String())
+ c.ResultInt(commit.NumParents())
}
+
return nil
}
-func (vc *commitCursor) Next() error {
- id := new(git.Oid)
- err := vc.commitIter.Next(id)
- if err != nil {
- if id.IsZero() {
- vc.current.Free()
- vc.current = nil
- return nil
+func (cur *gitLogCursor) Next() (err error) {
+ if cur.commit, err = cur.commits.Next(); err != nil {
+ // check for ErrObjectNotFound to ensure we don't crash
+ // if the user provided hash did not point to a commit
+ if !eof(err) && err != plumbing.ErrObjectNotFound {
+ return err
}
- return err
}
+ return nil
+}
- commit, err := vc.repo.LookupCommit(id)
- if err != nil {
- return err
+func (cur *gitLogCursor) Eof() bool { return cur.commit == nil }
+func (cur *gitLogCursor) Rowid() (int64, error) { return int64(0), nil }
+func (cur *gitLogCursor) Close() error {
+ if cur.commits != nil {
+ cur.commits.Close()
}
- vc.current.Free()
- vc.current = commit
return nil
}
-
-func (vc *commitCursor) Eof() bool { return vc.current == nil }
-func (vc *commitCursor) Rowid() (int64, error) { return int64(0), nil }
-func (vc *commitCursor) Close() error { vc.commitIter.Free(); vc.repo.Free(); return nil }
diff --git a/tables/internal/git/log_cli.go b/tables/internal/git/log_cli.go
deleted file mode 100644
index 6b4a5086..00000000
--- a/tables/internal/git/log_cli.go
+++ /dev/null
@@ -1,175 +0,0 @@
-// +build ignore
-
-package git
-
-import (
- "fmt"
- "io"
- "strings"
- "time"
-
- "github.com/askgitdev/askgit/pkg/gitlog"
- "github.com/mattn/go-sqlite3"
-)
-
-type GitLogCLIModule struct {
- options *GitLogCLIModuleOptions
-}
-
-type GitLogCLIModuleOptions struct {
- RepoPath string
-}
-
-func NewGitLogCLIModule(options *GitLogCLIModuleOptions) *GitLogCLIModule {
- return &GitLogCLIModule{options}
-}
-
-type gitLogCLITable struct {
- repoPath string
-}
-
-func (m *GitLogCLIModule) EponymousOnlyModule() {}
-
-func (m *GitLogCLIModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) {
- err := c.DeclareVTab(fmt.Sprintf(`
- CREATE TABLE %q (
- id TEXT,
- message TEXT,
- summary TEXT,
- author_name TEXT,
- author_email TEXT,
- author_when DATETIME,
- committer_name TEXT,
- committer_email TEXT,
- committer_when DATETIME,
- parent_id TEXT,
- parent_count INT
- )`, args[0]))
- if err != nil {
- return nil, err
- }
-
- return &gitLogCLITable{repoPath: m.options.RepoPath}, nil
-}
-
-func (m *GitLogCLIModule) Connect(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTab, error) {
- return m.Create(c, args)
-}
-
-func (m *GitLogCLIModule) DestroyModule() {}
-
-func (v *gitLogCLITable) Open() (sqlite3.VTabCursor, error) {
- return &commitCLICursor{repoPath: v.repoPath}, nil
-}
-
-func (v *gitLogCLITable) BestIndex(cst []sqlite3.InfoConstraint, ob []sqlite3.InfoOrderBy) (*sqlite3.IndexResult, error) {
- // TODO this should actually be implemented!
- dummy := make([]bool, len(cst))
- return &sqlite3.IndexResult{Used: dummy}, nil
-}
-
-func (v *gitLogCLITable) Disconnect() error {
- return nil
-}
-func (v *gitLogCLITable) Destroy() error { return nil }
-
-type commitCLICursor struct {
- repoPath string
- iter *gitlog.CommitIter
- current *gitlog.Commit
-}
-
-func (vc *commitCLICursor) Filter(idxNum int, idxStr string, vals []interface{}) error {
- iter, err := gitlog.Execute(vc.repoPath)
- if err != nil {
- return err
- }
- vc.iter = iter
-
- commit, err := iter.Next()
- if err != nil {
- return err
- }
-
- vc.current = commit
- return nil
-}
-
-func (vc *commitCLICursor) Next() error {
- commit, err := vc.iter.Next()
- if err != nil {
- if err == io.EOF {
- vc.current = nil
- return nil
- }
- return err
- }
-
- vc.current = commit
- return nil
-}
-
-func (vc *commitCLICursor) EOF() bool {
- return vc.current == nil
-}
-
-func (vc *commitCLICursor) Column(c *sqlite3.SQLiteContext, col int) error {
- current := vc.current
- switch col {
- case 0:
- //commit id
- c.ResultText(current.SHA)
- case 1:
- //commit message
- c.ResultText(current.Message)
- case 2:
- //commit summary
- c.ResultText(strings.Split(current.Message, "\n")[0])
- case 3:
- //commit author name
- c.ResultText(current.AuthorName)
- case 4:
- //commit author email
- c.ResultText(current.AuthorEmail)
- case 5:
- //author when
- c.ResultText(current.AuthorWhen.Format(time.RFC3339Nano))
- case 6:
- //committer name
- c.ResultText(current.CommitterName)
- case 7:
- //committer email
- c.ResultText(current.CommitterEmail)
- case 8:
- //committer when
- c.ResultText(current.CommitterWhen.Format(time.RFC3339Nano))
- case 9:
- //parent_id
- parentID := strings.Split(current.ParentID, " ")[0]
- if strings.Trim(parentID, " ") == "" {
- c.ResultNull()
- } else {
- c.ResultText(parentID)
- }
- case 10:
- //parent_count
- parentIDs := strings.Split(current.ParentID, " ")
- if len(parentIDs) > 0 && parentIDs[0] == "" {
- c.ResultInt(0)
- } else {
- c.ResultInt(len(parentIDs))
- }
- case 11:
- //tree_id
- c.ResultText(current.TreeID)
- }
- return nil
-}
-
-func (vc *commitCLICursor) Rowid() (int64, error) {
- return int64(0), nil
-}
-
-func (vc *commitCLICursor) Close() error {
- return nil
-}
diff --git a/tables/internal/git/log_cli_test.go b/tables/internal/git/log_cli_test.go
deleted file mode 100644
index 838a975f..00000000
--- a/tables/internal/git/log_cli_test.go
+++ /dev/null
@@ -1,92 +0,0 @@
-// +build ignore
-
-package git_test
-
-import (
- "testing"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-func TestCommitCounts(t *testing.T) {
- revWalk, err := fixtureRepo.Walk()
- if err != nil {
- t.Fatal(err)
- }
- defer revWalk.Free()
-
- err = revWalk.PushHead()
- if err != nil {
- t.Fatal(err)
- }
-
- commitCount := 0
- err = revWalk.Iterate(func(c *git.Commit) bool {
- commitCount++
- return true
- })
- if err != nil {
- t.Fatal(err)
- }
-
- //checks commits
- rows, err := fixtureDB.Query("SELECT * FROM commits_cli")
- if err != nil {
- t.Fatal(err)
- }
- defer rows.Close()
- columns, err := rows.Columns()
- if err != nil {
- t.Fatal(err)
- }
- expected := 11
- if len(columns) != expected {
- t.Fatalf("expected %d columns, got: %d", expected, len(columns))
- }
- numRows := GetRowsCount(rows)
-
- expected = commitCount
- if numRows != expected {
- t.Fatalf("expected %d rows got: %d", expected, numRows)
- }
-
- rows, err = fixtureDB.Query("SELECT id, author_name FROM commits_cli")
- if err != nil {
- t.Fatal(err)
- }
- rowNum, contents, err := GetRowContents(rows)
- if err != nil {
- t.Fatalf("err %d at row Number %d", err, rowNum)
- }
-
- i := 0
- err = revWalk.Iterate(func(commit *git.Commit) bool {
- c := contents[i]
- if commit.Id().String() != c[0] {
- t.Fatalf("expected %s at row %d got %s", commit.Id().String(), i, c[0])
- }
-
- if commit.Author().Name != c[1] {
- t.Fatalf("expected %s at row %d got %s", commit.Author().Name, i, c[1])
- }
-
- i++
- return true
- })
- if err != nil {
- t.Fatal(err)
- }
-
-}
-func BenchmarkCLICommitCounts(b *testing.B) {
- for i := 0; i < b.N; i++ {
- rows, err := fixtureDB.Query("SELECT * FROM commits")
- if err != nil {
- b.Fatal(err)
- }
- rowNum, _, err := GetRowContents(rows)
- if err != nil {
- b.Fatalf("err %d at row Number %d", err, rowNum)
- }
- }
-}
diff --git a/tables/internal/git/log_test.go b/tables/internal/git/log_test.go
index d50b24de..844d9f06 100644
--- a/tables/internal/git/log_test.go
+++ b/tables/internal/git/log_test.go
@@ -1,128 +1,112 @@
-package git
+package git_test
import (
- "fmt"
+ "database/sql"
+ "os"
"testing"
-
- git "github.com/libgit2/git2go/v31"
+ "time"
)
-func TestCommits(t *testing.T) {
- revWalk, err := fixtureRepo.Walk()
- if err != nil {
- t.Fatal(err)
- }
- defer revWalk.Free()
+func TestSelectAllCommits(t *testing.T) {
+ db := Connect(t, Memory)
+ repo, ref := "https://github.com/askgitdev/askgit", "HEAD"
- err = revWalk.PushHead()
+ rows, err := db.Query("SELECT * FROM commits(?, ?) LIMIT 5", repo, ref)
if err != nil {
- t.Fatal(err)
- }
-
- commitCount := 0
- err = revWalk.Iterate(func(c *git.Commit) bool {
- commitCount++
- return true
- })
- if err != nil {
- t.Fatal(err)
- }
-
- //checks commits
- rows, err := fixtureDB.Query("SELECT * FROM commits")
- if err != nil {
- t.Fatal(err)
+ t.Fatalf("failed to execute query: %v", err.Error())
}
defer rows.Close()
- columns, err := rows.Columns()
- if err != nil {
- t.Fatal(err)
+ for rows.Next() {
+ var hash, message string
+ var authorName, authorEmail, authorWhen string
+ var committerName, committerEmail, committerWhen string
+ var parents int
+ err = rows.Scan(&hash, &message, &authorName, &authorEmail, &authorWhen, &committerName, &committerEmail, &committerWhen, &parents)
+ if err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("commit: hash=%q author=\"%s <%s>\" committer=\"%s <%s>\" parents=%d", hash, authorName, authorEmail, committerName, committerEmail, parents)
}
- expected := 11
- if len(columns) != expected {
- t.Fatalf("expected %d columns, got: %d", expected, len(columns))
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
}
- numRows := GetRowsCount(rows)
+}
- expected = commitCount
- if numRows != expected {
- t.Fatalf("expected %d rows got: %d", expected, numRows)
- }
+func TestSelectCommitByHash(t *testing.T) {
+ db := Connect(t, Memory)
+ repo, ref := "https://github.com/askgitdev/askgit", "HEAD"
+ hash := "5ce802c851d3bedb5bb4a0f749093cae9a34818b"
- rows, err = fixtureDB.Query("SELECT id, author_name FROM commits")
- if err != nil {
- t.Fatal(err)
- }
- rowNum, contents, err := GetRowContents(rows)
+ var message, email string
+ var when time.Time
+ err := db.QueryRow("SELECT message, committer_email, committer_when FROM commits(?, ?) WHERE hash = ?",
+ repo, ref, hash).Scan(&message, &email, &when)
if err != nil {
- t.Fatalf("err %d at row Number %d", err, rowNum)
+ t.Fatalf("failed to execute query: %v", err.Error())
}
- i := 0
- err = revWalk.Iterate(func(commit *git.Commit) bool {
- c := contents[i]
- if commit.Id().String() != c[0] {
- t.Fatalf("expected %s at row %d got %s", commit.Id().String(), i, c[0])
- }
-
- if commit.Author().Name != c[1] {
- t.Fatalf("expected %s at row %d got %s", commit.Author().Name, i, c[1])
- }
-
- i++
- return true
- })
- if err != nil {
- t.Fatal(err)
- }
+ t.Logf("commit: %q by %q on %q", hash, email, when.Format(time.RFC3339))
}
-func TestCommitByID(t *testing.T) {
- o, err := fixtureRepo.RevparseSingle("HEAD~3")
- if err != nil {
- t.Fatal(err)
- }
- defer o.Free()
+func TestDateFilterOnCommit(t *testing.T) {
+ db := Connect(t, Memory)
+ repo := "https://github.com/askgitdev/askgit"
- commit, err := o.AsCommit()
+ rows, err := db.Query("SELECT hash, committer_email, committer_when FROM commits(?)"+
+ " WHERE committer_when > DATE(?) AND committer_when < DATE(?) ORDER BY committer_when DESC",
+ repo, time.Date(2021, 01, 01, 00, 00, 00, 00, time.UTC), time.Date(2021, 04, 30, 00, 00, 00, 00, time.UTC))
if err != nil {
- t.Fatal(err)
+ t.Fatalf("failed to execute query: %v", err.Error())
}
- defer commit.Free()
+ defer rows.Close()
- rows, err := fixtureDB.Query(fmt.Sprintf("SELECT * FROM commits WHERE id = '%s'", commit.Id().String()))
- if err != nil {
- t.Fatal(err)
+ for rows.Next() {
+ var hash, email string
+ var when time.Time
+ if err = rows.Scan(&hash, &email, &when); err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("commit: %q by %q on %q", hash, email, when.Format(time.RFC3339))
}
- defer rows.Close()
- _, contents, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
}
+}
- count := len(contents)
+func TestDefaultCases(t *testing.T) {
+ db := Connect(t, Memory)
+ repo := "https://github.com/askgitdev/askgit"
- if count != 1 {
- t.Fatalf("expected 1 commit, got %d", count)
+ var q = func(row *sql.Row) (hash, email string, when time.Time, err error) {
+ err = row.Scan(&hash, &email, &when)
+ return
}
- if contents[0][0] != commit.Id().String() {
- t.Fatalf("expected commit ID: %s, got %s", commit.Id().String(), contents[0][0])
- }
-}
+ t.Run("should use current working directory as default repository", func(t *testing.T) {
+ if ci, ok := os.LookupEnv("CI"); ok && ci == "true" {
+ t.Skip("skipping test as current working directory cannot be set in ci environment")
+ }
-func BenchmarkCommitCounts(b *testing.B) {
- for i := 0; i < b.N; i++ {
- rows, err := fixtureDB.Query("SELECT * FROM commits")
+ err := os.Chdir("../../../")
if err != nil {
- b.Fatal(err)
+ t.Fatalf("failed to change working directory: %v", err)
}
- rowNum, _, err := GetRowContents(rows)
+
+ _, _, _, err = q(db.QueryRow("SELECT hash, committer_email, committer_when FROM commits LIMIT 1"))
if err != nil {
- b.Fatalf("err %d at row Number %d", err, rowNum)
+ t.Error(err)
+ t.Fail()
}
- }
+ })
+
+ t.Run("should use head as the default reference", func(t *testing.T) {
+ _, _, _, err := q(db.QueryRow("SELECT hash, committer_email, committer_when FROM commits(?) LIMIT 1", repo))
+ if err != nil {
+ t.Error(err)
+ t.Fail()
+ }
+ })
}
diff --git a/tables/internal/git/native/blame.go b/tables/internal/git/native/blame.go
new file mode 100644
index 00000000..030d55ca
--- /dev/null
+++ b/tables/internal/git/native/blame.go
@@ -0,0 +1,183 @@
+package native
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "os"
+
+ "github.com/askgitdev/askgit/tables/internal/git"
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/augmentable-dev/vtab"
+ "github.com/go-git/go-git/v5/storage/filesystem"
+ libgit2 "github.com/libgit2/git2go/v31"
+ "github.com/pkg/errors"
+ "go.riyazali.net/sqlite"
+)
+
+var blameCols = []vtab.Column{
+ {Name: "line_no", Type: sqlite.SQLITE_TEXT, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+ // {Name: "line_content", Type: sqlite.SQLITE_TEXT, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+ {Name: "commit_hash", Type: sqlite.SQLITE_TEXT, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+
+ {Name: "repository", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, OmitCheck: true}}, OrderBy: vtab.NONE},
+ {Name: "rev", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, Required: true, OmitCheck: true}}, OrderBy: vtab.NONE},
+ {Name: "file_path", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, Required: true, OmitCheck: true}}, OrderBy: vtab.NONE},
+}
+
+// NewBlameModule returns the implementation of a table-valued-function for accessing git blame
+func NewBlameModule(locator services.RepoLocator, ctx services.Context) sqlite.Module {
+ return vtab.NewTableFunc("blame", blameCols, func(constraints []*vtab.Constraint, order []*sqlite.OrderBy) (vtab.Iterator, error) {
+ var repoPath, rev, filePath string
+ for _, constraint := range constraints {
+ if constraint.Op == sqlite.INDEX_CONSTRAINT_EQ {
+ switch constraint.ColIndex {
+ case 2:
+ repoPath = constraint.Value.Text()
+ case 3:
+ rev = constraint.Value.Text()
+ case 4:
+ filePath = constraint.Value.Text()
+ }
+ }
+ }
+
+ if filePath == "" {
+ return nil, fmt.Errorf("blame table requires a file path")
+ }
+
+ if repoPath == "" {
+ var err error
+ repoPath, err = git.GetDefaultRepoFromCtx(ctx)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return newBlameIter(locator, repoPath, rev, filePath)
+ })
+}
+
+func newBlameIter(locator services.RepoLocator, repoPath, rev, filePath string) (*blameIter, error) {
+ iter := &blameIter{
+ repoPath: repoPath,
+ rev: rev,
+ filePath: filePath,
+ index: -1,
+ }
+
+ if repoPath == "" {
+ if wd, err := os.Getwd(); err != nil {
+ return nil, err
+ } else {
+ repoPath = wd
+ }
+ }
+
+ r, err := locator.Open(context.Background(), repoPath)
+ if err != nil {
+ return nil, err
+ }
+
+ fsStorer, ok := r.Storer.(*filesystem.Storage)
+ if !ok {
+ return nil, fmt.Errorf("blame table only supported on filesystem backed git repos")
+ }
+
+ repo, err := libgit2.OpenRepository(fsStorer.Filesystem().Root())
+ if err != nil {
+ return nil, err
+ }
+ defer repo.Free()
+
+ var commitID *libgit2.Oid
+ // if no rev is supplied, use HEAD
+ if rev == "" {
+ head, err := repo.Head()
+ if err != nil {
+ return nil, err
+ }
+ commitID = head.Target()
+ } else {
+ obj, err := repo.RevparseSingle(rev)
+ if err != nil {
+ return nil, err
+ }
+ defer obj.Free()
+
+ if obj.Type() != libgit2.ObjectCommit {
+ return nil, fmt.Errorf("invalid rev, could not resolve to a commit")
+ }
+
+ commitID = obj.Id()
+ }
+
+ opts, err := libgit2.DefaultBlameOptions()
+ if err != nil {
+ return nil, err
+ }
+
+ opts.NewestCommit = commitID
+
+ blame, err := repo.BlameFile(filePath, &opts)
+ if err != nil {
+ return nil, err
+ }
+ defer func() {
+ err := blame.Free()
+ if err != nil {
+ fmt.Println(err) // TODO(patrickdevivo) figure out a better handling here
+ }
+ }()
+
+ iter.lines = make([]*blamedLine, 0)
+ fileLine := 1
+ for {
+ hunk, err := blame.HunkByLine(fileLine)
+ if err != nil {
+ if errors.Is(err, libgit2.ErrInvalid) {
+ break
+ }
+ return nil, err
+ }
+ iter.lines = append(iter.lines, &blamedLine{
+ hunk: &hunk,
+ lineNo: fileLine,
+ })
+ fileLine++
+ }
+
+ return iter, nil
+}
+
+type blamedLine struct {
+ lineNo int
+ hunk *libgit2.BlameHunk
+}
+
+type blameIter struct {
+ repoPath string
+ rev string
+ filePath string
+ lines []*blamedLine
+ index int
+}
+
+func (i *blameIter) Column(ctx *sqlite.Context, c int) error {
+ currentLine := i.lines[i.index]
+ switch c {
+ case 0:
+ ctx.ResultInt(currentLine.lineNo)
+ case 1:
+ ctx.ResultText(currentLine.hunk.OrigCommitId.String())
+ }
+ return nil
+}
+
+func (i *blameIter) Next() (vtab.Row, error) {
+ i.index++
+ if i.index >= len(i.lines) {
+ return nil, io.EOF
+ }
+ return i, nil
+}
diff --git a/tables/internal/git/native/blame_test.go b/tables/internal/git/native/blame_test.go
new file mode 100644
index 00000000..be30cf09
--- /dev/null
+++ b/tables/internal/git/native/blame_test.go
@@ -0,0 +1,83 @@
+package native_test
+
+import (
+ "encoding/csv"
+ "fmt"
+ "os"
+ "strconv"
+ "testing"
+)
+
+func TestSelectBlameREADMELines(t *testing.T) {
+ db := Connect(t, Memory)
+ repo := "https://github.com/askgitdev/askgit"
+
+ rows, err := db.Query("SELECT line_no, commit_hash FROM blame(?, '', 'README.md') LIMIT 10", repo)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var commitHash string
+ var lineNo int
+ err = rows.Scan(&lineNo, &commitHash)
+ if err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("blame: line_no=%d commit_hash=%s", lineNo, commitHash)
+ }
+
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
+ }
+}
+
+func TestSelectKnownBlame(t *testing.T) {
+ db := Connect(t, Memory)
+ repo, hash := "https://github.com/askgitdev/askgit", "2359c9a9ba0ba8aa694601ff12538c4e74b82cd5"
+
+ rows, err := db.Query("SELECT line_no, commit_hash FROM blame(?, ?, 'README.md')", repo, hash)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+ defer rows.Close()
+
+ fixtureFileName := "README.md.blame.csv.testdata"
+ f, err := os.Open(fmt.Sprintf("./testdata/%s/%s", hash, fixtureFileName))
+ if err != nil {
+ t.Fatalf("failed to open fixture file %s: %v", fixtureFileName, err.Error())
+ }
+
+ r := csv.NewReader(f)
+ fixtureRecords, err := r.ReadAll()
+ if err != nil {
+ t.Fatalf("failed to parse CSV in fixture file %s: %v", fixtureFileName, err.Error())
+ }
+
+ i := 0
+ for rows.Next() {
+ var commitHash string
+ var lineNo int
+ err = rows.Scan(&lineNo, &commitHash)
+ if err != nil {
+ t.Fatalf("failed to scan resultset: %v", err.Error())
+ }
+ t.Logf("blame: line_no=%d commit_hash=%s", lineNo, commitHash)
+
+ i++
+ fixtureRow := fixtureRecords[i]
+ fixtureLine, fixtureHash := fixtureRow[0], fixtureRow[1]
+ if strconv.Itoa(lineNo) != fixtureLine {
+ t.Fatalf("expected line: %s, got: %d", fixtureLine, lineNo)
+ }
+
+ if commitHash != fixtureHash {
+ t.Fatalf("expected hash: %s, got: %d", fixtureLine, lineNo)
+ }
+ }
+
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
+ }
+}
diff --git a/tables/internal/git/native/doc.go b/tables/internal/git/native/doc.go
new file mode 100644
index 00000000..93e72392
--- /dev/null
+++ b/tables/internal/git/native/doc.go
@@ -0,0 +1,5 @@
+// Package native provides virtual table implementations for git tables using libgit2
+// via the git2go bindings (https://github.com/libgit2/git2go).
+// Some operations are more performant using libgit2 vs go-git, namely, what's involved in
+// the `stats`, `files` and `blame` tables, which are implemented in this package.
+package native
diff --git a/tables/internal/git/native/files.go b/tables/internal/git/native/files.go
new file mode 100644
index 00000000..6ef1c1ab
--- /dev/null
+++ b/tables/internal/git/native/files.go
@@ -0,0 +1,182 @@
+package native
+
+import (
+ "context"
+ "fmt"
+ "io"
+ "os"
+ "path"
+
+ "github.com/askgitdev/askgit/tables/internal/git"
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/augmentable-dev/vtab"
+ "github.com/go-git/go-git/v5/storage/filesystem"
+ libgit2 "github.com/libgit2/git2go/v31"
+ "go.riyazali.net/sqlite"
+)
+
+var filesCols = []vtab.Column{
+ {Name: "path", Type: sqlite.SQLITE_TEXT, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+ {Name: "executable", Type: sqlite.SQLITE_INTEGER, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+ {Name: "contents", Type: sqlite.SQLITE_BLOB, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+
+ {Name: "repository", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, OmitCheck: true}}, OrderBy: vtab.NONE},
+ {Name: "rev", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, Required: true, OmitCheck: true}}, OrderBy: vtab.NONE},
+}
+
+// NewFilesModule returns the implementation of a table-valued-function for accessing the content of files in git
+func NewFilesModule(locator services.RepoLocator, ctx services.Context) sqlite.Module {
+ return vtab.NewTableFunc("files", filesCols, func(constraints []*vtab.Constraint, order []*sqlite.OrderBy) (vtab.Iterator, error) {
+ var repoPath, rev string
+ for _, constraint := range constraints {
+ if constraint.Op == sqlite.INDEX_CONSTRAINT_EQ {
+ switch constraint.ColIndex {
+ case 3:
+ repoPath = constraint.Value.Text()
+ case 4:
+ rev = constraint.Value.Text()
+ }
+ }
+ }
+
+ if repoPath == "" {
+ var err error
+ repoPath, err = git.GetDefaultRepoFromCtx(ctx)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return newFilesIter(locator, repoPath, rev)
+ })
+}
+
+func newFilesIter(locator services.RepoLocator, repoPath, rev string) (*filesIter, error) {
+ iter := &filesIter{
+ repoPath: repoPath,
+ rev: rev,
+ index: -1,
+ }
+
+ if repoPath == "" {
+ if wd, err := os.Getwd(); err != nil {
+ return nil, err
+ } else {
+ repoPath = wd
+ }
+ }
+
+ r, err := locator.Open(context.Background(), repoPath)
+ if err != nil {
+ return nil, err
+ }
+
+ fsStorer, ok := r.Storer.(*filesystem.Storage)
+ if !ok {
+ return nil, fmt.Errorf("file table only supported on filesystem backed git repos")
+ }
+
+ repo, err := libgit2.OpenRepository(fsStorer.Filesystem().Root())
+ if err != nil {
+ return nil, err
+ }
+ iter.repo = repo
+
+ var commitID *libgit2.Oid
+ var commit *libgit2.Commit
+ // if no rev is supplied, use HEAD
+ if rev == "" {
+ head, err := repo.Head()
+ if err != nil {
+ return nil, err
+ }
+ commitID = head.Target()
+ } else {
+ obj, err := repo.RevparseSingle(rev)
+ if err != nil {
+ return nil, err
+ }
+ defer obj.Free()
+
+ if obj.Type() != libgit2.ObjectCommit {
+ return nil, fmt.Errorf("invalid rev, could not resolve to a commit")
+ }
+
+ commitID = obj.Id()
+ }
+ commit, err = repo.LookupCommit(commitID)
+ if err != nil {
+ return nil, err
+ }
+ defer commit.Free()
+
+ tree, err := commit.Tree()
+ if err != nil {
+ return nil, err
+ }
+
+ iter.files = make([]*file, 0, tree.EntryCount())
+ err = tree.Walk(func(p string, treeEntry *libgit2.TreeEntry) int {
+ if treeEntry.Type != libgit2.ObjectBlob {
+ return 0
+ }
+ iter.files = append(iter.files, &file{
+ id: treeEntry.Id,
+ path: path.Join(p, treeEntry.Name),
+ executable: treeEntry.Filemode == libgit2.FilemodeBlobExecutable,
+ })
+ return 0
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ return iter, nil
+}
+
+type file struct {
+ id *libgit2.Oid
+ path string
+ executable bool
+}
+
+type filesIter struct {
+ repoPath string
+ rev string
+ files []*file
+ index int
+ repo *libgit2.Repository
+}
+
+func (i *filesIter) Column(ctx *sqlite.Context, c int) error {
+ currentFile := i.files[i.index]
+ switch c {
+ case 0:
+ ctx.ResultText(currentFile.path)
+ case 1:
+ if currentFile.executable {
+ ctx.ResultInt(1)
+ } else {
+ ctx.ResultInt(0)
+ }
+ case 2:
+ blob, err := i.repo.LookupBlob(currentFile.id)
+ if err != nil {
+ return err
+ }
+ defer blob.Free()
+ ctx.ResultText(string(blob.Contents()))
+ }
+ return nil
+}
+
+func (i *filesIter) Next() (vtab.Row, error) {
+ i.index++
+ if i.index >= len(i.files) {
+ if i.repo != nil {
+ i.repo.Free()
+ }
+ return nil, io.EOF
+ }
+ return i, nil
+}
diff --git a/tables/internal/git/native/files_test.go b/tables/internal/git/native/files_test.go
new file mode 100644
index 00000000..db9f70ca
--- /dev/null
+++ b/tables/internal/git/native/files_test.go
@@ -0,0 +1,65 @@
+package native_test
+
+import (
+ "fmt"
+ "io/ioutil"
+ "testing"
+)
+
+func TestSelect10FilesHEAD(t *testing.T) {
+ db := Connect(t, Memory)
+ repo := "https://github.com/askgitdev/askgit"
+
+ rows, err := db.Query("SELECT path, executable, contents FROM files(?) LIMIT 10", repo)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var path, contents string
+ var executable int
+ err = rows.Scan(&path, &executable, &contents)
+ if err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("file: path=%s executable=%d contents_len=%d", path, executable, len(contents))
+ }
+
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
+ }
+}
+
+func TestSelectKnownContents(t *testing.T) {
+ db := Connect(t, Memory)
+ repo, hash := "https://github.com/askgitdev/askgit", "2359c9a9ba0ba8aa694601ff12538c4e74b82cd5"
+
+ rows, err := db.Query("SELECT path, contents FROM files(?, ?) WHERE path LIKE 'Makefile' OR path LIKE 'go.mod'", repo, hash)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var path, contents string
+ err = rows.Scan(&path, &contents)
+ if err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("file: path=%s contents_len=%d", path, len(contents))
+
+ expectedFileContents, err := ioutil.ReadFile(fmt.Sprintf("./testdata/%s/%s.testdata", hash, path))
+ if err != nil {
+ t.Fatalf("failed to load fixture file: %v", err)
+ }
+
+ if contents != string(expectedFileContents) {
+ t.Fatalf("contents of %s files do not match", path)
+ }
+ }
+
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
+ }
+}
diff --git a/tables/internal/git/native/native_test.go b/tables/internal/git/native/native_test.go
new file mode 100644
index 00000000..1370a773
--- /dev/null
+++ b/tables/internal/git/native/native_test.go
@@ -0,0 +1,43 @@
+package native_test
+
+import (
+ "database/sql"
+ "os"
+ "testing"
+
+ "github.com/askgitdev/askgit/pkg/locator"
+ _ "github.com/askgitdev/askgit/pkg/sqlite"
+ "github.com/askgitdev/askgit/tables"
+ _ "github.com/mattn/go-sqlite3"
+ "go.riyazali.net/sqlite"
+)
+
+func init() {
+ // register sqlite extension when this package is loaded
+ sqlite.Register(tables.RegisterFn(
+ tables.WithExtraFunctions(), tables.WithRepoLocator(locator.CachedLocator(locator.MultiLocator())),
+ ))
+}
+
+// tests' entrypoint that registers the extension
+// automatically with all loaded database connections
+func TestMain(m *testing.M) { os.Exit(m.Run()) }
+
+// Memory represents a uri to an in-memory database
+const Memory = "file:testing.db?mode=memory"
+
+// Connect opens a connection with the sqlite3 database using
+// the given data source address and pings it to check liveliness.
+func Connect(t *testing.T, dataSourceName string) *sql.DB {
+ t.Helper()
+ db, err := sql.Open("sqlite3", dataSourceName)
+ if err != nil {
+ t.Fatalf("failed to open connection: %v", err.Error())
+ }
+
+ if err = db.Ping(); err != nil {
+ t.Fatalf("failed to open connection: %v", err.Error())
+ }
+
+ return db
+}
diff --git a/tables/internal/git/native/stats.go b/tables/internal/git/native/stats.go
new file mode 100644
index 00000000..bafa353b
--- /dev/null
+++ b/tables/internal/git/native/stats.go
@@ -0,0 +1,220 @@
+package native
+
+import (
+ "context"
+ "fmt"
+ "io"
+
+ "github.com/askgitdev/askgit/tables/internal/git"
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/augmentable-dev/vtab"
+ "github.com/go-git/go-git/v5/storage/filesystem"
+ libgit2 "github.com/libgit2/git2go/v31"
+ "go.riyazali.net/sqlite"
+)
+
+var statsCols = []vtab.Column{
+ {Name: "file_path", Type: sqlite.SQLITE_TEXT, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+ {Name: "additions", Type: sqlite.SQLITE_INTEGER, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+ {Name: "deletions", Type: sqlite.SQLITE_INTEGER, NotNull: false, Hidden: false, Filters: nil, OrderBy: vtab.NONE},
+
+ {Name: "repository", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, OmitCheck: true}}, OrderBy: vtab.NONE},
+ {Name: "rev", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, Required: true, OmitCheck: true}}, OrderBy: vtab.NONE},
+ {Name: "to_rev", Type: sqlite.SQLITE_TEXT, NotNull: true, Hidden: true, Filters: []*vtab.ColumnFilter{{Op: sqlite.INDEX_CONSTRAINT_EQ, OmitCheck: true}}, OrderBy: vtab.NONE},
+}
+
+// NewStatsModule returns the implementation of a table-valued-function for git stats
+func NewStatsModule(locator services.RepoLocator, ctx services.Context) sqlite.Module {
+ return vtab.NewTableFunc("stats", statsCols, func(constraints []*vtab.Constraint, order []*sqlite.OrderBy) (vtab.Iterator, error) {
+ var repoPath, rev, toRev string
+ for _, constraint := range constraints {
+ if constraint.Op == sqlite.INDEX_CONSTRAINT_EQ {
+ switch constraint.ColIndex {
+ case 3:
+ repoPath = constraint.Value.Text()
+ case 4:
+ rev = constraint.Value.Text()
+ case 5:
+ toRev = constraint.Value.Text()
+ }
+ }
+ }
+
+ if repoPath == "" {
+ var err error
+ repoPath, err = git.GetDefaultRepoFromCtx(ctx)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ return newStatsIter(locator, repoPath, rev, toRev)
+ })
+}
+
+func newStatsIter(locator services.RepoLocator, repoPath, rev, toRev string) (*statsIter, error) {
+ iter := &statsIter{
+ repoPath: repoPath,
+ index: -1,
+ }
+
+ r, err := locator.Open(context.Background(), repoPath)
+ if err != nil {
+ return nil, err
+ }
+
+ fsStorer, ok := r.Storer.(*filesystem.Storage)
+ if !ok {
+ return nil, fmt.Errorf("stats table only supported on filesystem backed git repos")
+ }
+
+ repo, err := libgit2.OpenRepository(fsStorer.Filesystem().Root())
+ if err != nil {
+ return nil, err
+ }
+ defer repo.Free()
+
+ var fromCommit *libgit2.Commit
+ // if no rev is supplied, use HEAD
+ if rev == "" {
+ head, err := repo.Head()
+ if err != nil {
+ return nil, err
+ }
+ fromCommit, err = repo.LookupCommit(head.Target())
+ if err != nil {
+ return nil, err
+ }
+ } else {
+ obj, err := repo.RevparseSingle(rev)
+ if err != nil {
+ return nil, err
+ }
+ defer obj.Free()
+
+ if obj.Type() != libgit2.ObjectCommit {
+ return nil, fmt.Errorf("invalid rev, could not resolve to a commit")
+ }
+
+ fromCommit, err = repo.LookupCommit(obj.Id())
+ if err != nil {
+ return nil, err
+ }
+ }
+ defer fromCommit.Free()
+
+ tree, err := fromCommit.Tree()
+ if err != nil {
+ return nil, err
+ }
+ defer tree.Free()
+
+ var toCommit *libgit2.Commit
+ if toRev == "" {
+ toCommit = fromCommit.Parent(0)
+ } else {
+ id, err := libgit2.NewOid(toRev)
+ if err != nil {
+ return nil, fmt.Errorf("invalid to_rev: %v", err)
+ }
+
+ toCommit, err = repo.LookupCommit(id)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ var toTree *libgit2.Tree
+ if toCommit == nil {
+ toTree = &libgit2.Tree{}
+ } else {
+ toTree, err = toCommit.Tree()
+ if err != nil {
+ return nil, err
+ }
+ defer toCommit.Free()
+ }
+ defer toTree.Free()
+
+ diffOpts, err := libgit2.DefaultDiffOptions()
+ if err != nil {
+ return nil, err
+ }
+
+ diff, err := repo.DiffTreeToTree(toTree, tree, &diffOpts)
+ if err != nil {
+ return nil, err
+ }
+ defer func() {
+ err := diff.Free()
+ if err != nil {
+ // TODO what should we do here?
+ fmt.Println(err)
+ }
+ }()
+
+ diffFindOpts, err := libgit2.DefaultDiffFindOptions()
+ if err != nil {
+ return nil, err
+ }
+
+ err = diff.FindSimilar(&diffFindOpts)
+ if err != nil {
+ return nil, err
+ }
+
+ iter.stats = make([]*stat, 0)
+ err = diff.ForEach(func(delta libgit2.DiffDelta, progress float64) (libgit2.DiffForEachHunkCallback, error) {
+ stat := &stat{filePath: delta.NewFile.Path}
+ iter.stats = append(iter.stats, stat)
+ return func(hunk libgit2.DiffHunk) (libgit2.DiffForEachLineCallback, error) {
+ return func(line libgit2.DiffLine) error {
+ switch line.Origin {
+ case libgit2.DiffLineAddition:
+ stat.additions++
+ case libgit2.DiffLineDeletion:
+ stat.deletions++
+ }
+ return nil
+ }, nil
+ }, nil
+ }, libgit2.DiffDetailLines)
+ if err != nil {
+ return nil, err
+ }
+
+ return iter, nil
+}
+
+type stat struct {
+ filePath string
+ additions int
+ deletions int
+}
+
+type statsIter struct {
+ repoPath string
+ stats []*stat
+ index int
+}
+
+func (i *statsIter) Column(ctx *sqlite.Context, c int) error {
+ currentStat := i.stats[i.index]
+ switch c {
+ case 0:
+ ctx.ResultText(currentStat.filePath)
+ case 1:
+ ctx.ResultInt(currentStat.additions)
+ case 2:
+ ctx.ResultInt(currentStat.deletions)
+ }
+ return nil
+}
+
+func (i *statsIter) Next() (vtab.Row, error) {
+ i.index++
+ if i.index >= len(i.stats) {
+ return nil, io.EOF
+ }
+ return i, nil
+}
diff --git a/tables/internal/git/native/stats_test.go b/tables/internal/git/native/stats_test.go
new file mode 100644
index 00000000..f593e819
--- /dev/null
+++ b/tables/internal/git/native/stats_test.go
@@ -0,0 +1,86 @@
+package native_test
+
+import (
+ "testing"
+)
+
+func TestSelectLast5CommitStats(t *testing.T) {
+ db := Connect(t, Memory)
+ repo := "https://github.com/askgitdev/askgit"
+
+ rows, err := db.Query("SELECT commits.hash, file_path, additions, deletions FROM commits($1), stats($1, commits.hash) LIMIT 5", repo)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var hash, filePath string
+ var additions, deletions int
+ err = rows.Scan(&hash, &filePath, &additions, &deletions)
+ if err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("stat: hash=%q file_path=%s additions=%d deletions=%d", hash, filePath, additions, deletions)
+ }
+
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
+ }
+}
+
+func TestInitialCommitStats(t *testing.T) {
+ db := Connect(t, Memory)
+ repo, initialCommit := "https://github.com/askgitdev/askgit", "a4562d2d5a35536771745b0aa19d705eb47234e7"
+
+ var filesChanged, additions, deletions int
+ err := db.QueryRow("SELECT count(DISTINCT file_path), sum(additions), sum(deletions) FROM stats(?, ?)", repo, initialCommit).
+ Scan(&filesChanged, &additions, &deletions)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+
+ t.Logf("stat: files_changed=%d additions=%d deletions=%d", filesChanged, additions, deletions)
+
+ expectedFilesChanged, expectedAdditions, expectedDeletions := 13, 1612, 0
+
+ if filesChanged != expectedFilesChanged {
+ t.Fatalf("expected %d files changed, got %d", expectedFilesChanged, filesChanged)
+ }
+
+ if additions != expectedAdditions {
+ t.Fatalf("expected %d additions, got %d", expectedAdditions, additions)
+ }
+
+ if deletions != expectedDeletions {
+ t.Fatalf("expected %d deletions, got %d", expectedDeletions, deletions)
+ }
+}
+
+func TestFromAndToStats(t *testing.T) {
+ db := Connect(t, Memory)
+ repo, fromHash, toHash := "https://github.com/askgitdev/askgit", "2359c9a9ba0ba8aa694601ff12538c4e74b82cd5", "d65736fd08fab5a64027f0c050ee148d88549406"
+
+ var filesChanged, additions, deletions int
+ err := db.QueryRow("SELECT count(DISTINCT file_path), sum(additions), sum(deletions) FROM stats(?, ?, ?)", repo, fromHash, toHash).
+ Scan(&filesChanged, &additions, &deletions)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+
+ t.Logf("stat: files_changed=%d additions=%d deletions=%d", filesChanged, additions, deletions)
+
+ expectedFilesChanged, expectedAdditions, expectedDeletions := 5, 13, 13
+
+ if filesChanged != expectedFilesChanged {
+ t.Fatalf("expected %d files changed, got %d", expectedFilesChanged, filesChanged)
+ }
+
+ if additions != expectedAdditions {
+ t.Fatalf("expected %d additions, got %d", expectedAdditions, additions)
+ }
+
+ if deletions != expectedDeletions {
+ t.Fatalf("expected %d deletions, got %d", expectedDeletions, deletions)
+ }
+}
diff --git a/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/Makefile.testdata b/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/Makefile.testdata
new file mode 100644
index 00000000..e4c84d33
--- /dev/null
+++ b/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/Makefile.testdata
@@ -0,0 +1,86 @@
+.PHONY: clean vet test lint lint-ci test-cover bench
+
+# default task invoked while running make
+all: clean .build/libaskgit.so .build/askgit
+
+# pass these flags to linker to suppress missing symbol errors in intermediate artifacts
+export CGO_CFLAGS = -DUSE_LIBSQLITE3
+export CPATH = ${PWD}/pkg/sqlite
+export CGO_LDFLAGS = -Wl,--unresolved-symbols=ignore-in-object-files
+ifeq ($(shell uname -s),Darwin)
+ export CGO_LDFLAGS = -Wl,-undefined,dynamic_lookup
+endif
+
+# target to build a dynamic extension that can be loaded at runtime
+.build/libaskgit.so: $(shell find . -type f -name '*.go' -o -name '*.c')
+ $(call log, $(CYAN), "building $@")
+ @go build -buildmode=c-shared -o $@ -tags="system_libgit2,shared" shared.go
+ $(call log, $(GREEN), "built $@")
+
+# target to compile askgit executable
+.build/askgit: $(shell find . -type f -name '*.go' -o -name '*.c')
+ $(call log, $(CYAN), "building $@")
+ @go build -o $@ -tags="sqlite_vtable,vtable,sqlite_json1,static,system_libgit2" askgit.go
+ $(call log, $(GREEN), "built $@")
+
+# target to download latest sqlite3 amalgamation code
+pkg/sqlite/sqlite3.c:
+ $(call log, $(CYAN), "downloading sqlite3 amalgamation source v3.35.0")
+ $(eval SQLITE_DOWNLOAD_DIR = $(shell mktemp -d))
+ @curl -sSLo $(SQLITE_DOWNLOAD_DIR)/sqlite3.zip https://www.sqlite.org/2021/sqlite-amalgamation-3350000.zip
+ $(call log, $(GREEN), "downloaded sqlite3 amalgamation source v3.35.0")
+ $(call log, $(CYAN), "unzipping to $(SQLITE_DOWNLOAD_DIR)")
+ @(cd $(SQLITE_DOWNLOAD_DIR) && unzip sqlite3.zip > /dev/null)
+ @-rm $(SQLITE_DOWNLOAD_DIR)/sqlite-amalgamation-3350000/shell.c
+ $(call log, $(CYAN), "moving to pkg/sqlite")
+ @mv $(SQLITE_DOWNLOAD_DIR)/sqlite-amalgamation-3350000/* pkg/sqlite
+
+clean:
+ $(call log, $(YELLOW), "nuking .build/")
+ @-rm -rf .build/
+
+# ========================================
+# target for common golang tasks
+
+# go build tags used by test, vet and more
+TAGS = "sqlite_vtable,vtable,sqlite_json1,static,system_libgit2"
+
+vet:
+ go vet -v -tags=$(TAGS) ./...
+
+build:
+ go build -v -tags=$(TAGS) askgit.go
+
+lint:
+ golangci-lint run --build-tags $(TAGS)
+
+lint-ci:
+ ./bin/golangci-lint run --build-tags $(TAGS) --out-format github-actions
+
+test:
+ go test -v -tags=$(TAGS) ./...
+
+test-cover:
+ go test -v -tags=$(TAGS) ./... -cover -covermode=count -coverprofile=coverage.out
+ go tool cover -html=coverage.out
+
+bench:
+ go test -v -tags=$(TAGS) -bench=. -benchmem -run=^nomatch ./...
+
+# ========================================
+# some utility methods
+
+# ASCII color codes that can be used with functions that output to stdout
+RED := 1;31
+GREEN := 1;32
+ORANGE := 1;33
+YELLOW := 1;33
+BLUE := 1;34
+PURPLE := 1;35
+CYAN := 1;36
+
+# log:
+# print out $2 to stdout using $1 as ASCII color codes
+define log
+ @printf "\033[$(strip $1)m-- %s\033[0m\n" $2
+endef
diff --git a/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/README.md.blame.csv.testdata b/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/README.md.blame.csv.testdata
new file mode 100644
index 00000000..d7185f16
--- /dev/null
+++ b/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/README.md.blame.csv.testdata
@@ -0,0 +1,436 @@
+line_no,commit_hash
+1,d65736fd08fab5a64027f0c050ee148d88549406
+2,d65736fd08fab5a64027f0c050ee148d88549406
+3,d65736fd08fab5a64027f0c050ee148d88549406
+4,2091ef6ea2b61d56d4634ae6eb309c471cb2ce9a
+5,d65736fd08fab5a64027f0c050ee148d88549406
+6,a4562d2d5a35536771745b0aa19d705eb47234e7
+7,a4562d2d5a35536771745b0aa19d705eb47234e7
+8,6261f191abcfdb3901f80da3fe8b40026a306b41
+9,a4562d2d5a35536771745b0aa19d705eb47234e7
+10,6ea446b721a9b4189e8664553520fc9b8be27ed3
+11,a4562d2d5a35536771745b0aa19d705eb47234e7
+12,5ac571f021e4a0759819b02d76799e7347eb7ffc
+13,5ac571f021e4a0759819b02d76799e7347eb7ffc
+14,5ac571f021e4a0759819b02d76799e7347eb7ffc
+15,5ac571f021e4a0759819b02d76799e7347eb7ffc
+16,5ac571f021e4a0759819b02d76799e7347eb7ffc
+17,137317e0e42841df22ae31d3d4e49745fd09325b
+18,fea7d53b61095d6885cf4fddc9a9b0c5275cf249
+19,fea7d53b61095d6885cf4fddc9a9b0c5275cf249
+20,137317e0e42841df22ae31d3d4e49745fd09325b
+21,137317e0e42841df22ae31d3d4e49745fd09325b
+22,5ac571f021e4a0759819b02d76799e7347eb7ffc
+23,a4562d2d5a35536771745b0aa19d705eb47234e7
+24,6261f191abcfdb3901f80da3fe8b40026a306b41
+25,6261f191abcfdb3901f80da3fe8b40026a306b41
+26,6261f191abcfdb3901f80da3fe8b40026a306b41
+27,6261f191abcfdb3901f80da3fe8b40026a306b41
+28,6261f191abcfdb3901f80da3fe8b40026a306b41
+29,6261f191abcfdb3901f80da3fe8b40026a306b41
+30,6261f191abcfdb3901f80da3fe8b40026a306b41
+31,6261f191abcfdb3901f80da3fe8b40026a306b41
+32,6261f191abcfdb3901f80da3fe8b40026a306b41
+33,6261f191abcfdb3901f80da3fe8b40026a306b41
+34,ca4e34501bf50f72047bb81bea8a8fddaa33f2a3
+35,6261f191abcfdb3901f80da3fe8b40026a306b41
+36,6261f191abcfdb3901f80da3fe8b40026a306b41
+37,6261f191abcfdb3901f80da3fe8b40026a306b41
+38,6261f191abcfdb3901f80da3fe8b40026a306b41
+39,6261f191abcfdb3901f80da3fe8b40026a306b41
+40,6261f191abcfdb3901f80da3fe8b40026a306b41
+41,6261f191abcfdb3901f80da3fe8b40026a306b41
+42,8b1493a7cc7a0c47c09f461a6c80c667772db802
+43,6261f191abcfdb3901f80da3fe8b40026a306b41
+44,6261f191abcfdb3901f80da3fe8b40026a306b41
+45,6261f191abcfdb3901f80da3fe8b40026a306b41
+46,ce9feebcb238c2857a82fab22f8058d1249093ad
+47,a4562d2d5a35536771745b0aa19d705eb47234e7
+48,a4562d2d5a35536771745b0aa19d705eb47234e7
+49,e13700fcfb38bb69c39e14c749a2060f70b15e87
+50,e13700fcfb38bb69c39e14c749a2060f70b15e87
+51,e13700fcfb38bb69c39e14c749a2060f70b15e87
+52,b5a4e49cb78d1d34ca921c416d50bf192247c2de
+53,e13700fcfb38bb69c39e14c749a2060f70b15e87
+54,e13700fcfb38bb69c39e14c749a2060f70b15e87
+55,e13700fcfb38bb69c39e14c749a2060f70b15e87
+56,e13700fcfb38bb69c39e14c749a2060f70b15e87
+57,5ac571f021e4a0759819b02d76799e7347eb7ffc
+58,a4562d2d5a35536771745b0aa19d705eb47234e7
+59,d65736fd08fab5a64027f0c050ee148d88549406
+60,a4562d2d5a35536771745b0aa19d705eb47234e7
+61,a4562d2d5a35536771745b0aa19d705eb47234e7
+62,a4562d2d5a35536771745b0aa19d705eb47234e7
+63,a4562d2d5a35536771745b0aa19d705eb47234e7
+64,a4562d2d5a35536771745b0aa19d705eb47234e7
+65,d65736fd08fab5a64027f0c050ee148d88549406
+66,a4562d2d5a35536771745b0aa19d705eb47234e7
+67,a4562d2d5a35536771745b0aa19d705eb47234e7
+68,a4562d2d5a35536771745b0aa19d705eb47234e7
+69,a4562d2d5a35536771745b0aa19d705eb47234e7
+70,a4562d2d5a35536771745b0aa19d705eb47234e7
+71,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+72,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+73,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+74,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+75,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+76,6ea446b721a9b4189e8664553520fc9b8be27ed3
+77,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+78,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+79,6ea446b721a9b4189e8664553520fc9b8be27ed3
+80,8ffe09e7bb9e76f8e35faabc3eafd9922a840b4b
+81,8ffe09e7bb9e76f8e35faabc3eafd9922a840b4b
+82,6ea446b721a9b4189e8664553520fc9b8be27ed3
+83,8ffe09e7bb9e76f8e35faabc3eafd9922a840b4b
+84,8ffe09e7bb9e76f8e35faabc3eafd9922a840b4b
+85,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+86,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+87,6ea446b721a9b4189e8664553520fc9b8be27ed3
+88,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+89,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+90,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+91,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+92,7effc98dc9f8a415aaf3afd0b2cfb55c09806556
+93,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+94,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+95,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+96,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+97,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+98,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+99,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+100,7effc98dc9f8a415aaf3afd0b2cfb55c09806556
+101,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+102,d90e38531d7f845a3287e6de50e5615d2e6a0ce0
+103,a4562d2d5a35536771745b0aa19d705eb47234e7
+104,a4562d2d5a35536771745b0aa19d705eb47234e7
+105,a4562d2d5a35536771745b0aa19d705eb47234e7
+106,6ea446b721a9b4189e8664553520fc9b8be27ed3
+107,a4562d2d5a35536771745b0aa19d705eb47234e7
+108,a4562d2d5a35536771745b0aa19d705eb47234e7
+109,a4562d2d5a35536771745b0aa19d705eb47234e7
+110,a4562d2d5a35536771745b0aa19d705eb47234e7
+111,a4562d2d5a35536771745b0aa19d705eb47234e7
+112,a4562d2d5a35536771745b0aa19d705eb47234e7
+113,6ea446b721a9b4189e8664553520fc9b8be27ed3
+114,a4562d2d5a35536771745b0aa19d705eb47234e7
+115,a4562d2d5a35536771745b0aa19d705eb47234e7
+116,a4562d2d5a35536771745b0aa19d705eb47234e7
+117,a4562d2d5a35536771745b0aa19d705eb47234e7
+118,6ea446b721a9b4189e8664553520fc9b8be27ed3
+119,a4562d2d5a35536771745b0aa19d705eb47234e7
+120,a4562d2d5a35536771745b0aa19d705eb47234e7
+121,a4562d2d5a35536771745b0aa19d705eb47234e7
+122,a4562d2d5a35536771745b0aa19d705eb47234e7
+123,6ea446b721a9b4189e8664553520fc9b8be27ed3
+124,a4562d2d5a35536771745b0aa19d705eb47234e7
+125,a4562d2d5a35536771745b0aa19d705eb47234e7
+126,a4562d2d5a35536771745b0aa19d705eb47234e7
+127,a4562d2d5a35536771745b0aa19d705eb47234e7
+128,a4562d2d5a35536771745b0aa19d705eb47234e7
+129,a4562d2d5a35536771745b0aa19d705eb47234e7
+130,a4562d2d5a35536771745b0aa19d705eb47234e7
+131,a4562d2d5a35536771745b0aa19d705eb47234e7
+132,137317e0e42841df22ae31d3d4e49745fd09325b
+133,137317e0e42841df22ae31d3d4e49745fd09325b
+134,137317e0e42841df22ae31d3d4e49745fd09325b
+135,137317e0e42841df22ae31d3d4e49745fd09325b
+136,137317e0e42841df22ae31d3d4e49745fd09325b
+137,a4562d2d5a35536771745b0aa19d705eb47234e7
+138,a4562d2d5a35536771745b0aa19d705eb47234e7
+139,a4562d2d5a35536771745b0aa19d705eb47234e7
+140,a4562d2d5a35536771745b0aa19d705eb47234e7
+141,a4562d2d5a35536771745b0aa19d705eb47234e7
+142,a4562d2d5a35536771745b0aa19d705eb47234e7
+143,a4562d2d5a35536771745b0aa19d705eb47234e7
+144,a4562d2d5a35536771745b0aa19d705eb47234e7
+145,a4562d2d5a35536771745b0aa19d705eb47234e7
+146,a4562d2d5a35536771745b0aa19d705eb47234e7
+147,a4562d2d5a35536771745b0aa19d705eb47234e7
+148,a4562d2d5a35536771745b0aa19d705eb47234e7
+149,a4562d2d5a35536771745b0aa19d705eb47234e7
+150,a4562d2d5a35536771745b0aa19d705eb47234e7
+151,a4562d2d5a35536771745b0aa19d705eb47234e7
+152,a4562d2d5a35536771745b0aa19d705eb47234e7
+153,a4562d2d5a35536771745b0aa19d705eb47234e7
+154,a54fc82ce2408dc68e261a984cea59d090750ebe
+155,a54fc82ce2408dc68e261a984cea59d090750ebe
+156,ca4e34501bf50f72047bb81bea8a8fddaa33f2a3
+157,a54fc82ce2408dc68e261a984cea59d090750ebe
+158,256444144d3e22d54e028656baa54982500076a5
+159,256444144d3e22d54e028656baa54982500076a5
+160,256444144d3e22d54e028656baa54982500076a5
+161,256444144d3e22d54e028656baa54982500076a5
+162,256444144d3e22d54e028656baa54982500076a5
+163,256444144d3e22d54e028656baa54982500076a5
+164,a54fc82ce2408dc68e261a984cea59d090750ebe
+165,a54fc82ce2408dc68e261a984cea59d090750ebe
+166,58dc5a0c565f29f5a969e209fb45617280f747ed
+167,58dc5a0c565f29f5a969e209fb45617280f747ed
+168,58dc5a0c565f29f5a969e209fb45617280f747ed
+169,58dc5a0c565f29f5a969e209fb45617280f747ed
+170,58dc5a0c565f29f5a969e209fb45617280f747ed
+171,256444144d3e22d54e028656baa54982500076a5
+172,58dc5a0c565f29f5a969e209fb45617280f747ed
+173,58dc5a0c565f29f5a969e209fb45617280f747ed
+174,58dc5a0c565f29f5a969e209fb45617280f747ed
+175,137317e0e42841df22ae31d3d4e49745fd09325b
+176,a4562d2d5a35536771745b0aa19d705eb47234e7
+177,a4562d2d5a35536771745b0aa19d705eb47234e7
+178,a4562d2d5a35536771745b0aa19d705eb47234e7
+179,a4562d2d5a35536771745b0aa19d705eb47234e7
+180,a4562d2d5a35536771745b0aa19d705eb47234e7
+181,e8ca9ac51c2428d2ce7498b39e6db7bd6d7009f3
+182,e8ca9ac51c2428d2ce7498b39e6db7bd6d7009f3
+183,e8ca9ac51c2428d2ce7498b39e6db7bd6d7009f3
+184,256444144d3e22d54e028656baa54982500076a5
+185,e8ca9ac51c2428d2ce7498b39e6db7bd6d7009f3
+186,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+187,a4562d2d5a35536771745b0aa19d705eb47234e7
+188,22735d80efc3bb0dbba5c90f6bfeb53f1d03f369
+189,137317e0e42841df22ae31d3d4e49745fd09325b
+190,a4562d2d5a35536771745b0aa19d705eb47234e7
+191,a4562d2d5a35536771745b0aa19d705eb47234e7
+192,a4562d2d5a35536771745b0aa19d705eb47234e7
+193,a4562d2d5a35536771745b0aa19d705eb47234e7
+194,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+195,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+196,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+197,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+198,137317e0e42841df22ae31d3d4e49745fd09325b
+199,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+200,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+201,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+202,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+203,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+204,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+205,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+206,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+207,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+208,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+209,cb2bd95c40eb4a83fcc79f71a2bb1ae578693f33
+210,a4562d2d5a35536771745b0aa19d705eb47234e7
+211,137317e0e42841df22ae31d3d4e49745fd09325b
+212,137317e0e42841df22ae31d3d4e49745fd09325b
+213,137317e0e42841df22ae31d3d4e49745fd09325b
+214,137317e0e42841df22ae31d3d4e49745fd09325b
+215,96a175585a0e75a7d319c84a8bea6f8464d0f66c
+216,43d88d87c20ae34ab19901ef03f283d349915929
+217,96a175585a0e75a7d319c84a8bea6f8464d0f66c
+218,137317e0e42841df22ae31d3d4e49745fd09325b
+219,5809ea8e314a76fab3e08e88f5e094d08a7aed04
+220,137317e0e42841df22ae31d3d4e49745fd09325b
+221,8d362596e662fe753b67a184b0483e7a9519e712
+222,8d362596e662fe753b67a184b0483e7a9519e712
+223,8d362596e662fe753b67a184b0483e7a9519e712
+224,8d362596e662fe753b67a184b0483e7a9519e712
+225,d65736fd08fab5a64027f0c050ee148d88549406
+226,8d362596e662fe753b67a184b0483e7a9519e712
+227,8d362596e662fe753b67a184b0483e7a9519e712
+228,d65736fd08fab5a64027f0c050ee148d88549406
+229,8d362596e662fe753b67a184b0483e7a9519e712
+230,137317e0e42841df22ae31d3d4e49745fd09325b
+231,137317e0e42841df22ae31d3d4e49745fd09325b
+232,137317e0e42841df22ae31d3d4e49745fd09325b
+233,137317e0e42841df22ae31d3d4e49745fd09325b
+234,137317e0e42841df22ae31d3d4e49745fd09325b
+235,137317e0e42841df22ae31d3d4e49745fd09325b
+236,137317e0e42841df22ae31d3d4e49745fd09325b
+237,137317e0e42841df22ae31d3d4e49745fd09325b
+238,137317e0e42841df22ae31d3d4e49745fd09325b
+239,137317e0e42841df22ae31d3d4e49745fd09325b
+240,137317e0e42841df22ae31d3d4e49745fd09325b
+241,137317e0e42841df22ae31d3d4e49745fd09325b
+242,137317e0e42841df22ae31d3d4e49745fd09325b
+243,137317e0e42841df22ae31d3d4e49745fd09325b
+244,137317e0e42841df22ae31d3d4e49745fd09325b
+245,137317e0e42841df22ae31d3d4e49745fd09325b
+246,137317e0e42841df22ae31d3d4e49745fd09325b
+247,137317e0e42841df22ae31d3d4e49745fd09325b
+248,137317e0e42841df22ae31d3d4e49745fd09325b
+249,137317e0e42841df22ae31d3d4e49745fd09325b
+250,137317e0e42841df22ae31d3d4e49745fd09325b
+251,137317e0e42841df22ae31d3d4e49745fd09325b
+252,137317e0e42841df22ae31d3d4e49745fd09325b
+253,137317e0e42841df22ae31d3d4e49745fd09325b
+254,137317e0e42841df22ae31d3d4e49745fd09325b
+255,137317e0e42841df22ae31d3d4e49745fd09325b
+256,137317e0e42841df22ae31d3d4e49745fd09325b
+257,137317e0e42841df22ae31d3d4e49745fd09325b
+258,137317e0e42841df22ae31d3d4e49745fd09325b
+259,137317e0e42841df22ae31d3d4e49745fd09325b
+260,137317e0e42841df22ae31d3d4e49745fd09325b
+261,8d362596e662fe753b67a184b0483e7a9519e712
+262,8d362596e662fe753b67a184b0483e7a9519e712
+263,d65736fd08fab5a64027f0c050ee148d88549406
+264,8d362596e662fe753b67a184b0483e7a9519e712
+265,8d362596e662fe753b67a184b0483e7a9519e712
+266,d65736fd08fab5a64027f0c050ee148d88549406
+267,8d362596e662fe753b67a184b0483e7a9519e712
+268,8d362596e662fe753b67a184b0483e7a9519e712
+269,8d362596e662fe753b67a184b0483e7a9519e712
+270,8d362596e662fe753b67a184b0483e7a9519e712
+271,8d362596e662fe753b67a184b0483e7a9519e712
+272,8d362596e662fe753b67a184b0483e7a9519e712
+273,8d362596e662fe753b67a184b0483e7a9519e712
+274,8d362596e662fe753b67a184b0483e7a9519e712
+275,8d362596e662fe753b67a184b0483e7a9519e712
+276,8d362596e662fe753b67a184b0483e7a9519e712
+277,8d362596e662fe753b67a184b0483e7a9519e712
+278,8d362596e662fe753b67a184b0483e7a9519e712
+279,8d362596e662fe753b67a184b0483e7a9519e712
+280,8d362596e662fe753b67a184b0483e7a9519e712
+281,8d362596e662fe753b67a184b0483e7a9519e712
+282,8d362596e662fe753b67a184b0483e7a9519e712
+283,8d362596e662fe753b67a184b0483e7a9519e712
+284,8d362596e662fe753b67a184b0483e7a9519e712
+285,8d362596e662fe753b67a184b0483e7a9519e712
+286,8d362596e662fe753b67a184b0483e7a9519e712
+287,8d362596e662fe753b67a184b0483e7a9519e712
+288,8d362596e662fe753b67a184b0483e7a9519e712
+289,8d362596e662fe753b67a184b0483e7a9519e712
+290,8d362596e662fe753b67a184b0483e7a9519e712
+291,8d362596e662fe753b67a184b0483e7a9519e712
+292,8d362596e662fe753b67a184b0483e7a9519e712
+293,8d362596e662fe753b67a184b0483e7a9519e712
+294,8d362596e662fe753b67a184b0483e7a9519e712
+295,8d362596e662fe753b67a184b0483e7a9519e712
+296,8d362596e662fe753b67a184b0483e7a9519e712
+297,8d362596e662fe753b67a184b0483e7a9519e712
+298,8d362596e662fe753b67a184b0483e7a9519e712
+299,8d362596e662fe753b67a184b0483e7a9519e712
+300,8d362596e662fe753b67a184b0483e7a9519e712
+301,8d362596e662fe753b67a184b0483e7a9519e712
+302,8d362596e662fe753b67a184b0483e7a9519e712
+303,8d362596e662fe753b67a184b0483e7a9519e712
+304,8d362596e662fe753b67a184b0483e7a9519e712
+305,8d362596e662fe753b67a184b0483e7a9519e712
+306,8d362596e662fe753b67a184b0483e7a9519e712
+307,8d362596e662fe753b67a184b0483e7a9519e712
+308,8d362596e662fe753b67a184b0483e7a9519e712
+309,8d362596e662fe753b67a184b0483e7a9519e712
+310,8d362596e662fe753b67a184b0483e7a9519e712
+311,8b1493a7cc7a0c47c09f461a6c80c667772db802
+312,6a8b46424f81737c4d7d8659860d3d161cf39183
+313,d65736fd08fab5a64027f0c050ee148d88549406
+314,6a8b46424f81737c4d7d8659860d3d161cf39183
+315,6a8b46424f81737c4d7d8659860d3d161cf39183
+316,d65736fd08fab5a64027f0c050ee148d88549406
+317,6a8b46424f81737c4d7d8659860d3d161cf39183
+318,6a8b46424f81737c4d7d8659860d3d161cf39183
+319,6a8b46424f81737c4d7d8659860d3d161cf39183
+320,6a8b46424f81737c4d7d8659860d3d161cf39183
+321,6a8b46424f81737c4d7d8659860d3d161cf39183
+322,6a8b46424f81737c4d7d8659860d3d161cf39183
+323,6a8b46424f81737c4d7d8659860d3d161cf39183
+324,6a8b46424f81737c4d7d8659860d3d161cf39183
+325,6a8b46424f81737c4d7d8659860d3d161cf39183
+326,6a8b46424f81737c4d7d8659860d3d161cf39183
+327,6a8b46424f81737c4d7d8659860d3d161cf39183
+328,6a8b46424f81737c4d7d8659860d3d161cf39183
+329,6a8b46424f81737c4d7d8659860d3d161cf39183
+330,6a8b46424f81737c4d7d8659860d3d161cf39183
+331,6a8b46424f81737c4d7d8659860d3d161cf39183
+332,6a8b46424f81737c4d7d8659860d3d161cf39183
+333,6a8b46424f81737c4d7d8659860d3d161cf39183
+334,6a8b46424f81737c4d7d8659860d3d161cf39183
+335,6a8b46424f81737c4d7d8659860d3d161cf39183
+336,6a8b46424f81737c4d7d8659860d3d161cf39183
+337,6a8b46424f81737c4d7d8659860d3d161cf39183
+338,6a8b46424f81737c4d7d8659860d3d161cf39183
+339,6a8b46424f81737c4d7d8659860d3d161cf39183
+340,6a8b46424f81737c4d7d8659860d3d161cf39183
+341,6a8b46424f81737c4d7d8659860d3d161cf39183
+342,6a8b46424f81737c4d7d8659860d3d161cf39183
+343,6a8b46424f81737c4d7d8659860d3d161cf39183
+344,6a8b46424f81737c4d7d8659860d3d161cf39183
+345,6a8b46424f81737c4d7d8659860d3d161cf39183
+346,6a8b46424f81737c4d7d8659860d3d161cf39183
+347,6a8b46424f81737c4d7d8659860d3d161cf39183
+348,6a8b46424f81737c4d7d8659860d3d161cf39183
+349,a4562d2d5a35536771745b0aa19d705eb47234e7
+350,a4562d2d5a35536771745b0aa19d705eb47234e7
+351,a4562d2d5a35536771745b0aa19d705eb47234e7
+352,a4562d2d5a35536771745b0aa19d705eb47234e7
+353,a4562d2d5a35536771745b0aa19d705eb47234e7
+354,a4562d2d5a35536771745b0aa19d705eb47234e7
+355,a4562d2d5a35536771745b0aa19d705eb47234e7
+356,a4562d2d5a35536771745b0aa19d705eb47234e7
+357,a4562d2d5a35536771745b0aa19d705eb47234e7
+358,a4562d2d5a35536771745b0aa19d705eb47234e7
+359,a4562d2d5a35536771745b0aa19d705eb47234e7
+360,a4562d2d5a35536771745b0aa19d705eb47234e7
+361,a4562d2d5a35536771745b0aa19d705eb47234e7
+362,a4562d2d5a35536771745b0aa19d705eb47234e7
+363,a4562d2d5a35536771745b0aa19d705eb47234e7
+364,a4562d2d5a35536771745b0aa19d705eb47234e7
+365,a4562d2d5a35536771745b0aa19d705eb47234e7
+366,a4562d2d5a35536771745b0aa19d705eb47234e7
+367,a4562d2d5a35536771745b0aa19d705eb47234e7
+368,a4562d2d5a35536771745b0aa19d705eb47234e7
+369,a4562d2d5a35536771745b0aa19d705eb47234e7
+370,a4562d2d5a35536771745b0aa19d705eb47234e7
+371,a4562d2d5a35536771745b0aa19d705eb47234e7
+372,a4562d2d5a35536771745b0aa19d705eb47234e7
+373,a4562d2d5a35536771745b0aa19d705eb47234e7
+374,a4562d2d5a35536771745b0aa19d705eb47234e7
+375,a4562d2d5a35536771745b0aa19d705eb47234e7
+376,a4562d2d5a35536771745b0aa19d705eb47234e7
+377,a4562d2d5a35536771745b0aa19d705eb47234e7
+378,a4562d2d5a35536771745b0aa19d705eb47234e7
+379,a4562d2d5a35536771745b0aa19d705eb47234e7
+380,a4562d2d5a35536771745b0aa19d705eb47234e7
+381,a4562d2d5a35536771745b0aa19d705eb47234e7
+382,a4562d2d5a35536771745b0aa19d705eb47234e7
+383,a4562d2d5a35536771745b0aa19d705eb47234e7
+384,a4562d2d5a35536771745b0aa19d705eb47234e7
+385,a4562d2d5a35536771745b0aa19d705eb47234e7
+386,a4562d2d5a35536771745b0aa19d705eb47234e7
+387,a4562d2d5a35536771745b0aa19d705eb47234e7
+388,a4562d2d5a35536771745b0aa19d705eb47234e7
+389,a4562d2d5a35536771745b0aa19d705eb47234e7
+390,a33034737ec65ccaae074a4f3e3c998b034f3bfe
+391,a4562d2d5a35536771745b0aa19d705eb47234e7
+392,29b60e510de9d157a3f5611312ed4c6fed3442dc
+393,29b60e510de9d157a3f5611312ed4c6fed3442dc
+394,a33034737ec65ccaae074a4f3e3c998b034f3bfe
+395,29b60e510de9d157a3f5611312ed4c6fed3442dc
+396,a4562d2d5a35536771745b0aa19d705eb47234e7
+397,a4562d2d5a35536771745b0aa19d705eb47234e7
+398,a4562d2d5a35536771745b0aa19d705eb47234e7
+399,a4562d2d5a35536771745b0aa19d705eb47234e7
+400,a4562d2d5a35536771745b0aa19d705eb47234e7
+401,a4562d2d5a35536771745b0aa19d705eb47234e7
+402,a4562d2d5a35536771745b0aa19d705eb47234e7
+403,a4562d2d5a35536771745b0aa19d705eb47234e7
+404,a4562d2d5a35536771745b0aa19d705eb47234e7
+405,324f0cc7dc57e4d6ff58754ae907d8a0cca3b081
+406,324f0cc7dc57e4d6ff58754ae907d8a0cca3b081
+407,324f0cc7dc57e4d6ff58754ae907d8a0cca3b081
+408,324f0cc7dc57e4d6ff58754ae907d8a0cca3b081
+409,324f0cc7dc57e4d6ff58754ae907d8a0cca3b081
+410,324f0cc7dc57e4d6ff58754ae907d8a0cca3b081
+411,324f0cc7dc57e4d6ff58754ae907d8a0cca3b081
+412,a4562d2d5a35536771745b0aa19d705eb47234e7
+413,a4562d2d5a35536771745b0aa19d705eb47234e7
+414,a4562d2d5a35536771745b0aa19d705eb47234e7
+415,6708a83ff0d2452fcb035f9efa206ead35892a13
+416,6708a83ff0d2452fcb035f9efa206ead35892a13
+417,6708a83ff0d2452fcb035f9efa206ead35892a13
+418,6708a83ff0d2452fcb035f9efa206ead35892a13
+419,6708a83ff0d2452fcb035f9efa206ead35892a13
+420,6708a83ff0d2452fcb035f9efa206ead35892a13
+421,6708a83ff0d2452fcb035f9efa206ead35892a13
+422,6708a83ff0d2452fcb035f9efa206ead35892a13
+423,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+424,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+425,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+426,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+427,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+428,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+429,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+430,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+431,f7e4188e1fda52e3189607f5b3f9af00dca582a1
+432,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+433,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+434,237f5c11ac7899b24a98c9b5acf2abecf76641d9
+435,237f5c11ac7899b24a98c9b5acf2abecf76641d9
diff --git a/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/go.mod.testdata b/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/go.mod.testdata
new file mode 100644
index 00000000..45b475de
--- /dev/null
+++ b/tables/internal/git/native/testdata/2359c9a9ba0ba8aa694601ff12538c4e74b82cd5/go.mod.testdata
@@ -0,0 +1,37 @@
+module github.com/askgitdev/askgit
+
+go 1.13
+
+require (
+ github.com/BurntSushi/toml v0.3.1
+ github.com/DATA-DOG/go-sqlmock v1.5.0
+ github.com/augmentable-dev/tickgit v0.0.14
+ github.com/clbanning/mxj/v2 v2.5.2
+ github.com/ghodss/yaml v1.0.0
+ github.com/gitsight/go-vcsurl v1.0.0
+ github.com/go-openapi/errors v0.19.9 // indirect
+ github.com/go-openapi/strfmt v0.19.11 // indirect
+ github.com/golang/protobuf v1.4.3 // indirect
+ github.com/google/go-github v17.0.0+incompatible
+ github.com/google/go-querystring v1.0.0 // indirect
+ github.com/jedib0t/go-pretty v4.3.0+incompatible
+ github.com/jroimartin/gocui v0.4.0
+ github.com/libgit2/git2go/v31 v31.4.7
+ github.com/mattn/go-sqlite3 v1.14.6
+ github.com/mitchellh/mapstructure v1.4.0 // indirect
+ github.com/nsf/termbox-go v0.0.0-20201124104050-ed494de23a00 // indirect
+ github.com/pkg/errors v0.9.1
+ github.com/spf13/cobra v1.1.1
+ go.mongodb.org/mongo-driver v1.4.4 // indirect
+ go.riyazali.net/sqlite v0.0.0-20210413174544-3cf76b5afbdc
+ golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
+ golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
+ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5
+ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
+ golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect
+ golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
+ golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
+ google.golang.org/appengine v1.6.7 // indirect
+)
+
+replace github.com/mattn/go-sqlite3 v1.14.6 => github.com/patrickdevivo/go-sqlite3 v1.14.6-0.20201229155540-f024bb44eb6d
diff --git a/tables/internal/git/refs.go b/tables/internal/git/refs.go
new file mode 100644
index 00000000..4c0ff236
--- /dev/null
+++ b/tables/internal/git/refs.go
@@ -0,0 +1,172 @@
+package git
+
+import (
+ "context"
+ "regexp"
+
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/go-git/go-git/v5"
+ "github.com/go-git/go-git/v5/plumbing"
+ "github.com/go-git/go-git/v5/plumbing/storer"
+ "github.com/pkg/errors"
+ "go.riyazali.net/sqlite"
+)
+
+var remoteName = regexp.MustCompile(`(?m)refs\/remotes\/([^\/]*)\/.+`)
+
+type RefModule struct {
+ Locator services.RepoLocator
+ Context services.Context
+}
+
+func (mod *RefModule) Connect(_ *sqlite.Conn, _ []string, declare func(string) error) (sqlite.VirtualTable, error) {
+ const schema = `
+ CREATE TABLE refs (
+ name TEXT,
+ type TEXT,
+ remote TEXT,
+ full_name TEXT,
+ hash TEXT,
+ target TEXT,
+
+ repository HIDDEN,
+ tag HIDDEN,
+ PRIMARY KEY ( name )
+ ) WITHOUT ROWID`
+
+ return &gitRefTable{Locator: mod.Locator, Context: mod.Context}, declare(schema)
+}
+
+type gitRefTable struct {
+ Locator services.RepoLocator
+ Context services.Context
+}
+
+func (tab *gitRefTable) Disconnect() error { return nil }
+func (tab *gitRefTable) Destroy() error { return nil }
+func (tab *gitRefTable) Open() (sqlite.VirtualCursor, error) {
+ return &gitRefCursor{Locator: tab.Locator, Context: tab.Context}, nil
+}
+
+func (tab *gitRefTable) BestIndex(input *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
+ var bitmap []byte
+ var out = &sqlite.IndexInfoOutput{}
+ out.ConstraintUsage = make([]*sqlite.ConstraintUsage, len(input.Constraints))
+
+ for i, constraint := range input.Constraints {
+ if !constraint.Usable {
+ continue // we do not support unusable constraint at all
+ }
+
+ if constraint.ColumnIndex == 6 && constraint.Op == sqlite.INDEX_CONSTRAINT_EQ {
+ bitmap = append(bitmap, byte(1<<4|constraint.ColumnIndex))
+ out.ConstraintUsage[i] = &sqlite.ConstraintUsage{ArgvIndex: 1, Omit: true}
+ }
+ }
+
+ // validate passed in constraint to ensure there combination stays logical
+ out.IndexString = enc(bitmap)
+ return out, nil
+}
+
+type gitRefCursor struct {
+ Locator services.RepoLocator
+ Context services.Context
+
+ repo *git.Repository
+
+ ref *plumbing.Reference
+ refs storer.ReferenceIter
+}
+
+func (cur *gitRefCursor) Filter(_ int, s string, values ...sqlite.Value) (err error) {
+ // values extracted from constraints
+ var path string
+
+ var bitmap, _ = dec(s)
+ for i, val := range values {
+ switch b := bitmap[i]; b {
+ case 0b00010110:
+ path = val.Text()
+ }
+ }
+
+ var repo *git.Repository
+ { // open the git repository
+ if path == "" {
+ path, err = GetDefaultRepoFromCtx(cur.Context)
+ if err != nil {
+ return err
+ }
+ }
+
+ if repo, err = cur.Locator.Open(context.Background(), path); err != nil {
+ return errors.Wrapf(err, "failed to open %q", path)
+ }
+ cur.repo = repo
+ }
+
+ if cur.refs, err = repo.References(); err != nil {
+ return errors.Wrap(err, "failed to create iterator")
+ }
+
+ return cur.Next()
+}
+
+func (cur *gitRefCursor) Column(c *sqlite.Context, col int) error {
+ ref := cur.ref
+ switch col {
+ case 0:
+ c.ResultText(ref.Name().Short())
+ case 1:
+ if ref.Name().IsBranch() || isRemoteBranch(ref.Name()) {
+ c.ResultText("branch")
+ } else if ref.Name().IsTag() {
+ c.ResultText("tag")
+ } else if ref.Name().IsNote() {
+ c.ResultText("note")
+ }
+ case 2:
+ if ref.Name().IsRemote() {
+ if matches := remoteName.FindStringSubmatch(ref.Name().String()); len(matches) >= 2 {
+ c.ResultText(matches[1])
+ }
+ }
+ case 3:
+ c.ResultText(ref.Name().String())
+ case 4:
+ if !ref.Hash().IsZero() {
+ c.ResultText(ref.Hash().String())
+ }
+ case 5:
+ c.ResultText(ref.Target().String())
+ case 7:
+ if ref.Name().IsTag() {
+ if tag, err := cur.repo.TagObject(ref.Hash()); err != nil && err != plumbing.ErrObjectNotFound {
+ return errors.Wrap(err, "failed to fetch tag object")
+ } else if tag != nil && tag.TargetType == plumbing.CommitObject {
+ c.ResultPointer(tag)
+ }
+ }
+ }
+
+ return nil
+}
+
+func (cur *gitRefCursor) Next() (err error) {
+ if cur.ref, err = cur.refs.Next(); err != nil {
+ if !eof(err) {
+ return err
+ }
+ }
+ return nil
+}
+
+func (cur *gitRefCursor) Eof() bool { return cur.ref == nil }
+func (cur *gitRefCursor) Rowid() (int64, error) { return int64(0), nil }
+func (cur *gitRefCursor) Close() error {
+ if cur.refs != nil {
+ cur.refs.Close()
+ }
+ return nil
+}
diff --git a/tables/internal/git/refs_func.go b/tables/internal/git/refs_func.go
new file mode 100644
index 00000000..8a125871
--- /dev/null
+++ b/tables/internal/git/refs_func.go
@@ -0,0 +1,27 @@
+package git
+
+import (
+ "github.com/go-git/go-git/v5/plumbing/object"
+ "github.com/pkg/errors"
+ "go.riyazali.net/sqlite"
+)
+
+// CommitFromTagFn implements the COMMIT_FROM_TAG(...) sql function
+type CommitFromTagFn struct{}
+
+func (*CommitFromTagFn) Deterministic() bool { return true }
+func (*CommitFromTagFn) Args() int { return 1 }
+func (*CommitFromTagFn) Apply(c *sqlite.Context, values ...sqlite.Value) {
+ tag, ok := values[0].Pointer().(*object.Tag)
+ if !ok {
+ return
+ }
+
+ commit, err := tag.Commit()
+ if err != nil {
+ c.ResultError(errors.Wrap(err, "tag target is not a commit"))
+ return
+ }
+
+ c.ResultText(commit.Hash.String())
+}
diff --git a/tables/internal/git/refs_func_test.go b/tables/internal/git/refs_func_test.go
new file mode 100644
index 00000000..82e533a1
--- /dev/null
+++ b/tables/internal/git/refs_func_test.go
@@ -0,0 +1,29 @@
+package git_test
+
+import (
+ "database/sql"
+ "testing"
+)
+
+func TestCommitFromTagFn(t *testing.T) {
+ db := Connect(t, Memory)
+ repo := "https://github.com/askgitdev/askgit"
+
+ rows, err := db.Query("SELECT name, full_name, COMMIT_FROM_TAG(tag) FROM refs(?) WHERE type = 'tag'", repo)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var name, fullName, hash sql.NullString
+ if err = rows.Scan(&name, &fullName, &hash); err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("ref: name=%q fullName=%q hash=%q", name.String, fullName.String, hash.String)
+ }
+
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
+ }
+}
diff --git a/tables/internal/git/refs_test.go b/tables/internal/git/refs_test.go
new file mode 100644
index 00000000..5818cc83
--- /dev/null
+++ b/tables/internal/git/refs_test.go
@@ -0,0 +1,31 @@
+package git_test
+
+import (
+ "database/sql"
+ "testing"
+)
+
+func TestSelectAllRefs(t *testing.T) {
+ db := Connect(t, Memory)
+ repo := "https://github.com/askgitdev/askgit"
+
+ rows, err := db.Query("SELECT * FROM refs(?)", repo)
+ if err != nil {
+ t.Fatalf("failed to execute query: %v", err.Error())
+ }
+ defer rows.Close()
+
+ for rows.Next() {
+ var name, _type, remote sql.NullString
+ var fullName, hash, target sql.NullString
+ if err = rows.Scan(&name, &_type, &remote, &fullName, &hash, &target); err != nil {
+ t.Fatalf("failed to scan resultset: %v", err)
+ }
+ t.Logf("ref: name=%q type=%s fullName=%q hash=%q remote=%s target=%s",
+ name.String, _type.String, fullName.String, hash.String, remote.String, target.String)
+ }
+
+ if err = rows.Err(); err != nil {
+ t.Fatalf("failed to fetch results: %v", err.Error())
+ }
+}
diff --git a/tables/internal/git/stats.go b/tables/internal/git/stats.go
deleted file mode 100644
index 89fd5153..00000000
--- a/tables/internal/git/stats.go
+++ /dev/null
@@ -1,117 +0,0 @@
-package git
-
-import (
- "fmt"
- "go.riyazali.net/sqlite"
- "io"
- "strconv"
- "strings"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-// StatsModule implements sqlite.Module that provides the "stats" virtual table
-type StatsModule struct{}
-
-func (m *StatsModule) Connect(_ *sqlite.Conn, args []string, declare func(string) error) (sqlite.VirtualTable, error) {
- // TODO(@riyaz): parse args to extract repo
- var repo, _ = strconv.Unquote(strings.SplitN(args[3], "=", 2)[1])
-
- var schema = fmt.Sprintf(`CREATE TABLE %q (commit_id TEXT, file_path TEXT, additions INT, deletions INT)`, args[0])
- return &gitStatsTable{path: repo}, declare(schema)
-}
-
-type gitStatsTable struct{ path string }
-
-func (v *gitStatsTable) BestIndex(input *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
- var usage = make([]*sqlite.ConstraintUsage, len(input.Constraints))
-
- // TODO implement an index for file name glob patterns?
- // TODO this loop construct won't work well for multiple constraints...
- for c, constraint := range input.Constraints {
- switch {
- case constraint.Usable && constraint.ColumnIndex == 0 && constraint.Op == sqlite.INDEX_CONSTRAINT_EQ:
- usage[c] = &sqlite.ConstraintUsage{ArgvIndex: 1, Omit: false}
- return &sqlite.IndexInfoOutput{ConstraintUsage: usage, IndexNumber: 1, IndexString: "stats-by-commit-id", EstimatedCost: 1.0, EstimatedRows: 1}, nil
- }
- }
-
- return &sqlite.IndexInfoOutput{ConstraintUsage: usage, EstimatedCost: 100}, nil
-}
-
-func (v *gitStatsTable) Open() (sqlite.VirtualCursor, error) {
- repo, err := git.OpenRepository(v.path)
- if err != nil {
- return nil, err
- }
- return &statsCursor{repo: repo}, nil
-}
-
-func (v *gitStatsTable) Disconnect() error { return nil }
-func (v *gitStatsTable) Destroy() error { return nil }
-
-type statsCursor struct {
- repo *git.Repository
- iterator *commitStatsIter
- current *commitStat
-}
-
-func (vc *statsCursor) Filter(i int, _ string, values ...sqlite.Value) error {
- var opt *commitStatsIterOptions
- switch i {
- case 0:
- opt = &commitStatsIterOptions{}
- case 1:
- opt = &commitStatsIterOptions{commitID: values[0].Text()}
- }
-
- iter, err := NewCommitStatsIter(vc.repo, opt)
- if err != nil {
- return err
- }
-
- vc.iterator = iter
-
- file, err := vc.iterator.Next()
- if err != nil {
- if err == io.EOF {
- vc.current = nil
- return nil
- }
- return err
- }
-
- vc.current = file
- return nil
-}
-
-func (vc *statsCursor) Column(context *sqlite.Context, i int) error {
- switch stat := vc.current; i {
- case 0:
- context.ResultText(stat.commitID)
- case 1:
- context.ResultText(stat.file)
- case 2:
- context.ResultInt(stat.additions)
- case 3:
- context.ResultInt(stat.deletions)
- }
- return nil
-}
-
-func (vc *statsCursor) Next() error {
- file, err := vc.iterator.Next()
- if err != nil {
- if err == io.EOF {
- vc.current = nil
- return nil
- }
- return err
- }
- vc.current = file
- return nil
-}
-
-func (vc *statsCursor) Eof() bool { return vc.current == nil }
-func (vc *statsCursor) Rowid() (int64, error) { return int64(0), nil }
-func (vc *statsCursor) Close() error { vc.iterator.Close(); return nil }
diff --git a/tables/internal/git/stats_iter.go b/tables/internal/git/stats_iter.go
deleted file mode 100644
index a45072b6..00000000
--- a/tables/internal/git/stats_iter.go
+++ /dev/null
@@ -1,196 +0,0 @@
-package git
-
-import (
- "io"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-type commitStat struct {
- commitID string
- file string
- additions int
- deletions int
-}
-
-type commitStatsIter struct {
- repo *git.Repository
- commitIter *git.RevWalk
- currentCommit *git.Commit
- commitStats []*commitStat
- currentCommitStatIndex int
-}
-
-type commitStatsIterOptions struct {
- commitID string
-}
-
-func stats(commit *git.Commit) ([]*commitStat, error) {
-
- stats := make([]*commitStat, 0)
-
- repo := commit.Owner()
- tree, err := commit.Tree()
- if err != nil {
- return nil, err
- }
- defer tree.Free()
-
- var parentTree *git.Tree
- parent := commit.Parent(0)
- if parent == nil {
- parentTree = &git.Tree{}
- } else {
- parentTree, err = parent.Tree()
- if err != nil {
- return nil, err
- }
- defer parentTree.Free()
- }
-
- diffOpts, err := git.DefaultDiffOptions()
- if err != nil {
- return nil, err
- }
- diff, err := repo.DiffTreeToTree(parentTree, tree, &diffOpts)
- if err != nil {
- return nil, err
- }
- diffFindOpts, err := git.DefaultDiffFindOptions()
- if err != nil {
- return nil, err
- }
- err = diff.FindSimilar(&diffFindOpts)
- if err != nil {
- return nil, err
- }
-
- err = diff.ForEach(func(delta git.DiffDelta, progress float64) (git.DiffForEachHunkCallback, error) {
- stat := &commitStat{
- commitID: commit.Id().String(),
- file: delta.NewFile.Path,
- }
- stats = append(stats, stat)
- return func(hunk git.DiffHunk) (git.DiffForEachLineCallback, error) {
- return func(line git.DiffLine) error {
- switch line.Origin {
- case git.DiffLineAddition:
- stat.additions++
- case git.DiffLineDeletion:
- stat.deletions++
- }
- return nil
- }, nil
- }, nil
- }, git.DiffDetailLines)
-
- if err != nil {
- return nil, err
- }
- return stats, nil
-}
-
-func NewCommitStatsIter(repo *git.Repository, opt *commitStatsIterOptions) (*commitStatsIter, error) {
- if opt.commitID == "" {
- revWalk, err := repo.Walk()
- if err != nil {
- return nil, err
- }
-
- err = revWalk.PushHead()
- if err != nil {
- return nil, err
- }
-
- revWalk.Sorting(git.SortNone)
-
- return &commitStatsIter{
- repo: repo,
- commitIter: revWalk,
- currentCommit: nil,
- commitStats: make([]*commitStat, 0),
- currentCommitStatIndex: 100, // init with an index greater than above array, so that the first call to Next() sets up the first commit, rather than trying to return a current Blob
- }, nil
-
- } else {
- commitID, err := git.NewOid(opt.commitID)
- if err != nil {
- return nil, err
- }
-
- commit, err := repo.LookupCommit(commitID)
- if err != nil {
- return nil, err
- }
-
- commitStats, err := stats(commit)
- if err != nil {
- return nil, err
- }
-
- return &commitStatsIter{
- repo: repo,
- commitIter: nil,
- currentCommit: commit,
- commitStats: commitStats,
- currentCommitStatIndex: 0,
- }, nil
- }
-}
-
-func (iter *commitStatsIter) Next() (*commitStat, error) {
- defer func() {
- iter.currentCommitStatIndex++
- }()
-
- if iter.currentCommitStatIndex < len(iter.commitStats) {
- return iter.commitStats[iter.currentCommitStatIndex], nil
- }
-
- // if the commitIter is nil, there are no commits to iterate over, end
- // this assumes that a currentCommit was set when this was first called, with commitStats already populated
- if iter.commitIter == nil {
- return nil, io.EOF
- }
-
- id := new(git.Oid)
- err := iter.commitIter.Next(id)
- if err != nil {
- if id.IsZero() {
- return nil, io.EOF
- }
-
- return nil, err
- }
-
- commit, err := iter.repo.LookupCommit(id)
- if err != nil {
- return nil, err
- }
-
- iter.currentCommit = commit
-
- commitStats, err := stats(commit)
- if err != nil {
- return nil, err
- }
-
- iter.commitStats = commitStats
- iter.currentCommitStatIndex = 0
-
- if len(commitStats) == 0 {
- return iter.Next()
- }
-
- return commitStats[iter.currentCommitStatIndex], nil
-}
-
-func (iter *commitStatsIter) Close() {
- if iter == nil {
- return
- }
- iter.currentCommit.Free()
- if iter.commitIter != nil {
- iter.commitIter.Free()
- }
-}
diff --git a/tables/internal/git/stats_test.go b/tables/internal/git/stats_test.go
deleted file mode 100644
index 37913dc7..00000000
--- a/tables/internal/git/stats_test.go
+++ /dev/null
@@ -1,132 +0,0 @@
-package git
-
-import (
- "io"
- "strconv"
- "testing"
-
- "github.com/askgitdev/askgit/pkg/gitlog"
-)
-
-func TestStatsIterator(t *testing.T) {
- iter, err := NewCommitStatsIter(fixtureRepo, &commitStatsIterOptions{})
- if err != nil {
- t.Fatal(err)
- }
-
- for {
- stat, err := iter.Next()
- if err == io.EOF {
- break
- }
- if stat.commitID == "" {
- t.Fatal("invalid commit")
- }
- }
-}
-
-func TestStatsTable(t *testing.T) {
- rows, err := fixtureDB.Query("SELECT * FROM stats")
- if err != nil {
- t.Fatal(err)
- }
- defer rows.Close()
-
- _, contents, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
- }
-
- if len(contents[0]) != 4 {
- t.Fatalf("expected 4 columns, got %d", len(contents[0]))
- }
-
-}
-
-func TestStatsTableCommitIDIndex(t *testing.T) {
- rows, err := fixtureDB.Query("SELECT * FROM stats WHERE commit_id = (SELECT id FROM commits LIMIT 1)")
- if err != nil {
- t.Fatal(err)
- }
- defer rows.Close()
-
- _, contents, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
- }
-
- if len(contents[0]) != 4 {
- t.Fatalf("expected 4 columns, got %d", len(contents[0]))
- }
-
- // TODO actually test the results here?
- // this test case added to activate the code path that looks up commit stats by commit id
- // (avoiding a full table scan)
-}
-
-func TestStatsTotals(t *testing.T) {
- iter, err := gitlog.Execute(fixtureRepoDir)
- if err != nil {
- t.Fatal(err)
- }
-
- totalAdditions := 0
- totalDeletions := 0
- for {
- commit, err := iter.Next()
- if err != nil {
- if err == io.EOF {
- break
- }
- t.Fatal(err)
- }
- totalAdditions += commit.Additions
- totalDeletions += commit.Deletions
- }
-
- if err != nil {
- t.Fatal(err)
- }
-
- rows, err := fixtureDB.Query("SELECT sum(additions) AS a, sum(deletions) AS d FROM stats")
- if err != nil {
- t.Fatal(err)
- }
- defer rows.Close()
-
- _, contents, err := GetRowContents(rows)
- if err != nil {
- t.Fatal(err)
- }
-
- gotAdditions, err := strconv.Atoi(contents[0][0])
- if err != nil {
- t.Fatal(err)
- }
-
- gotDeletions, err := strconv.Atoi(contents[0][1])
- if err != nil {
- t.Fatal(err)
- }
-
- if totalAdditions != gotAdditions {
- t.Fatalf("expected: %d, got: %d total additions", totalAdditions, gotAdditions)
- }
-
- if totalDeletions != gotDeletions {
- t.Fatalf("expected: %d, got: %d total deletions", totalDeletions, gotDeletions)
- }
-}
-
-func BenchmarkStats(b *testing.B) {
- for i := 0; i < b.N; i++ {
- rows, err := fixtureDB.Query("SELECT * FROM stats")
- if err != nil {
- b.Fatal(err)
- }
- rowNum, _, err := GetRowContents(rows)
- if err != nil {
- b.Fatalf("err %d at row Number %d", err, rowNum)
- }
- }
-}
diff --git a/tables/internal/git/tags.go b/tables/internal/git/tags.go
deleted file mode 100644
index a32534fa..00000000
--- a/tables/internal/git/tags.go
+++ /dev/null
@@ -1,129 +0,0 @@
-package git
-
-import (
- "fmt"
- "go.riyazali.net/sqlite"
- "strconv"
- "strings"
-
- git "github.com/libgit2/git2go/v31"
-)
-
-// TagsModule implements sqlite.Module that provides "tags" table
-type TagsModule struct{}
-
-func (m *TagsModule) Connect(_ *sqlite.Conn, args []string, declare func(string) error) (sqlite.VirtualTable, error) {
- // TODO(@riyaz): parse args to extract repo
- var repo, _ = strconv.Unquote(strings.SplitN(args[3], "=", 2)[1])
-
- var schema = fmt.Sprintf(`CREATE TABLE %q (full_name TEXT, name TEXT, lightweight BOOL, target TEXT,
- tagger_name TEXT, tagger_email TEXT, message TEXT, target_type TEXT)`, args[0])
- return &gitTagsTable{repoPath: repo}, declare(schema)
-}
-
-type gitTagsTable struct{ repoPath string }
-
-func (v *gitTagsTable) BestIndex(_ *sqlite.IndexInfoInput) (*sqlite.IndexInfoOutput, error) {
- // TODO this should actually be implemented!
- return &sqlite.IndexInfoOutput{}, nil
-}
-
-func (v *gitTagsTable) Open() (sqlite.VirtualCursor, error) {
- repo, err := git.OpenRepository(v.repoPath)
- if err != nil {
- return nil, err
- }
-
- return &tagsCursor{repo: repo}, nil
-}
-
-func (v *gitTagsTable) Disconnect() error { return nil }
-func (v *gitTagsTable) Destroy() error { return nil }
-
-type currentTag struct {
- name string
- id *git.Oid
-}
-
-type tagsCursor struct {
- repo *git.Repository
- index int
- tags []*currentTag
-}
-
-func (vc *tagsCursor) Column(c *sqlite.Context, col int) error {
- current := vc.tags[vc.index]
-
- ref, err := vc.repo.References.Lookup(current.name)
- if err != nil {
- return err
- }
- defer ref.Free()
-
- isLightweight := false
- tag, err := vc.repo.LookupTag(current.id)
- if err != nil {
- isLightweight = true
- } else {
- defer tag.Free()
- }
-
- switch col {
- case 0:
- c.ResultText(ref.Name())
- case 1:
- c.ResultText(ref.Shorthand())
- case 2:
- c.ResultInt(boolToInt(isLightweight))
- case 3:
- if tag != nil {
- c.ResultText(tag.Target().Id().String())
- } else {
- c.ResultText(ref.Target().String())
- }
- case 4:
- if tag != nil {
- c.ResultText(tag.Tagger().Name)
- } else {
- c.ResultNull()
- }
- case 5:
- if tag != nil {
- c.ResultText(tag.Tagger().Email)
- } else {
- c.ResultNull()
- }
- case 6:
- if tag != nil {
- c.ResultText(tag.Message())
- } else {
- c.ResultNull()
- }
- case 7:
- if tag != nil {
- c.ResultText(tag.TargetType().String())
- } else {
- c.ResultNull()
- }
- }
- return nil
-}
-
-func (vc *tagsCursor) Filter(_ int, _ string, _ ...sqlite.Value) error {
- tags := make([]*currentTag, 0)
- err := vc.repo.Tags.Foreach(func(name string, id *git.Oid) error {
- tags = append(tags, ¤tTag{name, id})
- return nil
- })
- if err != nil {
- return err
- }
-
- vc.tags = tags
- return nil
-}
-
-func (vc *tagsCursor) Next() error { vc.index++; return nil }
-func (vc *tagsCursor) Eof() bool { return vc.index >= len(vc.tags) }
-func (vc *tagsCursor) Rowid() (int64, error) { return int64(0), nil }
-func (vc *tagsCursor) Close() error { return nil }
diff --git a/tables/internal/git/tags_test.go b/tables/internal/git/tags_test.go
deleted file mode 100644
index 4cacbdac..00000000
--- a/tables/internal/git/tags_test.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package git
-
-import (
- "testing"
-)
-
-func TestTags(t *testing.T) {
- tags, err := fixtureRepo.Tags.List()
- if err != nil {
- t.Fatal(err)
- }
-
- tagRows, err := fixtureDB.Query("SELECT * FROM tags")
- if err != nil {
- t.Fatal(err)
- }
-
- rowNum, contents, err := GetRowContents(tagRows)
- if err != nil {
- t.Fatalf("err %d at row Number %d", err, rowNum)
- }
-
- if len(contents) != len(tags) {
- t.Fatalf("mismatched count of tags, expected %d got %d", len(tags), len(contents))
- }
-
- // for i, c := range contents {
- // tag, err := tagIterator.Next()
- // if err != nil {
- // if err == io.EOF {
- // break
- // } else {
- // t.Fatal(err)
- // }
- // }
- // if tag.Hash().String() != c[0] {
- // t.Fatalf("expected %s at row %d got %s", tag.Hash().String(), i, c[0])
- // }
- // if tag.Name().String() != c[1] {
- // t.Fatalf("expected %s at row %d got %s", tag.Name(), i, c[1])
- // }
-
- // }
-}
-func BenchmarkTagsCounts(b *testing.B) {
- for i := 0; i < b.N; i++ {
- rows, err := fixtureDB.Query("SELECT * FROM tags")
- if err != nil {
- b.Fatal(err)
- }
- rowNum, _, err := GetRowContents(rows)
- if err != nil {
- b.Fatalf("err %d at row Number %d", err, rowNum)
- }
- }
-}
diff --git a/tables/internal/git/utils.go b/tables/internal/git/utils.go
index 2df7947d..0b8175e3 100644
--- a/tables/internal/git/utils.go
+++ b/tables/internal/git/utils.go
@@ -1,8 +1,36 @@
package git
-func boolToInt(b bool) int {
- if b {
- return 1
+import (
+ "encoding/base64"
+ "io"
+ "os"
+ "strings"
+
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/go-git/go-git/v5/plumbing"
+)
+
+// returns true if error is an end-of-file error
+func eof(err error) bool { return err == io.EOF }
+
+func enc(buf []byte) string { return base64.StdEncoding.EncodeToString(buf) }
+func dec(str string) ([]byte, error) { return base64.StdEncoding.DecodeString(str) }
+
+func isRemoteBranch(ref plumbing.ReferenceName) bool {
+ return ref.IsRemote() &&
+ plumbing.ReferenceName(strings.Replace(ref.String(), "remotes", "heads", 1)).IsBranch()
+}
+
+// GetDefaultRepoFromCtx looks up the defaultRepoPath key in the supplied context and returns it if set,
+// otherwise it returns the current working directory
+func GetDefaultRepoFromCtx(ctx services.Context) (repoPath string, err error) {
+ var ok bool
+ if repoPath, ok = ctx["defaultRepoPath"]; !ok || repoPath == "" {
+ if wd, err := os.Getwd(); err != nil {
+ return "", err
+ } else {
+ repoPath = wd
+ }
}
- return 0
+ return
}
diff --git a/tables/internal/tools/tools.go b/tables/internal/tools/tools.go
index a7dc7e2b..73cda2e4 100644
--- a/tables/internal/tools/tools.go
+++ b/tables/internal/tools/tools.go
@@ -5,34 +5,9 @@ package tools
import (
"database/sql"
_ "github.com/askgitdev/askgit/pkg/sqlite"
- git "github.com/libgit2/git2go/v31"
_ "github.com/mattn/go-sqlite3"
- "io/ioutil"
- "os"
)
-func Clone(url string) (_ *git.Repository, _ func() error, err error) {
- var dir string
- if dir, err = ioutil.TempDir("", "repo"); err != nil {
- return nil, nil, err
- }
-
- var repo *git.Repository
- if repo, err = git.Clone(url, dir, &git.CloneOptions{}); err != nil {
- return nil, nil, err
- }
-
- return repo, func() error { return os.RemoveAll(dir) }, nil
-}
-
-func RowCount(rows *sql.Rows) int {
- var count = 0
- for rows.Next() {
- count++
- }
- return count
-}
-
func RowContent(rows *sql.Rows) (colCount int, contents [][]string, err error) {
columns, err := rows.Columns()
if err != nil {
diff --git a/tables/options.go b/tables/options.go
new file mode 100644
index 00000000..4c21bbff
--- /dev/null
+++ b/tables/options.go
@@ -0,0 +1,56 @@
+package tables
+
+import (
+ "context"
+
+ "github.com/askgitdev/askgit/tables/services"
+ "github.com/go-git/go-git/v5"
+)
+
+// Options is the container for various different options
+// and configurations that can be passed to tables.RegisterFn
+// to conditionally include or tweak the extension module's behaviour
+type Options struct {
+ Locator services.RepoLocator
+
+ // whether or not to register the extra utility functions
+ // bundled with this extension
+ ExtraFunctions bool
+
+ // Context is a key-value store to pass along values to the underlying extensions
+ Context services.Context
+}
+
+// OptionFn represents any function capable of customising or providing options
+type OptionFn func(*Options)
+
+// WithExtraFunctions configures the extension to also register the bundled
+// utility sql routines.
+func WithExtraFunctions() OptionFn {
+ return func(o *Options) { o.ExtraFunctions = true }
+}
+
+// RepoLocatorFn is an adapter type that adapts any function with compatible
+// signature to a RepoLocator instance.
+type RepoLocatorFn func(ctx context.Context, path string) (*git.Repository, error)
+
+func (fn RepoLocatorFn) Open(ctx context.Context, path string) (*git.Repository, error) {
+ return fn(ctx, path)
+}
+
+// WithRepoLocator uses the provided locator implementation
+// for locating and opening git repositories.
+func WithRepoLocator(loc services.RepoLocator) OptionFn {
+ return func(o *Options) { o.Locator = loc }
+}
+
+// WithContextValue sets a value on the options context.
+// It will override any existing value set with the same key
+func WithContextValue(key, value string) OptionFn {
+ return func(o *Options) {
+ if o.Context == nil {
+ o.Context = make(map[string]string)
+ }
+ o.Context[key] = value
+ }
+}
diff --git a/tables/services/context.go b/tables/services/context.go
new file mode 100644
index 00000000..364bb8eb
--- /dev/null
+++ b/tables/services/context.go
@@ -0,0 +1,5 @@
+package services
+
+// Context is a key-value store that holds general configuration parameters for the "environment"
+// in which a module/function is executed in. For instance, it can be used to hold API tokens or configuration.
+type Context map[string]string
diff --git a/tables/services/doc.go b/tables/services/doc.go
new file mode 100644
index 00000000..e6b02fb0
--- /dev/null
+++ b/tables/services/doc.go
@@ -0,0 +1,5 @@
+// Package services provide types and interfaces that defines the various
+// abstract services that different virtual module implementations depend upon.
+// The reason its extracted out like this is to prevent a circular dependency
+// from virtual modules to tables package and vice-versa.
+package services
diff --git a/tables/services/locator.go b/tables/services/locator.go
new file mode 100644
index 00000000..c98ebdc5
--- /dev/null
+++ b/tables/services/locator.go
@@ -0,0 +1,17 @@
+package services
+
+import (
+ "context"
+
+ "github.com/go-git/go-git/v5"
+)
+
+// RepoLocator is a service that the virtual modules rely upon
+// to create or open an existing git repository.
+type RepoLocator interface {
+ // Open opens the git repository specified by path.
+ // The path need not be a file system path only and can also represent
+ // a networked resource. The implementation should return a handle
+ // to the initialized git repository instance, or throw an error.
+ Open(ctx context.Context, path string) (*git.Repository, error)
+}
diff --git a/tables/tables.go b/tables/tables.go
index 833f300b..df3820d1 100644
--- a/tables/tables.go
+++ b/tables/tables.go
@@ -6,21 +6,26 @@ package tables
import (
"github.com/askgitdev/askgit/tables/internal/funcs"
"github.com/askgitdev/askgit/tables/internal/git"
+ "github.com/askgitdev/askgit/tables/internal/git/native"
"github.com/pkg/errors"
"go.riyazali.net/sqlite"
)
-func init() {
- // register sqlite extension when this package is loaded
- sqlite.Register(func(ext *sqlite.ExtensionApi) (_ sqlite.ErrorCode, err error) {
+func RegisterFn(fns ...OptionFn) func(ext *sqlite.ExtensionApi) (_ sqlite.ErrorCode, err error) {
+ var opt = &Options{}
+ for _, fn := range fns {
+ fn(opt)
+ }
+
+ // return an extension function that register modules with sqlite when this package is loaded
+ return func(ext *sqlite.ExtensionApi) (_ sqlite.ErrorCode, err error) {
// register virtual table modules
var modules = map[string]sqlite.Module{
- "git_blame": &git.BlameModule{},
- "git_branches": &git.BranchesModule{},
- "git_files": &git.FilesModule{},
- "git_log": &git.LogModule{},
- "git_stats": &git.StatsModule{},
- "git_tags": &git.TagsModule{},
+ "commits": &git.LogModule{Locator: opt.Locator, Context: opt.Context},
+ "refs": &git.RefModule{Locator: opt.Locator, Context: opt.Context},
+ "stats": native.NewStatsModule(opt.Locator, opt.Context),
+ "files": native.NewFilesModule(opt.Locator, opt.Context),
+ "blame": native.NewBlameModule(opt.Locator, opt.Context),
}
for name, mod := range modules {
@@ -29,23 +34,36 @@ func init() {
}
}
- // register sql functions
var fns = map[string]sqlite.Function{
- "str_split": &funcs.StringSplit{},
- "toml_to_json": &funcs.TomlToJson{},
- "yaml_to_json": &funcs.YamlToJson{},
- "xml_to_json": &funcs.XmlToJson{},
+ "commit_from_tag": &git.CommitFromTagFn{},
}
- // alias yaml_to_json => yml_to_json
- fns["yml_to_json"] = fns["yaml_to_json"]
-
for name, fn := range fns {
if err = ext.CreateFunction(name, fn); err != nil {
return sqlite.SQLITE_ERROR, errors.Wrapf(err, "failed to register %q function", name)
}
}
+ // only conditionally register the utility functions
+ if opt.ExtraFunctions {
+ // register sql functions
+ var fns = map[string]sqlite.Function{
+ "str_split": &funcs.StringSplit{},
+ "toml_to_json": &funcs.TomlToJson{},
+ "yaml_to_json": &funcs.YamlToJson{},
+ "xml_to_json": &funcs.XmlToJson{},
+ }
+
+ // alias yaml_to_json => yml_to_json
+ fns["yml_to_json"] = fns["yaml_to_json"]
+
+ for name, fn := range fns {
+ if err = ext.CreateFunction(name, fn); err != nil {
+ return sqlite.SQLITE_ERROR, errors.Wrapf(err, "failed to register %q function", name)
+ }
+ }
+ }
+
return sqlite.SQLITE_OK, nil
- })
+ }
}