mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
Use inline status for fetching remotes
This commit is contained in:
@@ -15,6 +15,10 @@ func (r *Remote) ID() string {
|
|||||||
return r.RefName()
|
return r.RefName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Remote) URN() string {
|
||||||
|
return "remote-" + r.ID()
|
||||||
|
}
|
||||||
|
|
||||||
func (r *Remote) Description() string {
|
func (r *Remote) Description() string {
|
||||||
return r.RefName()
|
return r.RefName()
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,8 @@ func NewRemotesContext(c *ContextCommon) *RemotesContext {
|
|||||||
)
|
)
|
||||||
|
|
||||||
getDisplayStrings := func(_ int, _ int) [][]string {
|
getDisplayStrings := func(_ int, _ int) [][]string {
|
||||||
return presentation.GetRemoteListDisplayStrings(viewModel.GetItems(), c.Modes().Diffing.Ref)
|
return presentation.GetRemoteListDisplayStrings(
|
||||||
|
viewModel.GetItems(), c.Modes().Diffing.Ref, c.State().GetItemOperation, c.Tr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &RemotesContext{
|
return &RemotesContext{
|
||||||
|
@@ -206,12 +206,15 @@ func (self *RemotesController) edit(remote *models.Remote) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *RemotesController) fetch(remote *models.Remote) error {
|
func (self *RemotesController) fetch(remote *models.Remote) error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.FetchingRemoteStatus, func(task gocui.Task) error {
|
return self.c.WithInlineStatus(remote, types.ItemOperationFetching, context.REMOTES_CONTEXT_KEY, func(task gocui.Task) error {
|
||||||
err := self.c.Git().Sync.FetchRemote(task, remote.Name)
|
err := self.c.Git().Sync.FetchRemote(task, remote.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = self.c.Error(err)
|
_ = self.c.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}})
|
return self.c.Refresh(types.RefreshOptions{
|
||||||
|
Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES},
|
||||||
|
Mode: types.ASYNC,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,8 @@ func ItemOperationToString(itemOperation types.ItemOperation, tr *i18n.Translati
|
|||||||
return tr.FastForwarding
|
return tr.FastForwarding
|
||||||
case types.ItemOperationDeleting:
|
case types.ItemOperationDeleting:
|
||||||
return tr.DeletingStatus
|
return tr.DeletingStatus
|
||||||
|
case types.ItemOperationFetching:
|
||||||
|
return tr.FetchingStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
@@ -1,22 +1,37 @@
|
|||||||
package presentation
|
package presentation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetRemoteListDisplayStrings(remotes []*models.Remote, diffName string) [][]string {
|
func GetRemoteListDisplayStrings(
|
||||||
|
remotes []*models.Remote,
|
||||||
|
diffName string,
|
||||||
|
getItemOperation func(item types.HasUrn) types.ItemOperation,
|
||||||
|
tr *i18n.TranslationSet,
|
||||||
|
) [][]string {
|
||||||
return lo.Map(remotes, func(remote *models.Remote, _ int) []string {
|
return lo.Map(remotes, func(remote *models.Remote, _ int) []string {
|
||||||
diffed := remote.Name == diffName
|
diffed := remote.Name == diffName
|
||||||
return getRemoteDisplayStrings(remote, diffed)
|
return getRemoteDisplayStrings(remote, diffed, getItemOperation(remote), tr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// getRemoteDisplayStrings returns the display string of branch
|
// getRemoteDisplayStrings returns the display string of branch
|
||||||
func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
|
func getRemoteDisplayStrings(
|
||||||
|
r *models.Remote,
|
||||||
|
diffed bool,
|
||||||
|
itemOperation types.ItemOperation,
|
||||||
|
tr *i18n.TranslationSet,
|
||||||
|
) []string {
|
||||||
branchCount := len(r.Branches)
|
branchCount := len(r.Branches)
|
||||||
|
|
||||||
textStyle := theme.DefaultTextColor
|
textStyle := theme.DefaultTextColor
|
||||||
@@ -28,6 +43,11 @@ func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
|
|||||||
if icons.IsIconEnabled() {
|
if icons.IsIconEnabled() {
|
||||||
res = append(res, textStyle.Sprint(icons.IconForRemote(r)))
|
res = append(res, textStyle.Sprint(icons.IconForRemote(r)))
|
||||||
}
|
}
|
||||||
res = append(res, textStyle.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount))
|
descriptionStr := style.FgBlue.Sprintf("%d branches", branchCount)
|
||||||
|
itemOperationStr := ItemOperationToString(itemOperation, tr)
|
||||||
|
if itemOperationStr != "" {
|
||||||
|
descriptionStr += " " + style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader(time.Now()))
|
||||||
|
}
|
||||||
|
res = append(res, textStyle.Sprint(r.Name), descriptionStr)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@@ -308,6 +308,7 @@ const (
|
|||||||
ItemOperationPulling
|
ItemOperationPulling
|
||||||
ItemOperationFastForwarding
|
ItemOperationFastForwarding
|
||||||
ItemOperationDeleting
|
ItemOperationDeleting
|
||||||
|
ItemOperationFetching
|
||||||
)
|
)
|
||||||
|
|
||||||
type HasUrn interface {
|
type HasUrn interface {
|
||||||
|
Reference in New Issue
Block a user