@@ -37,6 +37,19 @@ webui.COLORS = ["#ffab1d", "#fd8c25", "#f36e4a", "#fc6148", "#d75ab6", "#b25ade"
37
37
"#e47b07" , "#e36920" , "#d34e2a" , "#ec3b24" , "#ba3d99" , "#9d45c9" , "#4f5aec" , "#615dcf" , "#3286cf" , "#00abca" , "#279227" , "#3a980c" , "#6c7f00" , "#ab8b0a" , "#b56427" , "#757575" ,
38
38
"#ff911a" , "#fc8120" , "#e7623e" , "#fa5236" , "#ca4da9" , "#a74fd3" , "#5a68ff" , "#6d69db" , "#489bd9" , "#00bcde" , "#36a436" , "#47a519" , "#798d0a" , "#c1a120" , "#bf7730" , "#8e8e8e" ]
39
39
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
+ }
40
53
41
54
webui . showError = function ( message ) {
42
55
$ ( "#error-modal .alert" ) . text ( message ) ;
@@ -122,10 +135,21 @@ webui.git = function(cmd, arg1, arg2, arg3, arg4) {
122
135
}
123
136
}
124
137
} 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 )
129
153
}
130
154
}
131
155
} else {
@@ -289,6 +313,7 @@ webui.SideBarView = function(mainView) {
289
313
var cardBody = $ ( '<div class="card-body">' +
290
314
'<div class="d-grid gap-2 col-12 mx-auto">' +
291
315
'<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>' +
292
317
'<button class="btn btn-xs btn-danger btn-block btn-delete-branch">Delete Branch</button>' +
293
318
'</div>' +
294
319
'</div>' ) . appendTo ( collapseDiv ) ;
@@ -315,6 +340,7 @@ webui.SideBarView = function(mainView) {
315
340
var cardBody = $ ( '<div class="card-body">' +
316
341
'<div class="d-grid gap-2 col-12 mx-auto">' +
317
342
'<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>' +
318
344
'</div>' +
319
345
'</div>' ) . appendTo ( collapseDiv ) ;
320
346
}
@@ -1849,7 +1875,6 @@ $(function()
1849
1875
$ ( document ) . on ( 'click' , '.btn-prune-remote-branches' , function ( e ) {
1850
1876
e . preventDefault ( ) ;
1851
1877
$ ( ".btn-prune-remote-branches" ) . addClass ( "refresh-start" ) ;
1852
-
1853
1878
webui . git ( "fetch --prune" , function ( ) {
1854
1879
updateSideBar ( ) ;
1855
1880
} ) ;
@@ -1954,6 +1979,55 @@ $(function () {
1954
1979
1955
1980
} ) ;
1956
1981
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
+
1957
2031
$ ( document ) . on ( 'click' , '.btn-checkout-remote-branch' , function ( e ) {
1958
2032
e . preventDefault ( ) ;
1959
2033
var refName = $ ( this ) . parent ( ) . parent ( ) . parent ( ) . siblings (
@@ -1962,7 +2036,7 @@ $(function () {
1962
2036
var remoteName = refName . split ( '/' ) [ 0 ] ;
1963
2037
var branchName = refName . split ( '/' ) [ 1 ] ;
1964
2038
1965
- webui . git ( "fetch " + remoteName ) ;
2039
+ webui . git ( "fetch " + remoteName + " " + branchName ) ;
1966
2040
webui . git ( "checkout -b " + branchName + " " + refName , function ( ) {
1967
2041
updateSideBar ( ) ;
1968
2042
} ) ;
0 commit comments