@@ -2269,6 +2269,16 @@ webui.NewChangedFilesView = function(workspaceView) {
22692269
22702270 } ) ;
22712271
2272+ $ ( "amendBtn" ) . off ( "click" ) ;
2273+ $ ( "#amendBtn" ) . on ( "click" , function ( ) {
2274+ if ( selectedItemsFromOtherUser . length > 0 ) {
2275+ self . confirmActionOnOtherUsersChanges ( "amend" ) ;
2276+ } else {
2277+ var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2278+ self . amend ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
2279+ }
2280+ } ) ;
2281+
22722282 $ ( "#discardBtn" ) . off ( "click" ) ;
22732283 $ ( "#discardBtn" ) . on ( "click" , function ( ) {
22742284 if ( selectedItemsFromOtherUser . length > 0 ) {
@@ -2348,6 +2358,8 @@ webui.NewChangedFilesView = function(workspaceView) {
23482358 self . discard ( ) ;
23492359 } else if ( action == "stash" ) {
23502360 self . stash ( ) ;
2361+ } else if ( axtion == "amend" ) {
2362+ self . amend ( ) ;
23512363 }
23522364 } ) ;
23532365
@@ -2398,6 +2410,7 @@ webui.NewChangedFilesView = function(workspaceView) {
23982410 if ( self . getSelectedItemsCount ( ) > 0 ) {
23992411 $ ( '#stashBtn' ) . prop ( "disabled" , false ) ;
24002412 $ ( '#discardBtn' ) . prop ( "disabled" , false ) ;
2413+ $ ( '#amendBtn' ) . prop ( "disabled" , false ) ;
24012414 if ( ! self . commitMsgEmpty ( ) ) {
24022415 $ ( '#commitBtn' ) . prop ( "disabled" , false ) ;
24032416 } else {
@@ -2407,6 +2420,12 @@ webui.NewChangedFilesView = function(workspaceView) {
24072420 $ ( '#stashBtn' ) . prop ( "disabled" , true ) ;
24082421 $ ( '#discardBtn' ) . prop ( "disabled" , true ) ;
24092422 $ ( '#commitBtn' ) . prop ( "disabled" , true ) ;
2423+ if ( ! self . commitMsgEmpty ( ) ) {
2424+ $ ( '#amendBtn' ) . prop ( "disabled" , false ) ;
2425+ } else {
2426+ $ ( '#amendBtn' ) . prop ( "disabled" , true ) ;
2427+ }
2428+
24102429 }
24112430
24122431 }
@@ -2466,6 +2485,33 @@ webui.NewChangedFilesView = function(workspaceView) {
24662485 } ) ;
24672486 }
24682487
2488+ self . amend = function ( message , details ) {
2489+ var selectedFilesAsString = selectedItems . join ( " " ) ;
2490+ console . log ( selectedItems . length ) ;
2491+ if ( self . commitMsgEmpty ( ) ) {
2492+ webui . git ( "add " + selectedFilesAsString ) ;
2493+ webui . git ( "commit --amend --no-edit -- " + selectedFilesAsString , function ( output ) {
2494+ webui . showSuccess ( output ) ;
2495+ workspaceView . update ( ) ;
2496+ } )
2497+ } else if ( selectedItems . length != 0 ) {
2498+ console . log ( "bad" ) ;
2499+ webui . git ( "add " + selectedFilesAsString ) ;
2500+ webui . git ( 'commit --amend -m "' + message + '" -m "' + details + '" -- ' + selectedFilesAsString , function ( output ) {
2501+ webui . showSuccess ( output ) ;
2502+ workspaceView . update ( ) ;
2503+ } )
2504+ } else {
2505+ console . log ( "here" ) ;
2506+ webui . git ( 'commit --amend --allow-empty -m "' + message + '" -m "' + details + '"' , function ( output ) {
2507+ webui . showSuccess ( output ) ;
2508+ workspaceView . update ( ) ;
2509+ } )
2510+ }
2511+
2512+
2513+ }
2514+
24692515 self . commit = function ( message , details ) {
24702516 var selectedFilesAsString = selectedItems . join ( " " ) ;
24712517
@@ -2495,6 +2541,7 @@ webui.NewChangedFilesView = function(workspaceView) {
24952541 '</div>' +
24962542 '<div class="button-group">' +
24972543 '<button type="button" class="btn btn-primary file-action-button" id="commitBtn" disabled> Commit </button>' +
2544+ '<button type="button" class="btn btn-outline-primary file-action-button" id="amendBtn" disabled> Amend </button>' +
24982545 '<button type="button" class="btn btn-secondary file-action-button" id="stashBtn" disabled> Stash </button>' +
24992546 '<button type="button" class="btn btn-danger file-action-button" id="discardBtn" disabled> Discard </button>' +
25002547 '</div>' +
0 commit comments