From 40bc3aa5a9edca5fa562a0056522e117476fe84c Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Mon, 18 Oct 2021 22:44:01 +0900 Subject: Improve backward compatibility --- pkg/commands/loading_commits.go | 2 +- pkg/commands/loading_reflog_commits.go | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'pkg/commands') diff --git a/pkg/commands/loading_commits.go b/pkg/commands/loading_commits.go index e7d27e094..f5c1d662e 100644 --- a/pkg/commands/loading_commits.go +++ b/pkg/commands/loading_commits.go @@ -361,7 +361,7 @@ func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) *exec.Cmd { return c.OSCommand.ExecutableFromString( 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), SEPARATION_CHAR, SEPARATION_CHAR, diff --git a/pkg/commands/loading_reflog_commits.go b/pkg/commands/loading_reflog_commits.go index 0c6915543..619e5c225 100644 --- a/pkg/commands/loading_reflog_commits.go +++ b/pkg/commands/loading_reflog_commits.go @@ -2,8 +2,8 @@ package commands import ( "fmt" - "regexp" "strconv" + "strings" "github.com/jesseduffield/lazygit/pkg/commands/models" "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 func (c *GitCommand) GetReflogCommits(lastReflogCommit *models.Commit, filterPath string) ([]*models.Commit, bool, error) { commits := make([]*models.Commit, 0) - re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`) filterPathArg := "" if 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 err := oscommands.RunLineOutputCmd(cmd, func(line string) (bool, error) { - match := re.FindStringSubmatch(line) - if len(match) <= 1 { + fields := strings.SplitN(line, " ", 3) + if len(fields) <= 2 { return false, nil } - unixTimestamp, _ := strconv.Atoi(match[2]) + unixTimestamp, _ := strconv.Atoi(fields[1]) commit := &models.Commit{ - Sha: match[1], - Name: match[3], + Sha: fields[0], + Name: fields[2], UnixTimestamp: int64(unixTimestamp), Status: "reflog", } -- cgit v1.2.3