mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-17 22:32:58 +02:00
Add inline status for pushing tags and deleting remote tags
This commit is contained in:
parent
707fa37160
commit
3d6965ccbb
@ -24,6 +24,10 @@ func (t *Tag) ID() string {
|
|||||||
return t.RefName()
|
return t.RefName()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Tag) URN() string {
|
||||||
|
return "tag-" + t.ID()
|
||||||
|
}
|
||||||
|
|
||||||
func (t *Tag) Description() string {
|
func (t *Tag) Description() string {
|
||||||
return t.Message
|
return t.Message
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,10 @@ func NewTagsContext(
|
|||||||
)
|
)
|
||||||
|
|
||||||
getDisplayStrings := func(_ int, _ int) [][]string {
|
getDisplayStrings := func(_ int, _ int) [][]string {
|
||||||
return presentation.GetTagListDisplayStrings(viewModel.GetItems(), c.Modes().Diffing.Ref)
|
return presentation.GetTagListDisplayStrings(
|
||||||
|
viewModel.GetItems(),
|
||||||
|
c.State().GetItemOperation,
|
||||||
|
c.Modes().Diffing.Ref, c.Tr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &TagsContext{
|
return &TagsContext{
|
||||||
|
@ -129,9 +129,9 @@ func (self *TagsController) remoteDelete(tag *models.Tag) error {
|
|||||||
Title: confirmTitle,
|
Title: confirmTitle,
|
||||||
Prompt: confirmPrompt,
|
Prompt: confirmPrompt,
|
||||||
HandleConfirm: func() error {
|
HandleConfirm: func() error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.DeletingStatus, func(t gocui.Task) error {
|
return self.c.WithInlineStatus(tag, types.ItemOperationDeleting, context.TAGS_CONTEXT_KEY, func(task gocui.Task) error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.DeleteRemoteTag)
|
self.c.LogAction(self.c.Tr.Actions.DeleteRemoteTag)
|
||||||
if err := self.c.Git().Remote.DeleteRemoteTag(t, upstream, tag.Name); err != nil {
|
if err := self.c.Git().Remote.DeleteRemoteTag(task, upstream, tag.Name); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
self.c.Toast(self.c.Tr.RemoteTagDeletedMessage)
|
self.c.Toast(self.c.Tr.RemoteTagDeletedMessage)
|
||||||
@ -188,9 +188,16 @@ func (self *TagsController) push(tag *models.Tag) error {
|
|||||||
InitialContent: "origin",
|
InitialContent: "origin",
|
||||||
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteSuggestionsFunc(),
|
FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteSuggestionsFunc(),
|
||||||
HandleConfirm: func(response string) error {
|
HandleConfirm: func(response string) error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.PushingTagStatus, func(task gocui.Task) error {
|
return self.c.WithInlineStatus(tag, types.ItemOperationPushing, context.TAGS_CONTEXT_KEY, func(task gocui.Task) error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.PushTag)
|
self.c.LogAction(self.c.Tr.Actions.PushTag)
|
||||||
err := self.c.Git().Tag.Push(task, response, tag.Name)
|
err := self.c.Git().Tag.Push(task, response, tag.Name)
|
||||||
|
|
||||||
|
// Render again to remove the inline status:
|
||||||
|
self.c.OnUIThread(func() error {
|
||||||
|
_ = self.c.Contexts().Tags.HandleRender()
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -4,19 +4,27 @@ import (
|
|||||||
"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 GetTagListDisplayStrings(tags []*models.Tag, diffName string) [][]string {
|
func GetTagListDisplayStrings(
|
||||||
|
tags []*models.Tag,
|
||||||
|
getItemOperation func(item types.HasUrn) types.ItemOperation,
|
||||||
|
diffName string,
|
||||||
|
tr *i18n.TranslationSet,
|
||||||
|
) [][]string {
|
||||||
return lo.Map(tags, func(tag *models.Tag, _ int) []string {
|
return lo.Map(tags, func(tag *models.Tag, _ int) []string {
|
||||||
diffed := tag.Name == diffName
|
diffed := tag.Name == diffName
|
||||||
return getTagDisplayStrings(tag, diffed)
|
return getTagDisplayStrings(tag, getItemOperation(tag), diffed, tr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// getTagDisplayStrings returns the display string of branch
|
// getTagDisplayStrings returns the display string of branch
|
||||||
func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
|
func getTagDisplayStrings(t *models.Tag, itemOperation types.ItemOperation, diffed bool, tr *i18n.TranslationSet) []string {
|
||||||
textStyle := theme.DefaultTextColor
|
textStyle := theme.DefaultTextColor
|
||||||
if diffed {
|
if diffed {
|
||||||
textStyle = theme.DiffTerminalColor
|
textStyle = theme.DiffTerminalColor
|
||||||
@ -26,6 +34,11 @@ func getTagDisplayStrings(t *models.Tag, diffed bool) []string {
|
|||||||
res = append(res, textStyle.Sprint(icons.IconForTag(t)))
|
res = append(res, textStyle.Sprint(icons.IconForTag(t)))
|
||||||
}
|
}
|
||||||
descriptionColor := style.FgYellow
|
descriptionColor := style.FgYellow
|
||||||
res = append(res, textStyle.Sprint(t.Name), descriptionColor.Sprint(t.Description()))
|
descriptionStr := descriptionColor.Sprint(t.Description())
|
||||||
|
itemOperationStr := itemOperationToString(itemOperation, tr)
|
||||||
|
if itemOperationStr != "" {
|
||||||
|
descriptionStr = style.FgCyan.Sprint(itemOperationStr+" "+utils.Loader()) + " " + descriptionStr
|
||||||
|
}
|
||||||
|
res = append(res, textStyle.Sprint(t.Name), descriptionStr)
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user