diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-21 11:56:34 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-25 09:39:04 +1100 |
commit | f80d15062b4296c452645b167e76c1a5a13e52fc (patch) | |
tree | 7b3d14c768c69e6a4095483c9d9679dc2f4103bc /pkg/commands | |
parent | b1b0219f04ab0e17dd0ce0f5469dee7daecf2717 (diff) |
use reflog undo history pointer
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/git.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 6fabfe273..222d53af0 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -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", } |