@@ -1256,11 +1256,7 @@ webui.StashCommitView = function(stashView) {
1256
1256
var self = this ;
1257
1257
1258
1258
self . update = function ( entry ) {
1259
- if ( currentCommit == entry . commit ) {
1260
- // We already display the right data. No need to update.
1261
- return ;
1262
1259
1263
- }
1264
1260
currentCommit = entry . commit ;
1265
1261
self . showDiff ( ) ;
1266
1262
diffView . update ( "stash show -p stash@{" + entry . stashIndex + "}" ) ;
@@ -1294,7 +1290,7 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
1294
1290
if ( cmd ) {
1295
1291
self . gitCmd = cmd ;
1296
1292
self . gitDiffOpts = diffOpts ;
1297
- if ( file != self . gitFile ) {
1293
+ if ( file != self . gitFile && self . gitFile != '"undefined"' ) {
1298
1294
left . scrollTop = 0 ;
1299
1295
left . scrollLeft = 0 ;
1300
1296
right . scrollTop = 0 ;
@@ -1304,12 +1300,15 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
1304
1300
right . webuiPrevScrollTop = 0 ;
1305
1301
right . webuiPrevScrollLeft = 0 ;
1306
1302
}
1307
- webui . git ( "ls-files " + file , function ( path ) {
1308
- self . gitFile = file ;
1303
+ webui . git ( "ls-files \"" + file + "\"" , function ( path ) {
1304
+ self . gitFile = "\"" + file + "\"" ;
1309
1305
self . noIndex = ""
1310
1306
if ( path . length == 0 && file != undefined ) {
1311
1307
self . gitFile = " /dev/null " + file ;
1312
- self . noIndex = " --no-index "
1308
+ self . noIndex = " --no-index " ;
1309
+ if ( self . gitDiffOpts == "--cached" ) {
1310
+ self . gitDiffOpts = "" ;
1311
+ }
1313
1312
}
1314
1313
if ( self . gitCmd ) {
1315
1314
var fullCmd = self . gitCmd ;
@@ -1324,7 +1323,7 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
1324
1323
if ( self . gitDiffOpts ) {
1325
1324
fullCmd += " " + self . gitDiffOpts . join ( " " )
1326
1325
}
1327
- if ( self . gitFile ) {
1326
+ if ( self . gitFile && self . gitFile != '"undefined"' ) {
1328
1327
fullCmd += self . noIndex + " -- " + self . gitFile ;
1329
1328
}
1330
1329
webui . git ( fullCmd , self . refresh , self . refresh , self . refresh ) ;
@@ -2060,11 +2059,6 @@ webui.CommitView = function(historyView) {
2060
2059
var self = this ;
2061
2060
2062
2061
self . update = function ( entry ) {
2063
- if ( currentCommit == entry . commit ) {
2064
- // We already display the right data. No need to update.
2065
- return ;
2066
-
2067
- }
2068
2062
currentCommit = entry . commit ;
2069
2063
self . showDiff ( ) ;
2070
2064
buttonBox . select ( 0 ) ;
@@ -2172,9 +2166,10 @@ webui.NewChangedFilesView = function(workspaceView) {
2172
2166
webui . git ( "status -u --porcelain" , function ( data ) {
2173
2167
$ . get ( "api/uncommitted" , function ( uncommitted ) {
2174
2168
var uncommittedItems = JSON . parse ( uncommitted ) [ "current user's changes" ] ;
2169
+ var otherUserUncommittedItems = JSON . parse ( uncommitted ) [ "other users' changes" ] ;
2175
2170
self . filesCount = 0 ;
2176
2171
2177
- function addItemToFileList ( fileList , indexStatus , workingTreeStatus , model , isOtherUserChange ) {
2172
+ function addItemToFileList ( fileList , indexStatus , workingTreeStatus , model , isOtherUserChange , otherUser ) {
2178
2173
var formCheck ;
2179
2174
if ( isOtherUserChange ) {
2180
2175
formCheck = $ ( '<div class="form-check changes-check other-user"></div>' ) ;
@@ -2201,7 +2196,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2201
2196
2202
2197
var checkboxLabel ;
2203
2198
if ( isOtherUserChange ) {
2204
- checkboxLabel = $ ( '<label class="form-check-label file-item-label other-user-label" data-toggle="tooltip" title="File changed by another user ">' + webui . peopleIcon + '</label>' ) . append ( model ) ;
2199
+ checkboxLabel = $ ( '<label class="form-check-label file-item-label other-user-label" data-toggle="tooltip" data-placement="top" title="File changed by: ' + otherUser + ' ">' + webui . peopleIcon + '</label>' ) . append ( model ) ;
2205
2200
} else {
2206
2201
checkboxLabel = $ ( '<label class="form-check-label file-item-label"></label>' ) . text ( model ) ;
2207
2202
}
@@ -2224,6 +2219,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2224
2219
} else {
2225
2220
model = line ;
2226
2221
}
2222
+ model = model . replace ( / ^ " ( .* ) " $ / g, '$1' ) ;
2227
2223
2228
2224
++ self . filesCount ;
2229
2225
var isForCurrentUser ;
@@ -2236,7 +2232,8 @@ webui.NewChangedFilesView = function(workspaceView) {
2236
2232
if ( isForCurrentUser ) {
2237
2233
addItemToFileList ( fileList , indexStatus , workingTreeStatus , model , false ) ;
2238
2234
} else {
2239
- addItemToFileList ( fileList , indexStatus , workingTreeStatus , model , true ) ;
2235
+ var otherUser = otherUserUncommittedItems [ model . replace ( / \/ / g, '\\' ) ] ;
2236
+ addItemToFileList ( fileList , indexStatus , workingTreeStatus , model , true , otherUser ) ;
2240
2237
}
2241
2238
2242
2239
} ) ;
@@ -2272,6 +2269,15 @@ webui.NewChangedFilesView = function(workspaceView) {
2272
2269
2273
2270
} ) ;
2274
2271
2272
+ $ ( "#amendBtn" ) . off ( "click" ) ;
2273
+ $ ( "#amendBtn" ) . on ( "click" , function ( ) {
2274
+ if ( selectedItemsFromOtherUser . length > 0 ) {
2275
+ self . confirmActionOnOtherUsersChanges ( "amend" ) ;
2276
+ } else {
2277
+ self . confirmAmend ( ) ;
2278
+ }
2279
+ } ) ;
2280
+
2275
2281
$ ( "#discardBtn" ) . off ( "click" ) ;
2276
2282
$ ( "#discardBtn" ) . on ( "click" , function ( ) {
2277
2283
if ( selectedItemsFromOtherUser . length > 0 ) {
@@ -2294,6 +2300,64 @@ webui.NewChangedFilesView = function(workspaceView) {
2294
2300
} ) ;
2295
2301
}
2296
2302
2303
+ self . confirmAmend = function ( ) {
2304
+ function removePopup ( popup ) {
2305
+ $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
2306
+ $ ( ".modal-backdrop" ) . remove ( ) ;
2307
+ $ ( "#confirmAmend" ) . remove ( ) ;
2308
+ }
2309
+
2310
+ var popup = $ (
2311
+ '<div class="modal fade" tabindex="-1" id="confirmAmend" role="dialog" data-backdrop="static">' +
2312
+ '<div class="modal-dialog modal-md" role="document">' +
2313
+ '<div class="modal-content">' +
2314
+ '<div class="modal-header">' +
2315
+ '<h5 class="modal-title">Confirm amend</h5>' +
2316
+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' + webui . largeXIcon + '</button>' +
2317
+ '</div>' +
2318
+ '<div class="modal-body"></div>' +
2319
+ '<div class="modal-footer"></div>' +
2320
+ '</div>' +
2321
+ '</div>' +
2322
+ '</div>'
2323
+ ) [ 0 ] ;
2324
+
2325
+ $ ( "body" ) . append ( popup ) ;
2326
+ var popupContent = $ ( ".modal-body" , popup ) [ 0 ] ;
2327
+ webui . detachChildren ( popupContent ) ;
2328
+
2329
+ $ (
2330
+ '<div class="row">' +
2331
+ '<div class="col-sm-1">' +
2332
+ webui . warningIcon +
2333
+ '</div>' +
2334
+ '<div class="col-sm-11">' +
2335
+ '<p>Careful, amending commits will rewrite the branch history. The amended commit will not be pushed to remote, even if the previous commit was.</p>' + // Removed extra closing </p> tag
2336
+ '</div>' +
2337
+ '</div>'
2338
+ ) . appendTo ( popupContent ) ;
2339
+
2340
+ var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
2341
+ webui . detachChildren ( popupFooter ) ;
2342
+
2343
+ $ (
2344
+ '<button class="btn btn-sm btn-warning action-btn" id="confirmAmendBtn">Confirm amend</button>' +
2345
+ '<button class="btn btn-sm btn-secondary action-btn" id="cancelAmendBtn">Cancel</button>'
2346
+ ) . appendTo ( popupFooter ) ;
2347
+
2348
+ $ ( popup ) . modal ( 'show' ) ;
2349
+
2350
+ $ ( '#confirmAmendBtn' ) . on ( 'click' , function ( ) {
2351
+ removePopup ( popup ) ;
2352
+ var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2353
+ self . amend ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
2354
+ } ) ;
2355
+
2356
+ $ ( '#confirmAmend' ) . find ( '#cancelAmendBtn, .close' ) . click ( function ( ) {
2357
+ removePopup ( popup ) ;
2358
+ } ) ;
2359
+ }
2360
+
2297
2361
self . confirmActionOnOtherUsersChanges = function ( action ) {
2298
2362
function removeWarningModal ( popup ) {
2299
2363
$ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
@@ -2330,6 +2394,12 @@ webui.NewChangedFilesView = function(workspaceView) {
2330
2394
} ) ;
2331
2395
2332
2396
$ ( '</ul>' ) . appendTo ( popupContent ) ;
2397
+
2398
+ if ( action == "amend" ) {
2399
+ $ ( '<div>' +
2400
+ '<p>Careful, amending commits will rewrite the branch history. The amended commit will not be pushed to remote, even if the previous commit was.</p>' +
2401
+ '</div>' ) . appendTo ( popupContent ) ;
2402
+ }
2333
2403
2334
2404
var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
2335
2405
webui . detachChildren ( popupFooter ) ;
@@ -2345,12 +2415,15 @@ webui.NewChangedFilesView = function(workspaceView) {
2345
2415
$ ( '#confirmActionBtn' ) . on ( 'click' , function ( ) {
2346
2416
removeWarningModal ( popup ) ;
2347
2417
if ( action == "commit" ) {
2348
- var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( ) ;
2349
- self . commit ( commitMessage ) ;
2418
+ var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2419
+ self . commit ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
2350
2420
} else if ( action == "discard" ) {
2351
2421
self . discard ( ) ;
2352
2422
} else if ( action == "stash" ) {
2353
2423
self . stash ( ) ;
2424
+ } else if ( action == "amend" ) {
2425
+ var commitMessage = $ ( '#commitMsg' ) . val ( ) ;
2426
+ self . amend ( commitMessage , $ ( "#commitMsgDetail" ) . val ( ) ) ;
2354
2427
}
2355
2428
} ) ;
2356
2429
@@ -2401,6 +2474,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2401
2474
if ( self . getSelectedItemsCount ( ) > 0 ) {
2402
2475
$ ( '#stashBtn' ) . prop ( "disabled" , false ) ;
2403
2476
$ ( '#discardBtn' ) . prop ( "disabled" , false ) ;
2477
+ $ ( '#amendBtn' ) . prop ( "disabled" , false ) ;
2404
2478
if ( ! self . commitMsgEmpty ( ) ) {
2405
2479
$ ( '#commitBtn' ) . prop ( "disabled" , false ) ;
2406
2480
} else {
@@ -2410,6 +2484,12 @@ webui.NewChangedFilesView = function(workspaceView) {
2410
2484
$ ( '#stashBtn' ) . prop ( "disabled" , true ) ;
2411
2485
$ ( '#discardBtn' ) . prop ( "disabled" , true ) ;
2412
2486
$ ( '#commitBtn' ) . prop ( "disabled" , true ) ;
2487
+ if ( ! self . commitMsgEmpty ( ) ) {
2488
+ $ ( '#amendBtn' ) . prop ( "disabled" , false ) ;
2489
+ } else {
2490
+ $ ( '#amendBtn' ) . prop ( "disabled" , true ) ;
2491
+ }
2492
+
2413
2493
}
2414
2494
2415
2495
}
@@ -2469,6 +2549,30 @@ webui.NewChangedFilesView = function(workspaceView) {
2469
2549
} ) ;
2470
2550
}
2471
2551
2552
+ self . amend = function ( message , details ) {
2553
+ var selectedFilesAsString = selectedItems . join ( " " ) ;
2554
+ if ( self . commitMsgEmpty ( ) ) {
2555
+ webui . git ( "add " + selectedFilesAsString ) ;
2556
+ webui . git ( "commit --amend --no-edit -- " + selectedFilesAsString , function ( output ) {
2557
+ webui . showSuccess ( output ) ;
2558
+ workspaceView . update ( ) ;
2559
+ } )
2560
+ } else if ( selectedItems . length != 0 ) {
2561
+ webui . git ( "add " + selectedFilesAsString ) ;
2562
+ webui . git ( 'commit --amend -m "' + message + '" -m "' + details + '" -- ' + selectedFilesAsString , function ( output ) {
2563
+ webui . showSuccess ( output ) ;
2564
+ workspaceView . update ( ) ;
2565
+ } )
2566
+ } else {
2567
+ webui . git ( 'commit --amend --allow-empty -m "' + message + '" -m "' + details + '"' , function ( output ) {
2568
+ webui . showSuccess ( output ) ;
2569
+ workspaceView . update ( ) ;
2570
+ } )
2571
+ }
2572
+
2573
+
2574
+ }
2575
+
2472
2576
self . commit = function ( message , details ) {
2473
2577
var selectedFilesAsString = selectedItems . join ( " " ) ;
2474
2578
@@ -2498,6 +2602,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2498
2602
'</div>' +
2499
2603
'<div class="button-group">' +
2500
2604
'<button type="button" class="btn btn-primary file-action-button" id="commitBtn" disabled> Commit </button>' +
2605
+ '<button type="button" class="btn btn-outline-primary file-action-button" id="amendBtn" disabled> Amend </button>' +
2501
2606
'<button type="button" class="btn btn-secondary file-action-button" id="stashBtn" disabled> Stash </button>' +
2502
2607
'<button type="button" class="btn btn-danger file-action-button" id="discardBtn" disabled> Discard </button>' +
2503
2608
'</div>' +
0 commit comments