Skip to content

Commit d3bd875

Browse files
committed
Expose commit parents in commit table
Signed-off-by: Manuel Carmona <[email protected]>
1 parent ab6002b commit d3bd875

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

commits.go

+11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var CommitsSchema = sql.Schema{
2323
{Name: "committer_when", Type: sql.Timestamp, Nullable: false, Source: CommitsTableName},
2424
{Name: "message", Type: sql.Text, Nullable: false, Source: CommitsTableName},
2525
{Name: "tree_hash", Type: sql.Text, Nullable: false, Source: CommitsTableName},
26+
{Name: "parents", Type: sql.Array(sql.Text), Nullable: false, Source: CommitsTableName},
2627
}
2728

2829
var _ sql.PushdownProjectionAndFiltersTable = (*commitsTable)(nil)
@@ -186,5 +187,15 @@ func commitToRow(c *object.Commit) sql.Row {
186187
c.Committer.When,
187188
c.Message,
188189
c.TreeHash.String(),
190+
getParentHashes(c),
189191
)
190192
}
193+
194+
func getParentHashes(c *object.Commit) []interface{} {
195+
parentHashes := make([]interface{}, 0, len(c.ParentHashes))
196+
for _, plumbingHash := range c.ParentHashes {
197+
parentHashes = append(parentHashes, plumbingHash.String())
198+
}
199+
200+
return parentHashes
201+
}

internal/rule/squashjoins_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func TestSquashJoins(t *testing.T) {
7373
nil,
7474
false,
7575
),
76-
[]int{4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1, 2, 3},
76+
[]int{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 1, 2, 3},
7777
gitbase.RepositoriesTableName,
7878
gitbase.ReferencesTableName,
7979
gitbase.CommitsTableName,

0 commit comments

Comments
 (0)