Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.1] - Unreleased
## [2.3.0] - Unreleased

### Added
- Web UI includes a "Push Branch" button for local branches that are ahead of upstream

### Fixed
- Studio export path doesn't get weird mixed slahes on Windows (#252)
Expand Down
23 changes: 18 additions & 5 deletions git-webui/release/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,19 +329,23 @@ webui.SideBarView = function(mainView, noEventHandlers) {
+ refname
+ '</button>').appendTo(cardHeader);

var collapseDiv = $('<div id="collapse-'+ itemId +'" class="accordion-collapse collapse" aria-labelledby="heading-' + itemId +'" data-parent="#accordion-'+id+'-'+idPostfix+'">').appendTo(cardDiv);
if(ref[0] != "*") {
var collapseDiv = $('<div id="collapse-'+ itemId +'" class="accordion-collapse collapse" aria-labelledby="heading-' + itemId +'" data-parent="#accordion-'+id+'-'+idPostfix+'">').appendTo(cardDiv);
var cardBody = $('<div class="card-body">' +
'<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>'+
'<button class="btn btn-xs btn-danger btn-block btn-delete-branch">Delete Branch</button>'+
'</div>'+
'</div>').appendTo(collapseDiv);
}

if (ref[0] == "*") {
} 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);
}
} else {
var refname = ref.replaceAll('/', '-');
Expand Down Expand Up @@ -642,6 +646,14 @@ webui.SideBarView = function(mainView, noEventHandlers) {
webui.git("merge --no-commit --no-ff "+refName, "", self.upToDateHandler, callTestMergeHandler, callTestMergeHandler);
}

/// pushes the selected local branch to "origin"
self.pushBranch = function(e){
e.preventDefault();
var refName = $(this).parent().parent().parent().siblings(
".card-header").children("button").html();
webui.git(`push -u origin ${refName}`, "", self.upToDateHandler)
}

self.goToSettingsPage = function() {
window.location.replace(webui.settingsURL);
}
Expand All @@ -667,7 +679,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
$(self.buildAccordion(section, refs, id, undefined, "popup")).appendTo(popupContent);
// Hide popup when the user selects a branch operation
// Then execute the required operation with other even listeners
$(popupContent).find(".btn-delete-branch, .btn-checkout-local-branch, .btn-checkout-remote-branch, .btn-merge-remote-branch, .btn-merge-branch").click(function() {
$(popupContent).find(".btn-delete-branch, .btn-checkout-local-branch, .btn-checkout-remote-branch, .btn-merge-remote-branch, .btn-merge-branch, .btn-push-branch").click(function() {
$(popup).modal('hide');
});
}
Expand Down Expand Up @@ -748,6 +760,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {

if(!noEventHandlers){
$(document).on('click', '.btn-checkout-local-branch', self.checkoutBranch);
$(document).on('click', '.btn-push-branch', self.pushBranch);
$(document).on('click', '.btn-checkout-remote-branch', self.checkoutBranch);

$(document).on('click', '.btn-delete-branch', self.deleteLocalBranch);
Expand Down
32 changes: 25 additions & 7 deletions git-webui/src/share/git-webui/webui/js/git-webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,26 +322,35 @@ 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 + '">'
+ refname
+ '</button>').appendTo(cardHeader);

var collapseDiv = $('<div id="collapse-'+ itemId +'" class="accordion-collapse collapse" aria-labelledby="heading-' + itemId +'" data-parent="#accordion-'+id+'-'+idPostfix+'">').appendTo(cardDiv);
if(ref[0] != "*") {
var collapseDiv = $('<div id="collapse-'+ itemId +'" class="accordion-collapse collapse" aria-labelledby="heading-' + itemId +'" data-parent="#accordion-'+id+'-'+idPostfix+'">').appendTo(cardDiv);
var cardBody = $('<div class="card-body">' +
'<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>'+
(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);
}

if (ref[0] == "*") {
} else {
$(button).addClass("branch-current");
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 @@ -642,6 +651,14 @@ webui.SideBarView = function(mainView, noEventHandlers) {
webui.git("merge --no-commit --no-ff "+refName, "", self.upToDateHandler, callTestMergeHandler, callTestMergeHandler);
}

/// pushes the selected local branch to "origin"
self.pushBranch = function(e){
e.preventDefault();
var refName = $(this).parent().parent().parent().siblings(
".card-header").children("button").html();
webui.git(`push -u origin ${refName}`, "", self.upToDateHandler)
}

self.goToSettingsPage = function() {
window.location.replace(webui.settingsURL);
}
Expand All @@ -667,7 +684,7 @@ webui.SideBarView = function(mainView, noEventHandlers) {
$(self.buildAccordion(section, refs, id, undefined, "popup")).appendTo(popupContent);
// Hide popup when the user selects a branch operation
// Then execute the required operation with other even listeners
$(popupContent).find(".btn-delete-branch, .btn-checkout-local-branch, .btn-checkout-remote-branch, .btn-merge-remote-branch, .btn-merge-branch").click(function() {
$(popupContent).find(".btn-delete-branch, .btn-checkout-local-branch, .btn-checkout-remote-branch, .btn-merge-remote-branch, .btn-merge-branch, .btn-push-branch").click(function() {
$(popup).modal('hide');
});
}
Expand Down Expand Up @@ -742,12 +759,13 @@ 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");

if(!noEventHandlers){
$(document).on('click', '.btn-checkout-local-branch', self.checkoutBranch);
$(document).on('click', '.btn-push-branch', self.pushBranch);
$(document).on('click', '.btn-checkout-remote-branch', self.checkoutBranch);

$(document).on('click', '.btn-delete-branch', self.deleteLocalBranch);
Expand Down
2 changes: 1 addition & 1 deletion module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Document name="git-source-control.ZPM">
<Module>
<Name>git-source-control</Name>
<Version>2.2.1</Version>
<Version>2.3.0</Version>
<Description>Server-side source control extension for use of Git on InterSystems platforms</Description>
<Keywords>git source control studio vscode</Keywords>
<Packaging>module</Packaging>
Expand Down