2018-09-17 13:02:30 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/fatih/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Commit : A git commit
|
|
|
|
type Commit struct {
|
|
|
|
Sha string
|
|
|
|
Name string
|
|
|
|
Pushed bool
|
2018-09-20 01:41:29 +02:00
|
|
|
Merged bool
|
2018-09-17 13:02:30 +02:00
|
|
|
DisplayString string
|
|
|
|
}
|
|
|
|
|
2018-11-30 00:04:08 +02:00
|
|
|
// GetDisplayStrings is a function
|
2018-09-17 13:02:30 +02:00
|
|
|
func (c *Commit) GetDisplayStrings() []string {
|
|
|
|
red := color.New(color.FgRed)
|
2018-09-20 01:41:29 +02:00
|
|
|
yellow := color.New(color.FgGreen)
|
|
|
|
green := color.New(color.FgYellow)
|
2018-09-17 13:02:30 +02:00
|
|
|
white := color.New(color.FgWhite)
|
|
|
|
|
|
|
|
shaColor := yellow
|
|
|
|
if c.Pushed {
|
|
|
|
shaColor = red
|
2018-09-20 01:41:29 +02:00
|
|
|
} else if !c.Merged {
|
|
|
|
shaColor = green
|
2018-09-17 13:02:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return []string{shaColor.Sprint(c.Sha), white.Sprint(c.Name)}
|
|
|
|
}
|