mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-10 04:07:18 +02:00
Improve backward compatibility
This commit is contained in:
parent
e4888e924e
commit
40bc3aa5a9
@ -361,7 +361,7 @@ func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) *exec.Cmd {
|
|||||||
|
|
||||||
return c.OSCommand.ExecutableFromString(
|
return c.OSCommand.ExecutableFromString(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"git log %s --oneline --pretty=format:\"%%H%s%%at%s%%aN%s%%d%s%%p%s%%s\" %s --abbrev=%d --date=unix %s",
|
"git log %s --oneline --pretty=format:\"%%H%s%%at%s%%aN%s%%d%s%%p%s%%s\" %s --abbrev=%d %s",
|
||||||
c.OSCommand.Quote(opts.RefName),
|
c.OSCommand.Quote(opts.RefName),
|
||||||
SEPARATION_CHAR,
|
SEPARATION_CHAR,
|
||||||
SEPARATION_CHAR,
|
SEPARATION_CHAR,
|
||||||
|
@ -2,8 +2,8 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
@ -13,26 +13,25 @@ import (
|
|||||||
// 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) GetReflogCommits(lastReflogCommit *models.Commit, filterPath string) ([]*models.Commit, bool, error) {
|
func (c *GitCommand) GetReflogCommits(lastReflogCommit *models.Commit, filterPath string) ([]*models.Commit, bool, error) {
|
||||||
commits := make([]*models.Commit, 0)
|
commits := make([]*models.Commit, 0)
|
||||||
re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`)
|
|
||||||
|
|
||||||
filterPathArg := ""
|
filterPathArg := ""
|
||||||
if filterPath != "" {
|
if filterPath != "" {
|
||||||
filterPathArg = fmt.Sprintf(" --follow -- %s", c.OSCommand.Quote(filterPath))
|
filterPathArg = fmt.Sprintf(" --follow -- %s", c.OSCommand.Quote(filterPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := c.OSCommand.ExecutableFromString(fmt.Sprintf("git reflog --abbrev=20 --date=unix %s", filterPathArg))
|
cmd := c.OSCommand.ExecutableFromString(fmt.Sprintf(`git log -g --abbrev=20 --format="%%h %%ct %%gs" %s`, filterPathArg))
|
||||||
onlyObtainedNewReflogCommits := false
|
onlyObtainedNewReflogCommits := false
|
||||||
err := oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) {
|
err := oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) {
|
||||||
match := re.FindStringSubmatch(line)
|
fields := strings.SplitN(line, " ", 3)
|
||||||
if len(match) <= 1 {
|
if len(fields) <= 2 {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
unixTimestamp, _ := strconv.Atoi(match[2])
|
unixTimestamp, _ := strconv.Atoi(fields[1])
|
||||||
|
|
||||||
commit := &models.Commit{
|
commit := &models.Commit{
|
||||||
Sha: match[1],
|
Sha: fields[0],
|
||||||
Name: match[3],
|
Name: fields[2],
|
||||||
UnixTimestamp: int64(unixTimestamp),
|
UnixTimestamp: int64(unixTimestamp),
|
||||||
Status: "reflog",
|
Status: "reflog",
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user