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

add reflog tab in commits panel

This commit is contained in:
Jesse Duffield
2020-01-09 21:34:17 +11:00
parent 79e696d8a7
commit 9b32e99eb8
13 changed files with 257 additions and 30 deletions

View File

@ -1113,3 +1113,28 @@ func (c *GitCommand) PushTag(remoteName string, tagName string) error {
func (c *GitCommand) FetchRemote(remoteName string) error {
return c.OSCommand.RunCommand("git fetch %s", remoteName)
}
func (c *GitCommand) GetReflogCommits() ([]*Commit, error) {
output, err := c.OSCommand.RunCommandWithOutput("git reflog")
if err != nil {
return nil, err
}
lines := strings.Split(strings.TrimSpace(output), "\n")
commits := make([]*Commit, len(lines))
re := regexp.MustCompile(`(\w+).*HEAD@\{\d+\}: (.*)`)
for i, line := range lines {
match := re.FindStringSubmatch(line)
if len(match) == 1 {
continue
}
commits[i] = &Commit{
Sha: match[1],
Name: match[2],
Status: "reflog",
}
}
return commits, nil
}