Skip to content

Commit

Permalink
Merge pull request #284 from intersystems/fix-default-mappings
Browse files Browse the repository at this point in the history
committed git-webui/release branch
  • Loading branch information
isc-tleavitt authored Sep 14, 2023
2 parents 84ea497 + 2b0c345 commit 66eabd3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions git-webui/release/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
location.reload();
return false;
}
// here
webui.showError(displayMessage);
}
} else {
Expand Down Expand Up @@ -322,7 +323,10 @@ webui.SideBarView = function(mainView, noEventHandlers) {
}
var cardDiv = $('<div class="card custom-card">').appendTo(accordionDiv)[0];
if (id.indexOf("local-branches") > -1) {
var refname = ref.substring(2);
// parses the output of git branch --verbose --verbose
var branchInfo = /^\*?\s*(?<branch_name>[\w-]+)\s+(?<hash>[^\s]+)\s+(?<remote>\[.*\])?.*/.exec(ref).groups;
var refname = branchInfo.branch_name;
var canPush = (branchInfo.remote === undefined) || (branchInfo.remote.includes("ahead")) // either no upstream or ahead of upstream
var itemId = refname + idPostfix;
var cardHeader = $('<div class="card-header" id="heading-' + itemId + '">').appendTo(cardDiv);
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 + '">'
Expand All @@ -335,17 +339,19 @@ webui.SideBarView = function(mainView, noEventHandlers) {
'<div class="d-grid gap-2 col-12 mx-auto">'+
'<button class="btn btn-xs btn-primary btn-block btn-checkout-local-branch mt-1">Checkout Branch</button>'+
'<button class="btn btn-xs btn-warning btn-block btn-merge-branch">Merge Branch</button>'+
'<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>'+
(canPush ? '<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>' : '')+
'<button class="btn btn-xs btn-danger btn-block btn-delete-branch">Delete Branch</button>'+
'</div>'+
'</div>').appendTo(collapseDiv);
} else {
$(button).addClass("branch-current");
var cardBody = $('<div class="card-body">' +
'<div class="d-grid gap-2 col-12 mx-auto">'+
'<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>'+
'</div>'+
'</div>').appendTo(collapseDiv);
if (canPush) {
var cardBody = $('<div class="card-body">' +
'<div class="d-grid gap-2 col-12 mx-auto">'+
'<button class="btn btn-xs btn-warning btn-block btn-push-branch">Push Branch</button>'+
'</div>'+
'</div>').appendTo(collapseDiv);
}
}
} else {
var refname = ref.replaceAll('/', '-');
Expand Down Expand Up @@ -754,7 +760,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
$("#sidebar-settings", self.element).click(self.goToSettingsPage);
}

self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch");
self.fetchSection($("#sidebar-local-branches", self.element)[0], "Local Branches", "local-branches", "branch --verbose --verbose");
self.fetchSection($("#sidebar-remote-branches", self.element)[0], "Remote Branches", "remote-branches", "branch --remotes");
self.fetchSection($("#sidebar-tags", self.element)[0], "Tags", "tags", "tag");

Expand Down

0 comments on commit 66eabd3

Please sign in to comment.