diff options
author | Mark Kopenga <mkopenga@gmail.com> | 2021-10-18 18:58:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 18:58:46 +0200 |
commit | a496858c629e3c6241b51cf99cd38d6fa1b787bc (patch) | |
tree | 6842acfec59dfc6fb6df8f333fcd6b2d6695aafd /pkg | |
parent | e4888e924ed55abdcc07c924df734afd0921a46e (diff) | |
parent | 40bc3aa5a9edca5fa562a0056522e117476fe84c (diff) |
Merge pull request #1529 from Ryooooooga/feature/backward-compatibility
Improve backward compatibility
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/loading_commits.go | 2 | ||||
-rw-r--r-- | pkg/commands/loading_reflog_commits.go | 15 |
2 files changed, 8 insertions, 9 deletions
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", } |