Skip to content

Commit e278136

Browse files
authored
Propagate changes to src/ (#68)
* Initial commit to observe merge messages * Merge now works. Some testing and error handling remains. * Banner for successful merges. * Fixed output for successful merge * Commit to test automatic merge message * logging commit * Fix merge success condition * Minor update to merge call * comment to test merge * logging * commit to test merge * comment to test merge * comment to test merge * Fix success handler for test merge * Comment to test merge * Fix handler for successful merge * Comment to test merge * Better logging * Comment to test merge * Comment to test merge * Commenting for merge conflict * Error handling for cases when git returns the error message as a part of the request output instead of the message section. * Comment to test merge * comment to test merge conflict * comment for merge conflict * Comment to test merge * Cleanup merging remote branch * comment to test local merge * comment to test remote merge * Comment to test remote merge conflict * Comment to test remote merge conflict * Propagating changes to corresponding src file Co-authored-by: isc-svelury <[email protected]>
1 parent 0727707 commit e278136

File tree

1 file changed

+80
-6
lines changed

1 file changed

+80
-6
lines changed

git-webui/src/share/git-webui/webui/js/git-webui.js

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ webui.COLORS = ["#ffab1d", "#fd8c25", "#f36e4a", "#fc6148", "#d75ab6", "#b25ade"
3737
"#e47b07", "#e36920", "#d34e2a", "#ec3b24", "#ba3d99", "#9d45c9", "#4f5aec", "#615dcf", "#3286cf", "#00abca", "#279227", "#3a980c", "#6c7f00", "#ab8b0a", "#b56427", "#757575",
3838
"#ff911a", "#fc8120", "#e7623e", "#fa5236", "#ca4da9", "#a74fd3", "#5a68ff", "#6d69db", "#489bd9", "#00bcde", "#36a436", "#47a519", "#798d0a", "#c1a120", "#bf7730", "#8e8e8e"]
3939

40+
webui.showSuccess = function(message) {
41+
var messageBox = $("#message-box");
42+
messageBox.empty();
43+
$( '<div class="alert alert-success alert-dismissible" role="alert">' +
44+
'<button type="button" class="btn btn-default close" data-dismiss="alert">' +
45+
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">'+
46+
'<path fill-rule="evenodd" clip-rule="evenodd" d="M13.854 2.146a.5.5 0 0 1 0 .708l-11 11a.5.5 0 0 1-.708-.708l11-11a.5.5 0 0 1 .708 0Z" fill="#000"/>'+
47+
'<path fill-rule="evenodd" clip-rule="evenodd" d="M2.146 2.146a.5.5 0 0 0 0 .708l11 11a.5.5 0 0 0 .708-.708l-11-11a.5.5 0 0 0-.708 0Z" fill="#000"/>'+
48+
'</svg>'+
49+
'</button>' +
50+
message +
51+
'</div>').appendTo(messageBox);
52+
}
4053

4154
webui.showError = function(message) {
4255
$("#error-modal .alert").text(message);
@@ -122,10 +135,21 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
122135
}
123136
}
124137
} else {
125-
if(errorCallback) {
126-
errorCallback(message);
127-
} else{
128-
webui.showError(message);
138+
var displayMessage = ""
139+
if(output.length > 0){
140+
displayMessage += (output+"\n");
141+
}
142+
if(message.length > 0){
143+
displayMessage += message;
144+
}
145+
if(displayMessage.length > 0){
146+
if(errorCallback) {
147+
errorCallback(displayMessage);
148+
} else{
149+
webui.showError(displayMessage);
150+
}
151+
} else {
152+
webui.showError("The command <pre>"+cmd+"</pre> failed because of an unknown reason. Returned response: \n\n"+data)
129153
}
130154
}
131155
} else {
@@ -289,6 +313,7 @@ webui.SideBarView = function(mainView) {
289313
var cardBody = $('<div class="card-body">' +
290314
'<div class="d-grid gap-2 col-12 mx-auto">'+
291315
'<button class="btn btn-xs btn-primary btn-block btn-checkout-local-branch mt-1">Checkout Branch</button>'+
316+
'<button class="btn btn-xs btn-warning btn-block btn-merge-branch">Merge Branch</button>'+
292317
'<button class="btn btn-xs btn-danger btn-block btn-delete-branch">Delete Branch</button>'+
293318
'</div>'+
294319
'</div>').appendTo(collapseDiv);
@@ -315,6 +340,7 @@ webui.SideBarView = function(mainView) {
315340
var cardBody = $('<div class="card-body">' +
316341
'<div class="d-grid gap-2 col-12 mx-auto">'+
317342
'<button class="btn btn-xs btn-primary btn-block btn-checkout-remote-branch">Checkout Branch</button>'+
343+
'<button class="btn btn-xs btn-warning btn-block btn-merge-remote-branch">Merge Branch</button>'+
318344
'</div>'+
319345
'</div>').appendTo(collapseDiv);
320346
}
@@ -1849,7 +1875,6 @@ $(function()
18491875
$(document).on('click', '.btn-prune-remote-branches', function(e){
18501876
e.preventDefault();
18511877
$(".btn-prune-remote-branches").addClass("refresh-start");
1852-
18531878
webui.git("fetch --prune", function() {
18541879
updateSideBar();
18551880
});
@@ -1954,6 +1979,55 @@ $(function () {
19541979

19551980
});
19561981

1982+
$(document).on('click', '.btn-merge-branch', function(e){
1983+
e.preventDefault();
1984+
var refName = $(this).parent().parent().parent().siblings(
1985+
".card-header").children("button").html();
1986+
1987+
function testMergeHandler (message) {
1988+
function suppressErrorMessage(error) {
1989+
}
1990+
webui.git("merge --abort", "", "", suppressErrorMessage);
1991+
1992+
if(message.includes("Automatic merge went well") || message.includes("Auto-merging ")){
1993+
webui.git("merge "+refName, function (output){
1994+
webui.showSuccess(output);
1995+
});
1996+
}
1997+
else {
1998+
webui.showError(message);
1999+
}
2000+
}
2001+
webui.git("merge --no-commit --no-ff "+refName, "", "", testMergeHandler, testMergeHandler);
2002+
});
2003+
2004+
$(document).on('click', '.btn-merge-remote-branch', function(e){
2005+
e.preventDefault();
2006+
var refName = $(this).parent().parent().parent().siblings(
2007+
".card-header").children("button").html();
2008+
2009+
var remoteName = refName.split('/')[0];
2010+
var branchName = refName.split('/')[1];
2011+
2012+
webui.git("fetch "+remoteName+" "+branchName);
2013+
2014+
function testMergeHandler (message) {
2015+
function suppressErrorMessage(error) {
2016+
}
2017+
webui.git("merge --abort", "", "", suppressErrorMessage);
2018+
2019+
if(message.includes("Automatic merge went well") || message.includes("Auto-merging ")){
2020+
webui.git("merge "+refName, function (output){
2021+
webui.showSuccess(output);
2022+
});
2023+
}
2024+
else {
2025+
webui.showError(message);
2026+
}
2027+
}
2028+
webui.git("merge --no-commit --no-ff "+refName, "", "", testMergeHandler, testMergeHandler);
2029+
});
2030+
19572031
$(document).on('click', '.btn-checkout-remote-branch', function(e) {
19582032
e.preventDefault();
19592033
var refName = $(this).parent().parent().parent().siblings(
@@ -1962,7 +2036,7 @@ $(function () {
19622036
var remoteName = refName.split('/')[0];
19632037
var branchName = refName.split('/')[1];
19642038

1965-
webui.git("fetch "+remoteName);
2039+
webui.git("fetch "+remoteName+" "+branchName);
19662040
webui.git("checkout -b " +branchName + " " + refName, function() {
19672041
updateSideBar();
19682042
});

0 commit comments

Comments
 (0)