66 "strconv"
77 "strings"
88
9- "github.com/jesseduffield/gocui"
109 "github.com/jesseduffield/lazygit/pkg/gui/keybindings"
1110 "github.com/jesseduffield/lazygit/pkg/gui/types"
1211 "github.com/jesseduffield/lazygit/pkg/utils"
@@ -43,6 +42,10 @@ type CommitMessageViewModel struct {
4342 // invoked when pressing the switch-to-editor key binding
4443 onSwitchToEditor func (string ) error
4544
45+ // the following two fields are used for the display of the "hooks disabled" subtitle
46+ forceSkipHooks bool
47+ skipHooksPrefix string
48+
4649 // The message typed in before cycling through history
4750 // We store this separately to 'preservedMessage' because 'preservedMessage'
4851 // is specifically for committing staged files and we don't want this affected
@@ -149,12 +152,16 @@ func (self *CommitMessageContext) SetPanelState(
149152 initialMessage string ,
150153 onConfirm func (string , string ) error ,
151154 onSwitchToEditor func (string ) error ,
155+ forceSkipHooks bool ,
156+ skipHooksPrefix string ,
152157) {
153158 self .viewModel .selectedindex = index
154159 self .viewModel .preserveMessage = preserveMessage
155160 self .viewModel .initialMessage = initialMessage
156161 self .viewModel .onConfirm = onConfirm
157162 self .viewModel .onSwitchToEditor = onSwitchToEditor
163+ self .viewModel .forceSkipHooks = forceSkipHooks
164+ self .viewModel .skipHooksPrefix = skipHooksPrefix
158165 self .GetView ().Title = summaryTitle
159166 self .c .Views ().CommitDescription .Title = descriptionTitle
160167
@@ -167,16 +174,24 @@ func (self *CommitMessageContext) SetPanelState(
167174 self .c .Views ().CommitDescription .Visible = true
168175}
169176
170- func (self * CommitMessageContext ) RenderCommitLength () {
177+ func (self * CommitMessageContext ) RenderSubtitle () {
178+ skipHookPrefix := self .viewModel .skipHooksPrefix
179+ subject := self .c .Views ().CommitMessage .TextArea .GetContent ()
180+ var subtitle string
181+ if self .viewModel .forceSkipHooks || (skipHookPrefix != "" && strings .HasPrefix (subject , skipHookPrefix )) {
182+ subtitle = self .c .Tr .CommitHooksDisabledSubTitle
183+ }
171184 if self .c .UserConfig ().Gui .CommitLength .Show {
172- self .c .Views ().CommitMessage .Subtitle = getBufferLength (self .c .Views ().CommitMessage )
173- } else {
174- self .c .Views ().CommitMessage .Subtitle = ""
185+ if subtitle != "" {
186+ subtitle += "─"
187+ }
188+ subtitle += getBufferLength (subject )
175189 }
190+ self .c .Views ().CommitMessage .Subtitle = subtitle
176191}
177192
178- func getBufferLength (view * gocui. View ) string {
179- return " " + strconv .Itoa (strings .Count (view . TextArea . GetContent () , "" )- 1 ) + " "
193+ func getBufferLength (subject string ) string {
194+ return " " + strconv .Itoa (strings .Count (subject , "" )- 1 ) + " "
180195}
181196
182197func (self * CommitMessageContext ) SwitchToEditor (message string ) error {
0 commit comments