Skip to content

Commit 66eabd3

Browse files
authored
Merge pull request #284 from intersystems/fix-default-mappings
committed git-webui/release branch
2 parents 84ea497 + 2b0c345 commit 66eabd3

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
176176
location.reload();
177177
return false;
178178
}
179+
// here
179180
webui.showError(displayMessage);
180181
}
181182
} else {
@@ -322,7 +323,10 @@ webui.SideBarView = function(mainView, noEventHandlers) {
322323
}
323324
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
324325
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
326330
var itemId = refname + idPostfix;
327331
var cardHeader = $('<div class="card-header" id="heading-' + itemId + '">').appendTo(cardDiv);
328332
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) {
335339
'<div class="d-grid gap-2 col-12 mx-auto">'+
336340
'<button class="btn btn-xs btn-primary btn-block btn-checkout-local-branch mt-1">Checkout Branch</button>'+
337341
'<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>' : '')+
339343
'<button class="btn btn-xs btn-danger btn-block btn-delete-branch">Delete Branch</button>'+
340344
'</div>'+
341345
'</div>').appendTo(collapseDiv);
342346
} else {
343347
$(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+
}
349355
}
350356
} else {
351357
var refname = ref.replaceAll('/', '-');
@@ -754,7 +760,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
754760
$("#sidebar-settings", self.element).click(self.goToSettingsPage);
755761
}
756762

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");
758764
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
759765
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");
760766

0 commit comments

Comments
 (0)