diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 22b92ea0a..ab13e6523 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -495,7 +495,8 @@ func (self *CommitLoader) commitFromPatch(content string) *models.Commit { func setCommitMergedStatuses(ancestor string, commits []*models.Commit) []*models.Commit { passedAncestor := false for i, commit := range commits { - if strings.HasPrefix(ancestor, commit.Sha) { + // some commits aren't really commits and don't have sha's, such as the update-ref todo + if commit.Sha != "" && strings.HasPrefix(ancestor, commit.Sha) { passedAncestor = true } if commit.Status != models.StatusPushed && commit.Status != models.StatusUnpushed { diff --git a/pkg/commands/git_commands/commit_loader_test.go b/pkg/commands/git_commands/commit_loader_test.go index a281cb775..c3cfb0585 100644 --- a/pkg/commands/git_commands/commit_loader_test.go +++ b/pkg/commands/git_commands/commit_loader_test.go @@ -541,7 +541,7 @@ func TestCommitLoader_setCommitMergedStatuses(t *testing.T) { expectedCommits: []*models.Commit{ {Sha: "12345", Name: "1", Action: models.ActionNone, Status: models.StatusUnpushed}, {Sha: "", Name: "", Action: todo.UpdateRef, Status: models.StatusNone}, - {Sha: "abcde", Name: "3", Action: models.ActionNone, Status: models.StatusMerged}, // Wrong, expect Pushed + {Sha: "abcde", Name: "3", Action: models.ActionNone, Status: models.StatusPushed}, }, }, }