mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
in fact we don't need any of these options
This commit is contained in:
@ -1116,13 +1116,9 @@ func (c *GitCommand) FetchRemote(remoteName string) error {
|
|||||||
return c.OSCommand.RunCommand("git fetch %s", remoteName)
|
return c.OSCommand.RunCommand("git fetch %s", remoteName)
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetReflogCommitsOptions struct {
|
|
||||||
Recycle bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetReflogCommits only returns the new reflog commits since the given lastReflogCommit
|
// GetReflogCommits 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) GetReflogCommits(lastReflogCommit *Commit, options GetReflogCommitsOptions) ([]*Commit, bool, error) {
|
func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit) ([]*Commit, bool, error) {
|
||||||
commits := make([]*Commit, 0)
|
commits := make([]*Commit, 0)
|
||||||
re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`)
|
re := regexp.MustCompile(`(\w+).*HEAD@\{([^\}]+)\}: (.*)`)
|
||||||
|
|
||||||
@ -1143,7 +1139,7 @@ func (c *GitCommand) GetReflogCommits(lastReflogCommit *Commit, options GetReflo
|
|||||||
Status: "reflog",
|
Status: "reflog",
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.Recycle && lastReflogCommit != nil && commit.Sha == lastReflogCommit.Sha && commit.UnixTimestamp == lastReflogCommit.UnixTimestamp {
|
if lastReflogCommit != nil && commit.Sha == lastReflogCommit.Sha && commit.UnixTimestamp == lastReflogCommit.UnixTimestamp {
|
||||||
onlyObtainedNewReflogCommits = true
|
onlyObtainedNewReflogCommits = true
|
||||||
// after this point we already have these reflogs loaded so we'll simply return the new ones
|
// after this point we already have these reflogs loaded so we'll simply return the new ones
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -73,22 +73,19 @@ func (gui *Gui) handleCommitSelect(g *gocui.Gui, v *gocui.View) error {
|
|||||||
|
|
||||||
// during startup, the bottleneck is fetching the reflog entries. We need these
|
// during startup, the bottleneck is fetching the reflog entries. We need these
|
||||||
// on startup to sort the branches by recency. So we have two phases: INITIAL, and COMPLETE.
|
// on startup to sort the branches by recency. So we have two phases: INITIAL, and COMPLETE.
|
||||||
// In the initial phase we get a small set of reflog entries so that we can ensure
|
// In the initial phase we don't get any reflog commits, but we asynchronously get them
|
||||||
// the first couple of branches are correctly positioned. Then we asynchronously
|
// and refresh the branches after that
|
||||||
// refresh the reflog again, without a limit, and refresh the branches again when that's done.
|
|
||||||
// When we're complete, we can begin recycling reflog entries because we know we've got
|
|
||||||
// everything down to the oldest entry.
|
|
||||||
func (gui *Gui) refreshReflogCommitsConsideringStartup() {
|
func (gui *Gui) refreshReflogCommitsConsideringStartup() {
|
||||||
switch gui.State.StartupStage {
|
switch gui.State.StartupStage {
|
||||||
case INITIAL:
|
case INITIAL:
|
||||||
go func() {
|
go func() {
|
||||||
gui.refreshReflogCommits(refreshReflogOptions{Recycle: false})
|
gui.refreshReflogCommits()
|
||||||
gui.refreshBranches()
|
gui.refreshBranches()
|
||||||
gui.State.StartupStage = COMPLETE
|
gui.State.StartupStage = COMPLETE
|
||||||
}()
|
}()
|
||||||
|
|
||||||
case COMPLETE:
|
case COMPLETE:
|
||||||
gui.refreshReflogCommits(refreshReflogOptions{Recycle: true})
|
gui.refreshReflogCommits()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,17 +46,13 @@ func (gui *Gui) handleReflogCommitSelect(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type refreshReflogOptions struct {
|
func (gui *Gui) refreshReflogCommits() error {
|
||||||
Recycle bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) refreshReflogCommits(options refreshReflogOptions) error {
|
|
||||||
var lastReflogCommit *commands.Commit
|
var lastReflogCommit *commands.Commit
|
||||||
if len(gui.State.ReflogCommits) > 0 {
|
if len(gui.State.ReflogCommits) > 0 {
|
||||||
lastReflogCommit = gui.State.ReflogCommits[0]
|
lastReflogCommit = gui.State.ReflogCommits[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
commits, onlyObtainedNewReflogCommits, err := gui.GitCommand.GetReflogCommits(lastReflogCommit, commands.GetReflogCommitsOptions(options))
|
commits, onlyObtainedNewReflogCommits, err := gui.GitCommand.GetReflogCommits(lastReflogCommit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return gui.createErrorPanel(gui.g, err.Error())
|
return gui.createErrorPanel(gui.g, err.Error())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user