mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Add inline status for pushing tags and deleting remote tags
This commit is contained in:
parent
3ac5ef2d41
commit
2592bc6939
|
|
@ -27,7 +27,12 @@ func NewTagsContext(
|
|||
)
|
||||
|
||||
getDisplayStrings := func(_ int, _ int) [][]string {
|
||||
return presentation.GetTagListDisplayStrings(viewModel.GetItems(), c.Modes().Diffing.Ref)
|
||||
return presentation.GetTagListDisplayStrings(
|
||||
viewModel.GetItems(),
|
||||
func(tag *models.Tag) types.RefOperation {
|
||||
return c.State().GetRefOperation(tag.FullRefName())
|
||||
},
|
||||
c.Modes().Diffing.Ref, c.Tr)
|
||||
}
|
||||
|
||||
return &TagsContext{
|
||||
|
|
|
|||
|
|
@ -131,6 +131,9 @@ func (self *TagsController) remoteDelete(tag *models.Tag) error {
|
|||
Prompt: confirmPrompt,
|
||||
HandleConfirm: func() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.DeletingStatus, func(t gocui.Task) error {
|
||||
self.c.State().SetRefOperation(tag.FullRefName(), types.RefOperationDeleting, context.TAGS_CONTEXT_KEY)
|
||||
defer func() { self.c.State().ClearRefOperation(tag.FullRefName(), context.TAGS_CONTEXT_KEY) }()
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.DeleteRemoteTag)
|
||||
if err := self.c.Git().Remote.DeleteRemoteTag(t, upstream, tag.Name); err != nil {
|
||||
return self.c.Error(err)
|
||||
|
|
@ -190,6 +193,16 @@ func (self *TagsController) push(tag *models.Tag) error {
|
|||
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteSuggestionsFunc(),
|
||||
HandleConfirm: func(response string) error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.PushingTagStatus, func(task gocui.Task) error {
|
||||
self.c.State().SetRefOperation(tag.FullRefName(), types.RefOperationPushing, context.TAGS_CONTEXT_KEY)
|
||||
defer func() {
|
||||
self.c.State().ClearRefOperation(tag.FullRefName(), context.TAGS_CONTEXT_KEY)
|
||||
// Render again to remove the inline status:
|
||||
self.c.OnUIThread(func() error {
|
||||
_ = self.c.Contexts().Tags.HandleRender()
|
||||
return nil
|
||||
})
|
||||
}()
|
||||
|
||||
self.c.LogAction(self.c.Tr.Actions.PushTag)
|
||||
err := self.c.Git().Tag.Push(task, response, tag.Name)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ func refOperationToString(refOperation types.RefOperation, tr *i18n.TranslationS
|
|||
return tr.PullingStatus
|
||||
case types.RefOperationFastForwarding:
|
||||
return tr.FastForwardingOperation
|
||||
case types.RefOperationDeleting:
|
||||
return tr.DeletingStatus
|
||||
}
|
||||
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -4,19 +4,27 @@ import (
|
|||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||
"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/utils"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func GetTagListDisplayStrings(tags []*models.Tag, diffName string) [][]string {
|
||||
func GetTagListDisplayStrings(
|
||||
tags []*models.Tag,
|
||||
getRefOperation func(branch *models.Tag) types.RefOperation,
|
||||
diffName string,
|
||||
tr *i18n.TranslationSet,
|
||||
) [][]string {
|
||||
return lo.Map(tags, func(tag *models.Tag, _ int) []string {
|
||||
diffed := tag.Name == diffName
|
||||
return getTagDisplayStrings(tag, diffed)
|
||||
return getTagDisplayStrings(tag, getRefOperation(tag), diffed, tr)
|
||||
})
|
||||
}
|
||||
|
||||
// getTagDisplayStrings returns the display string of branch
|
||||
func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
|
||||
func getTagDisplayStrings(t *models.Tag, refOperation types.RefOperation, diffed bool, tr *i18n.TranslationSet) []string {
|
||||
textStyle := theme.DefaultTextColor
|
||||
if diffed {
|
||||
textStyle = theme.DiffTerminalColor
|
||||
|
|
@ -26,6 +34,11 @@ func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
|
|||
res = append(res, textStyle.Sprint(icons.IconForTag(t)))
|
||||
}
|
||||
descriptionColor := style.FgYellow
|
||||
res = append(res, textStyle.Sprint(t.Name), descriptionColor.Sprint(t.Description()))
|
||||
descriptionStr := descriptionColor.Sprint(t.Description())
|
||||
refOperationStr := refOperationToString(refOperation, tr)
|
||||
if refOperationStr != "" {
|
||||
descriptionStr = style.FgCyan.Sprint(refOperationStr+" "+utils.Loader()) + " " + descriptionStr
|
||||
}
|
||||
res = append(res, textStyle.Sprint(t.Name), descriptionStr)
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ const (
|
|||
RefOperationPushing
|
||||
RefOperationPulling
|
||||
RefOperationFastForwarding
|
||||
RefOperationDeleting
|
||||
)
|
||||
|
||||
type IStateAccessor interface {
|
||||
|
|
|
|||
Loading…
Reference in a new issue