File tree Expand file tree Collapse file tree 3 files changed +32
-8
lines changed Expand file tree Collapse file tree 3 files changed +32
-8
lines changed Original file line number Diff line number Diff line change 4545      - red 
4646  commitLength :
4747    show : true 
48+     commitLengthWarning : 0 
4849  mouseEvents : true 
4950  skipUnstageLineWarning : false 
5051  skipStashWarning : false 
@@ -530,4 +531,4 @@ notARepository: 'create'
530531` ` ` yaml
531532# to skip without creating a new repo 
532533notARepository: 'skip' 
533- ` ` ` 
534+ ` ` ` 
Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ type ThemeConfig struct {
6767}
6868
6969type  CommitLengthConfig  struct  {
70- 	Show  bool  `yaml:"show"` 
70+ 	Show                 bool  `yaml:"show"` 
71+ 	CommitLengthWarning  int   `yaml:"commitLengthWarning"` 
7172}
7273
7374type  GitConfig  struct  {
@@ -362,7 +363,10 @@ func GetDefaultConfig() *UserConfig {
362363				CherryPickedCommitFgColor : []string {"blue" },
363364				UnstagedChangesColor :      []string {"red" },
364365			},
365- 			CommitLength :             CommitLengthConfig {Show : true },
366+ 			CommitLength : CommitLengthConfig {
367+ 				Show :                true ,
368+ 				CommitLengthWarning : 72 ,
369+ 			},
366370			SkipNoStagedFilesWarning : false ,
367371			ShowListFooter :           true ,
368372			ShowCommandLog :           true ,
Original file line number Diff line number Diff line change 11package  gui
22
33import  (
4- 	"strconv " 
4+ 	"bufio " 
55	"strings" 
6- 
6+ 	 "fmt" 
77	"github.com/jesseduffield/gocui" 
88	"github.com/jesseduffield/lazygit/pkg/utils" 
9+ 	"github.com/jesseduffield/lazygit/pkg/theme" 
910)
1011
1112func  (gui  * Gui ) handleCommitMessageFocused () error  {
@@ -28,9 +29,27 @@ func (gui *Gui) RenderCommitLength() {
2829		return 
2930	}
3031
31- 	gui .Views .CommitMessage .Subtitle  =  getBufferLength (gui .Views .CommitMessage )
32+ 	commitLength  :=  getBufferLength (gui .Views .CommitMessage )
33+ 	gui .Views .CommitMessage .Subtitle  =  fmt .Sprintf (" %d " , commitLength )
34+ 	gui .checkCommitLengthWarning (commitLength )
3235}
3336
34- func  getBufferLength (view  * gocui.View ) string  {
35- 	return  " "   +   strconv . Itoa ( strings .Count (view .TextArea .GetContent (), "" )- 1 )  +   " " 
37+ func  getBufferLength (view  * gocui.View ) int  {
38+ 	return  strings .Count (view .TextArea .GetContent (), "" )  -   1 
3639}
40+ 
41+ func  (gui  * Gui ) checkCommitLengthWarning (commitLength  int ) {
42+ 	if  gui .c .UserConfig .Gui .CommitLength .CommitLengthWarning  ==  0  {
43+ 		return 
44+ 	}
45+ 
46+ 	scanner  :=  bufio .NewScanner (strings .NewReader (gui .Views .CommitMessage .TextArea .GetContent ()))
47+ 
48+ 	for  scanner .Scan () {
49+ 		if  len (scanner .Text ()) >  gui .c .UserConfig .Gui .CommitLength .CommitLengthWarning  {
50+ 			gui .Views .CommitMessage .FgColor  =  gocui .ColorRed 
51+ 		} else  {
52+ 			gui .Views .CommitMessage .FgColor  =  theme .GocuiDefaultTextColor 
53+ 		}
54+ 	}
55+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments