1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

use reflog undo history pointer

This commit is contained in:
Jesse Duffield
2020-03-21 11:56:34 +11:00
parent b1b0219f04
commit f80d15062b
8 changed files with 84 additions and 27 deletions

View File

@ -1106,15 +1106,15 @@ func (c *GitCommand) FetchRemote(remoteName string) error {
}
func (c *GitCommand) GetReflogCommits() ([]*Commit, error) {
output, err := c.OSCommand.RunCommandWithOutput("git reflog --abbrev=20")
output, err := c.OSCommand.RunCommandWithOutput("git reflog --abbrev=20 --date=iso")
if err != nil {
// assume error means we have no reflog
return []*Commit{}, nil
}
lines := strings.Split(strings.TrimSpace(output), "\n")
commits := make([]*Commit, 0)
re := regexp.MustCompile(`(\w+).*HEAD@\{\d+\}: (.*)`)
commits := make([]*Commit, 0, len(lines))
re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`)
for _, line := range lines {
match := re.FindStringSubmatch(line)
if len(match) <= 1 {
@ -1123,7 +1123,8 @@ func (c *GitCommand) GetReflogCommits() ([]*Commit, error) {
commit := &Commit{
Sha: match[1],
Name: match[2],
Name: match[3],
Date: match[2],
Status: "reflog",
}