File tree Expand file tree Collapse file tree 4 files changed +58
-13
lines changed Expand file tree Collapse file tree 4 files changed +58
-13
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ var main = {
99
99
reload : function ( ) {
100
100
git . status ( ) ;
101
101
102
+ view . branchbox . setText ( git . getCurrentBranchName ( ) ) ;
103
+
102
104
main . setItems ( ) ;
103
105
104
106
main . moveToUnstaged ( 0 ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ var gitExec = 'git';
6
6
7
7
function Git ( path ) {
8
8
this . path = path ;
9
+
10
+ this . loadBranches ( ) ;
9
11
}
10
12
11
13
Git . prototype . clear = function ( ) {
@@ -207,4 +209,27 @@ Git.prototype.diff = function (type, index) {
207
209
return stdout . toString ( ) ;
208
210
} ;
209
211
212
+ Git . prototype . loadBranches = function ( ) {
213
+ var self = this ;
214
+
215
+ var gitCommand = gitExec + ' branch --list' ;
216
+
217
+ var stdout = execSync ( gitCommand ) ;
218
+
219
+ this . branches = stdout . toString ( ) . split ( '\n' )
220
+ . map ( function ( line , index ) {
221
+ if ( line . charAt ( 0 ) === '*' ) {
222
+ self . currentBranchIndex = index ;
223
+ }
224
+
225
+ return line . slice ( 2 ) ;
226
+ } ) ;
227
+
228
+ return this . branches ;
229
+ } ;
230
+
231
+ Git . prototype . getCurrentBranchName = function ( ) {
232
+ return this . branches [ this . currentBranchIndex ] ;
233
+ } ;
234
+
210
235
module . exports = Git ;
Original file line number Diff line number Diff line change @@ -7,24 +7,27 @@ var screen = blessed.screen(styles.screen);
7
7
8
8
// bind screen to child elems
9
9
_ . merge ( styles , {
10
- title : {
10
+ title : {
11
11
staged : { parent : screen } ,
12
12
unstaged : { parent : screen }
13
13
} ,
14
- list : {
14
+ list : {
15
15
staged : { parent : screen } ,
16
16
unstaged : { parent : screen }
17
17
} ,
18
- menubar1 : {
18
+ branchbox : {
19
19
parent : screen
20
20
} ,
21
- menubar2 : {
21
+ menubar1 : {
22
22
parent : screen
23
23
} ,
24
- loading : {
24
+ menubar2 : {
25
25
parent : screen
26
26
} ,
27
- popup : {
27
+ loading : {
28
+ parent : screen
29
+ } ,
30
+ popup : {
28
31
parent : screen
29
32
}
30
33
} ) ;
@@ -42,6 +45,8 @@ var list = {
42
45
list . staged . name = "staged" ;
43
46
list . unstaged . name = "unstaged" ;
44
47
48
+ var branchbox = blessed . text ( styles . branchbox ) ;
49
+
45
50
blessed . listbar ( styles . menubar1 ) ;
46
51
blessed . listbar ( styles . menubar2 ) ;
47
52
@@ -50,9 +55,10 @@ var loading = blessed.loading(styles.loading);
50
55
var popup = blessed . box ( styles . popup ) ;
51
56
52
57
module . exports = {
53
- screen : screen ,
54
- title : title ,
55
- list : list ,
56
- loading : loading ,
57
- popup : popup
58
+ screen : screen ,
59
+ title : title ,
60
+ list : list ,
61
+ branchbox : branchbox ,
62
+ loading : loading ,
63
+ popup : popup
58
64
} ;
Original file line number Diff line number Diff line change 44
44
"align" : " left" ,
45
45
"tags" : true ,
46
46
"width" : " 50%" ,
47
- "height" : " 100%-5 " ,
47
+ "height" : " 100%-6 " ,
48
48
"interactive" : false ,
49
49
"keys" : true ,
50
50
"style" : {
64
64
"align" : " left" ,
65
65
"tags" : true ,
66
66
"width" : " 50%" ,
67
- "height" : " 100%-5 " ,
67
+ "height" : " 100%-6 " ,
68
68
"interactive" : true ,
69
69
"keys" : true ,
70
70
"style" : {
77
77
}
78
78
}
79
79
},
80
+ "branchbox" : {
81
+ "align" : " center" ,
82
+ "bottom" : 3 ,
83
+ "height" : 1 ,
84
+ "align" : " right" ,
85
+ "padding" : {
86
+ "right" : 2
87
+ },
88
+ "style" : {
89
+ "fg" : " yellow"
90
+ }
91
+ },
80
92
"menubar1" : {
81
93
"align" : " center" ,
82
94
"bottom" : 1 ,
You can’t perform that action at this time.
0 commit comments