@@ -176,6 +176,7 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
176
176
location . reload ( ) ;
177
177
return false ;
178
178
}
179
+ // here
179
180
webui . showError ( displayMessage ) ;
180
181
}
181
182
} else {
@@ -322,7 +323,10 @@ webui.SideBarView = function(mainView, noEventHandlers) {
322
323
}
323
324
var cardDiv = $ ( '<div class="card custom-card">' ) . appendTo ( accordionDiv ) [ 0 ] ;
324
325
if ( id . indexOf ( "local-branches" ) > - 1 ) {
325
- var refname = ref . substring ( 2 ) ;
326
+ // parses the output of git branch --verbose --verbose
327
+ var branchInfo = / ^ \* ? \s * (?< branch_name > [ \w - ] + ) \s + (?< hash > [ ^ \s ] + ) \s + (?< remote > \[ .* \] ) ? .* / . exec ( ref ) . groups ;
328
+ var refname = branchInfo . branch_name ;
329
+ var canPush = ( branchInfo . remote === undefined ) || ( branchInfo . remote . includes ( "ahead" ) ) // either no upstream or ahead of upstream
326
330
var itemId = refname + idPostfix ;
327
331
var cardHeader = $ ( '<div class="card-header" id="heading-' + itemId + '">' ) . appendTo ( cardDiv ) ;
328
332
var button = $ ( '<button class="btn btn-sm btn-default btn-branch text-left" type="button" data-toggle="collapse" data-target="#collapse-' + itemId + '" aria-expanded="true" aria-controls="collapse-' + itemId + '">'
@@ -335,17 +339,19 @@ webui.SideBarView = function(mainView, noEventHandlers) {
335
339
'<div class="d-grid gap-2 col-12 mx-auto">' +
336
340
'<button class="btn btn-xs btn-primary btn-block btn-checkout-local-branch mt-1">Checkout Branch</button>' +
337
341
'<button class="btn btn-xs btn-warning btn-block btn-merge-branch">Merge Branch</button>' +
338
- '<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>' +
342
+ ( canPush ? '<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>' : '' ) +
339
343
'<button class="btn btn-xs btn-danger btn-block btn-delete-branch">Delete Branch</button>' +
340
344
'</div>' +
341
345
'</div>' ) . appendTo ( collapseDiv ) ;
342
346
} else {
343
347
$ ( button ) . addClass ( "branch-current" ) ;
344
- var cardBody = $ ( '<div class="card-body">' +
345
- '<div class="d-grid gap-2 col-12 mx-auto">' +
346
- '<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>' +
347
- '</div>' +
348
- '</div>' ) . appendTo ( collapseDiv ) ;
348
+ if ( canPush ) {
349
+ var cardBody = $ ( '<div class="card-body">' +
350
+ '<div class="d-grid gap-2 col-12 mx-auto">' +
351
+ '<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>' +
352
+ '</div>' +
353
+ '</div>' ) . appendTo ( collapseDiv ) ;
354
+ }
349
355
}
350
356
} else {
351
357
var refname = ref . replaceAll ( '/' , '-' ) ;
@@ -754,7 +760,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
754
760
$ ( "#sidebar-settings" , self . element ) . click ( self . goToSettingsPage ) ;
755
761
}
756
762
757
- self . fetchSection ( $ ( "#sidebar-local-branches" , self . element ) [ 0 ] , "Local Branches" , "local-branches" , "branch" ) ;
763
+ self . fetchSection ( $ ( "#sidebar-local-branches" , self . element ) [ 0 ] , "Local Branches" , "local-branches" , "branch --verbose --verbose " ) ;
758
764
self . fetchSection ( $ ( "#sidebar-remote-branches" , self . element ) [ 0 ] , "Remote Branches" , "remote-branches" , "branch --remotes" ) ;
759
765
self . fetchSection ( $ ( "#sidebar-tags" , self . element ) [ 0 ] , "Tags" , "tags" , "tag" ) ;
760
766
0 commit comments