summaryrefslogtreecommitdiffstats
path: root/pkg/commands/commit.go
blob: 4c304271db8946fc57dff0f47d43c1faf519a1c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package commands

import (
	"github.com/fatih/color"
)

// Commit : A git commit
type Commit struct {
	Sha           string
	Name          string
	Pushed        bool
	Merged        bool
	DisplayString string
}

// GetDisplayStrings is a function.
func (c *Commit) GetDisplayStrings() []string {
	red := color.New(color.FgRed)
	yellow := color.New(color.FgGreen)
	green := color.New(color.FgYellow)
	white := color.New(color.FgWhite)

	shaColor := yellow
	if c.Pushed {
		shaColor = red
	} else if !c.Merged {
		shaColor = green
	}

	return []string{shaColor.Sprint(c.Sha), white.Sprint(c.Name)}
}