-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add file parameter to blame so it doesn't return all the results… (#988)
Add file parameter to blame so it doesn't return all the results from a commit
- Loading branch information
Showing
7 changed files
with
65 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -514,12 +514,12 @@ func TestIntegration(t *testing.T) { | |
SELECT repository_id, JSON_EXTRACT(bl, "$.author"), | ||
COUNT(bl) | ||
FROM ( | ||
SELECT repository_id, EXPLODE(BLAME(repository_id, commit_hash)) as bl | ||
SELECT repository_id, EXPLODE(BLAME(repository_id, commit_hash, '.gitignore')) as bl | ||
FROM commits | ||
WHERE commit_hash = '918c48b83bd081e863dbe1b80f8998f058cd8294' | ||
) as p | ||
`, | ||
[]sql.Row{{"worktree", "[email protected]", int64(7235)}}, | ||
[]sql.Row{{"worktree", "[email protected]", int64(12)}}, | ||
}, | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ func TestBlameEval(t *testing.T) { | |
name string | ||
repo sql.Expression | ||
commit sql.Expression | ||
file sql.Expression | ||
row sql.Row | ||
expected BlameLine | ||
expectedNil bool | ||
|
@@ -38,11 +39,11 @@ func TestBlameEval(t *testing.T) { | |
name: "init commit", | ||
repo: expression.NewGetField(0, sql.Text, "repository_id", false), | ||
commit: expression.NewGetField(1, sql.Text, "commit_hash", false), | ||
row: sql.NewRow("worktree", "b029517f6300c2da0f4b651b8642506cd6aaf45d"), | ||
file: expression.NewGetField(2, sql.Text, "file", false), | ||
row: sql.NewRow("worktree", "b029517f6300c2da0f4b651b8642506cd6aaf45d", ".gitignore"), | ||
testedLine: 0, | ||
lineCount: 12, | ||
expected: BlameLine{ | ||
".gitignore", | ||
0, | ||
"[email protected]", | ||
"*.class", | ||
|
@@ -53,11 +54,11 @@ func TestBlameEval(t *testing.T) { | |
name: "changelog", | ||
repo: expression.NewGetField(0, sql.Text, "repository_id", false), | ||
commit: expression.NewGetField(1, sql.Text, "commit_hash", false), | ||
row: sql.NewRow("worktree", "b8e471f58bcbca63b07bda20e428190409c2db47"), | ||
file: expression.NewGetField(2, sql.Text, "file", false), | ||
row: sql.NewRow("worktree", "b8e471f58bcbca63b07bda20e428190409c2db47", "CHANGELOG"), | ||
testedLine: 0, | ||
lineCount: 1, | ||
expected: BlameLine{ | ||
"CHANGELOG", | ||
0, | ||
"[email protected]", | ||
"Initial changelog", | ||
|
@@ -68,7 +69,8 @@ func TestBlameEval(t *testing.T) { | |
name: "no repo", | ||
repo: expression.NewGetField(0, sql.Text, "repository_id", false), | ||
commit: expression.NewGetField(1, sql.Text, "commit_hash", false), | ||
row: sql.NewRow("foo", "bar"), | ||
file: expression.NewGetField(2, sql.Text, "file", false), | ||
row: sql.NewRow("foo", "bar", "baz"), | ||
testedLine: 0, | ||
lineCount: 1, | ||
expected: BlameLine{}, | ||
|
@@ -78,7 +80,19 @@ func TestBlameEval(t *testing.T) { | |
name: "no commit", | ||
repo: expression.NewGetField(0, sql.Text, "repository_id", false), | ||
commit: expression.NewGetField(1, sql.Text, "commit_hash", false), | ||
row: sql.NewRow("worktree", "foo"), | ||
file: expression.NewGetField(2, sql.Text, "file", false), | ||
row: sql.NewRow("worktree", "foo", "bar"), | ||
testedLine: 0, | ||
lineCount: 1, | ||
expected: BlameLine{}, | ||
expectedNil: true, | ||
}, | ||
{ | ||
name: "no file", | ||
repo: expression.NewGetField(0, sql.Text, "repository_id", false), | ||
commit: expression.NewGetField(1, sql.Text, "commit_hash", false), | ||
file: expression.NewGetField(2, sql.Text, "file", false), | ||
row: sql.NewRow("worktree", "b8e471f58bcbca63b07bda20e428190409c2db47", "foo"), | ||
testedLine: 0, | ||
lineCount: 1, | ||
expected: BlameLine{}, | ||
|
@@ -88,7 +102,7 @@ func TestBlameEval(t *testing.T) { | |
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
blame := NewBlame(tc.repo, tc.commit) | ||
blame := NewBlame(tc.repo, tc.commit, tc.file) | ||
blameGen, err := blame.Eval(ctx, tc.row) | ||
require.NoError(t, err) | ||
|
||
|
@@ -105,9 +119,6 @@ func TestBlameEval(t *testing.T) { | |
lineCount := 0 | ||
for i, err := bg.Next(); err == nil; i, err = bg.Next() { | ||
i := i.(BlameLine) | ||
if i.File != tc.expected.File { | ||
continue | ||
} | ||
if lineCount != tc.testedLine { | ||
lineCount++ | ||
continue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters