1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/commands/models/commit.go

49 lines
1.1 KiB
Go
Raw Normal View History

2020-09-29 10:36:54 +02:00
package models
2022-01-19 09:32:27 +02:00
import (
"fmt"
"github.com/jesseduffield/lazygit/pkg/utils"
)
// Commit : A git commit
type Commit struct {
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
2021-06-05 08:39:59 +02:00
// SHAs of parent commits (will be multiple if it's a merge commit)
Parents []string
}
2020-03-26 00:18:52 +02:00
func (c *Commit) ShortSha() string {
2022-01-19 09:32:27 +02:00
return utils.ShortSha(c.Sha)
2020-03-26 00:18:52 +02:00
}
2020-08-19 14:57:22 +02:00
func (c *Commit) RefName() string {
return c.Sha
}
func (c *Commit) ID() string {
return c.RefName()
}
func (c *Commit) Description() string {
return fmt.Sprintf("%s %s", c.Sha[:7], c.Name)
}
2021-06-05 08:39:59 +02:00
func (c *Commit) IsMerge() bool {
return len(c.Parents) > 1
}
// returns true if this commit is not actually in the git log but instead
// is from a TODO file for an interactive rebase.
func (c *Commit) IsTODO() bool {
return c.Action != ""
}