From a7e840f3f18fd8d61274ed5cd1b9df495ea3e9f1 Mon Sep 17 00:00:00 2001 From: Patrick DeVivo Date: Sun, 15 Nov 2020 16:10:19 -0500 Subject: [PATCH 1/2] add stats table info --- README.md | 11 +++++++++-- pkg/gitqlite/git_stats.go | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e80d3f19..6bd872c5 100644 --- a/README.md +++ b/README.md @@ -119,8 +119,6 @@ Similar to `git log`, the `commits` table includes all commits in the history of | parent_id | TEXT | | parent_count | INT | | tree_id | TEXT | -| additions | INT | -| deletions | INT | #### `files` @@ -160,6 +158,15 @@ Use the `commit_id` column to filter for files that belong to the work tree of a | message | TEXT | | target_type | TEXT | +#### `stats` + +| Column | Type | +|-----------|------| +| commit_id | TEXT | +| file | TEXT | +| additions | INT | +| deletions | INT | + ### Example Queries This will return all commits in the history of the currently checked out branch/commit of the repo. diff --git a/pkg/gitqlite/git_stats.go b/pkg/gitqlite/git_stats.go index 5fadd54f..5f3e3fc4 100644 --- a/pkg/gitqlite/git_stats.go +++ b/pkg/gitqlite/git_stats.go @@ -20,8 +20,8 @@ func (m *gitStatsModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3.V CREATE TABLE %q ( commit_id TEXT, file TEXT, - additions TEXT, - deletions TEXT + additions INT, + deletions INT )`, args[0])) if err != nil { return nil, err From d1d233fc46c896bec0333ccfefc9c8b1b136819e Mon Sep 17 00:00:00 2001 From: Patrick DeVivo Date: Sun, 15 Nov 2020 16:31:19 -0500 Subject: [PATCH 2/2] remove extra columns --- pkg/gitqlite/git_log.go | 4 +--- pkg/gitqlite/git_log_cli.go | 9 +-------- pkg/gitqlite/git_log_cli_test.go | 2 +- pkg/gitqlite/git_log_test.go | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/pkg/gitqlite/git_log.go b/pkg/gitqlite/git_log.go index 47642bb5..600fd84c 100644 --- a/pkg/gitqlite/git_log.go +++ b/pkg/gitqlite/git_log.go @@ -31,9 +31,7 @@ func (m *gitLogModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3.VTa committer_when DATETIME, parent_id TEXT, parent_count INT, - tree_id TEXT, - additions INT, - deletions INT + tree_id TEXT )`, args[0])) if err != nil { return nil, err diff --git a/pkg/gitqlite/git_log_cli.go b/pkg/gitqlite/git_log_cli.go index 95ff5770..6a34b6eb 100644 --- a/pkg/gitqlite/git_log_cli.go +++ b/pkg/gitqlite/git_log_cli.go @@ -30,9 +30,7 @@ func (m *gitLogCLIModule) Create(c *sqlite3.SQLiteConn, args []string) (sqlite3. committer_when DATETIME, parent_id TEXT, parent_count INT, - tree_id TEXT, - additions INT, - deletions INT + tree_id TEXT )`, args[0])) if err != nil { return nil, err @@ -154,11 +152,6 @@ func (vc *commitCLICursor) Column(c *sqlite3.SQLiteContext, col int) error { case 11: //tree_id c.ResultText(current.TreeID) - case 12: - c.ResultInt(current.Additions) - case 13: - c.ResultInt(current.Deletions) - } return nil } diff --git a/pkg/gitqlite/git_log_cli_test.go b/pkg/gitqlite/git_log_cli_test.go index ea2dff17..4fcddc56 100644 --- a/pkg/gitqlite/git_log_cli_test.go +++ b/pkg/gitqlite/git_log_cli_test.go @@ -42,7 +42,7 @@ func TestCommitCounts(t *testing.T) { if err != nil { t.Fatal(err) } - expected := 14 + expected := 12 if len(columns) != expected { t.Fatalf("expected %d columns, got: %d", expected, len(columns)) } diff --git a/pkg/gitqlite/git_log_test.go b/pkg/gitqlite/git_log_test.go index d827163f..96d2de45 100644 --- a/pkg/gitqlite/git_log_test.go +++ b/pkg/gitqlite/git_log_test.go @@ -45,7 +45,7 @@ func TestCommits(t *testing.T) { t.Fatal(err) } - expected := 14 + expected := 12 if len(columns) != expected { t.Fatalf("expected %d columns, got: %d", expected, len(columns)) }