Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

committed git-webui/release branch #284

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading