summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation/commits_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/presentation/commits_test.go')
-rw-r--r--pkg/gui/presentation/commits_test.go71
1 files changed, 71 insertions, 0 deletions
diff --git a/pkg/gui/presentation/commits_test.go b/pkg/gui/presentation/commits_test.go
index 31c6c813d..b6684f80e 100644
--- a/pkg/gui/presentation/commits_test.go
+++ b/pkg/gui/presentation/commits_test.go
@@ -28,6 +28,8 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
scenarios := []struct {
testName string
commits []*models.Commit
+ branches []*models.Branch
+ currentBranchName string
fullDescription bool
cherryPickedCommitShaSet *set.Set[string]
diffName string
@@ -73,6 +75,73 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
`),
},
{
+ testName: "commit with tags",
+ commits: []*models.Commit{
+ {Name: "commit1", Sha: "sha1", Tags: []string{"tag1", "tag2"}},
+ {Name: "commit2", Sha: "sha2"},
+ },
+ startIdx: 0,
+ length: 2,
+ showGraph: false,
+ bisectInfo: git_commands.NewNullBisectInfo(),
+ cherryPickedCommitShaSet: set.New[string](),
+ now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
+ expected: formatExpected(`
+ sha1 tag1 tag2 commit1
+ sha2 commit2
+ `),
+ },
+ {
+ testName: "show local branch head, except the current branch, main branches, or merged branches",
+ commits: []*models.Commit{
+ {Name: "commit1", Sha: "sha1"},
+ {Name: "commit2", Sha: "sha2"},
+ {Name: "commit3", Sha: "sha3"},
+ {Name: "commit4", Sha: "sha4", Status: models.StatusMerged},
+ },
+ branches: []*models.Branch{
+ {Name: "current-branch", CommitHash: "sha1", Head: true},
+ {Name: "other-branch", CommitHash: "sha2", Head: false},
+ {Name: "master", CommitHash: "sha3", Head: false},
+ {Name: "old-branch", CommitHash: "sha4", Head: false},
+ },
+ currentBranchName: "current-branch",
+ startIdx: 0,
+ length: 4,
+ showGraph: false,
+ bisectInfo: git_commands.NewNullBisectInfo(),
+ cherryPickedCommitShaSet: set.New[string](),
+ now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
+ expected: formatExpected(`
+ sha1 commit1
+ sha2 * commit2
+ sha3 commit3
+ sha4 commit4
+ `),
+ },
+ {
+ testName: "show local branch head and tag if both exist",
+ commits: []*models.Commit{
+ {Name: "commit1", Sha: "sha1"},
+ {Name: "commit2", Sha: "sha2", Tags: []string{"some-tag"}},
+ {Name: "commit3", Sha: "sha3"},
+ },
+ branches: []*models.Branch{
+ {Name: "some-branch", CommitHash: "sha2"},
+ },
+ startIdx: 0,
+ length: 3,
+ showGraph: false,
+ bisectInfo: git_commands.NewNullBisectInfo(),
+ cherryPickedCommitShaSet: set.New[string](),
+ now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
+ expected: formatExpected(`
+ sha1 commit1
+ sha2 * some-tag commit2
+ sha3 commit3
+ `),
+ },
+ {
testName: "showing graph",
commits: []*models.Commit{
{Name: "commit1", Sha: "sha1", Parents: []string{"sha2", "sha3"}},
@@ -285,6 +354,8 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
result := GetCommitListDisplayStrings(
common,
s.commits,
+ s.branches,
+ s.currentBranchName,
s.fullDescription,
s.cherryPickedCommitShaSet,
s.diffName,