1
1
package controllers
2
2
3
3
import (
4
+ "fmt"
5
+ "strings"
6
+
4
7
"github.com/jesseduffield/gocui"
5
8
"github.com/jesseduffield/lazygit/pkg/commands/models"
6
9
"github.com/jesseduffield/lazygit/pkg/gui/context"
10
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
7
11
"github.com/jesseduffield/lazygit/pkg/gui/types"
8
12
"github.com/jesseduffield/lazygit/pkg/utils"
13
+ "github.com/samber/lo"
9
14
)
10
15
11
16
type TagsController struct {
@@ -96,7 +101,8 @@ func (self *TagsController) GetOnRenderToMain() func() {
96
101
task = types .NewRenderStringTask ("No tags" )
97
102
} else {
98
103
cmdObj := self .c .Git ().Branch .GetGraphCmdObj (tag .FullRefName ())
99
- task = types .NewRunCommandTask (cmdObj .GetCmd ())
104
+ prefix := self .getTagInfo (tag ) + "\n \n ---\n \n "
105
+ task = types .NewRunCommandTaskWithPrefix (cmdObj .GetCmd (), prefix )
100
106
}
101
107
102
108
self .c .RenderToMainViews (types.RefreshMainOpts {
@@ -110,6 +116,35 @@ func (self *TagsController) GetOnRenderToMain() func() {
110
116
}
111
117
}
112
118
119
+ func (self * TagsController ) getTagInfo (tag * models.Tag ) string {
120
+ if tag .IsAnnotated {
121
+ info := fmt .Sprintf ("%s: %s" , self .c .Tr .AnnotatedTag , style .AttrBold .Sprint (style .FgYellow .Sprint (tag .Name )))
122
+ output , err := self .c .Git ().Tag .ShowAnnotationInfo (tag .Name )
123
+ if err == nil {
124
+ info += "\n \n " + strings .TrimRight (filterOutPgpSignature (output ), "\n " )
125
+ }
126
+ return info
127
+ }
128
+
129
+ return fmt .Sprintf ("%s: %s" , self .c .Tr .LightweightTag , style .AttrBold .Sprint (style .FgYellow .Sprint (tag .Name )))
130
+ }
131
+
132
+ func filterOutPgpSignature (output string ) string {
133
+ lines := strings .Split (output , "\n " )
134
+ inPgpSignature := false
135
+ filteredLines := lo .Filter (lines , func (line string , _ int ) bool {
136
+ if line == "-----END PGP SIGNATURE-----" {
137
+ inPgpSignature = false
138
+ return false
139
+ }
140
+ if line == "-----BEGIN PGP SIGNATURE-----" {
141
+ inPgpSignature = true
142
+ }
143
+ return ! inPgpSignature
144
+ })
145
+ return strings .Join (filteredLines , "\n " )
146
+ }
147
+
113
148
func (self * TagsController ) checkout (tag * models.Tag ) error {
114
149
self .c .LogAction (self .c .Tr .Actions .CheckoutTag )
115
150
if err := self .c .Helpers ().Refs .CheckoutRef (tag .FullRefName (), types.CheckoutRefOptions {}); err != nil {
0 commit comments