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

remove redundant fetch of reflog

This commit is contained in:
Jesse Duffield
2020-03-26 22:31:14 +11:00
parent d1395b15bb
commit bd2c1eef53

View File

@ -1124,17 +1124,10 @@ func (c *GitCommand) FetchRemote(remoteName string) error {
// GetNewReflogCommits only returns the new reflog commits since the given lastReflogCommit // GetNewReflogCommits only returns the new reflog commits since the given lastReflogCommit
// if none is passed (i.e. it's value is nil) then we get all the reflog commits // if none is passed (i.e. it's value is nil) then we get all the reflog commits
func (c *GitCommand) GetNewReflogCommits(lastReflogCommit *Commit) ([]*Commit, error) { func (c *GitCommand) GetNewReflogCommits(lastReflogCommit *Commit) ([]*Commit, error) {
output, err := c.OSCommand.RunCommandWithOutput("git reflog --abbrev=20 --date=iso") commits := make([]*Commit, 0)
if err != nil {
// assume error means we have no reflog
return []*Commit{}, nil
}
lines := strings.Split(strings.TrimSpace(output), "\n")
commits := make([]*Commit, 0, len(lines))
re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`) re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`)
cmd := c.OSCommand.ExecutableFromString("git reflog --abbrev=20 --date=iso") cmd := c.OSCommand.ExecutableFromString("git reflog --abbrev=20 --date=iso")
err = RunLineOutputCmd(cmd, func(line string) (bool, error) { err := RunLineOutputCmd(cmd, func(line string) (bool, error) {
match := re.FindStringSubmatch(line) match := re.FindStringSubmatch(line)
if len(match) <= 1 { if len(match) <= 1 {
return false, nil return false, nil