Skip to content

Commit 9831296

Browse files
committed
BUG/MINOR: allow commit check to run with one commit only
when starting repository, only one author will be present (only one commit), account for that and for similar situation where only one author exist
1 parent 222c0d2 commit 9831296

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

check.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,13 @@ func getLocalCommitData() ([]string, []string, []map[string]string, error) {
361361
diffs := []map[string]string{}
362362
committer := ""
363363
var commit1 *object.Commit
364+
var oldestCommit *object.Commit
364365
var commit2 *object.Commit
365366
for {
366367
commit, err := iter.Next()
368+
if commit != nil {
369+
oldestCommit = commit
370+
}
367371
if err == io.EOF {
368372
break
369373
}
@@ -399,6 +403,9 @@ func getLocalCommitData() ([]string, []string, []map[string]string, error) {
399403

400404
// Get the changes (diff) between the two commits
401405
tree1, _ := commit1.Tree()
406+
if commit2 == nil {
407+
commit2 = oldestCommit
408+
}
402409
tree2, _ := commit2.Tree()
403410
changes, err := object.DiffTree(tree2, tree1)
404411
if err != nil {

0 commit comments

Comments
 (0)