Skip to content

Commit ebcb56e

Browse files
committed
fix: brought back amending commits
1 parent be083ed commit ebcb56e

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
- Files show in uncommitted queue when automatically added (#407)
1616
- WebUI workspace view now works properly for filenames with spaces (#423)
1717
- Fixed error popups in interop editors in Studio on 2024.1 (#417)
18+
- Reintroduced amend (#425)
1819

1920
## [2.4.0] - 2024-07-08
2021

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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>' +

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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,30 @@ webui.NewChangedFilesView = function(workspaceView) {
24662485
});
24672486
}
24682487

2488+
self.amend = function(message, details) {
2489+
var selectedFilesAsString = selectedItems.join(" ");
2490+
if (self.commitMsgEmpty()) {
2491+
webui.git("add " + selectedFilesAsString);
2492+
webui.git("commit --amend --no-edit -- " + selectedFilesAsString, function(output) {
2493+
webui.showSuccess(output);
2494+
workspaceView.update();
2495+
})
2496+
} else if (selectedItems.length != 0) {
2497+
webui.git("add " + selectedFilesAsString);
2498+
webui.git('commit --amend -m "' + message + '" -m "' + details + '" -- ' + selectedFilesAsString, function(output) {
2499+
webui.showSuccess(output);
2500+
workspaceView.update();
2501+
})
2502+
} else {
2503+
webui.git('commit --amend --allow-empty -m "' + message + '" -m "' + details + '"', function(output) {
2504+
webui.showSuccess(output);
2505+
workspaceView.update();
2506+
})
2507+
}
2508+
2509+
2510+
}
2511+
24692512
self.commit = function(message, details) {
24702513
var selectedFilesAsString = selectedItems.join(" ");
24712514

@@ -2495,6 +2538,7 @@ webui.NewChangedFilesView = function(workspaceView) {
24952538
'</div>' +
24962539
'<div class="button-group">' +
24972540
'<button type="button" class="btn btn-primary file-action-button" id="commitBtn" disabled> Commit </button>' +
2541+
'<button type="button" class="btn btn-outline-primary file-action-button" id="amendBtn" disabled> Amend </button>' +
24982542
'<button type="button" class="btn btn-secondary file-action-button" id="stashBtn" disabled> Stash </button>' +
24992543
'<button type="button" class="btn btn-danger file-action-button" id="discardBtn" disabled> Discard </button>' +
25002544
'</div>' +

0 commit comments

Comments
 (0)