2018-09-17 13:02:30 +02:00
|
|
|
package commands
|
|
|
|
|
2020-08-16 14:01:14 +02:00
|
|
|
import "fmt"
|
|
|
|
|
2018-09-17 13:02:30 +02:00
|
|
|
// Commit : A git commit
|
|
|
|
type Commit struct {
|
2020-03-27 10:12:15 +02:00
|
|
|
Sha string
|
|
|
|
Name string
|
|
|
|
Status string // one of "unpushed", "pushed", "merged", "rebasing" or "selected"
|
|
|
|
Action string // one of "", "pick", "edit", "squash", "reword", "drop", "fixup"
|
|
|
|
Tags []string
|
|
|
|
ExtraInfo string // something like 'HEAD -> master, tag: v0.15.2'
|
|
|
|
Author string
|
|
|
|
UnixTimestamp int64
|
2020-08-27 09:00:43 +02:00
|
|
|
|
|
|
|
// IsMerge tells us whether we're dealing with a merge commit i.e. a commit with two parents
|
|
|
|
IsMerge bool
|
2018-09-17 13:02:30 +02:00
|
|
|
}
|
2020-03-26 00:18:52 +02:00
|
|
|
|
|
|
|
func (c *Commit) ShortSha() string {
|
|
|
|
if len(c.Sha) < 8 {
|
|
|
|
return c.Sha
|
|
|
|
}
|
|
|
|
return c.Sha[:8]
|
|
|
|
}
|
2020-08-16 14:01:14 +02:00
|
|
|
|
2020-08-19 14:57:22 +02:00
|
|
|
func (c *Commit) RefName() string {
|
|
|
|
return c.Sha
|
|
|
|
}
|
2020-08-22 01:01:14 +02:00
|
|
|
|
|
|
|
func (c *Commit) ID() string {
|
|
|
|
return c.RefName()
|
|
|
|
}
|
2020-08-22 02:14:53 +02:00
|
|
|
|
|
|
|
func (c *Commit) Description() string {
|
|
|
|
return fmt.Sprintf("%s %s", c.Sha[:7], c.Name)
|
|
|
|
}
|