Skip to content

Commit 0d00072

Browse files
authored
Merge branch 'main' into disallow-add-uncompiled
2 parents 9b8665c + d2d96a1 commit 0d00072

File tree

9 files changed

+292
-41
lines changed

9 files changed

+292
-41
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111
- Fixed JS errors in Studio on certain operations (#416)
1212
- Add menu option disabled for unsaved files (#420)
13+
- Fixed issue where selecting different item in stash list didn't update diff view (#265)
14+
- Tooltip in workspace now shows user who made uncommitted change if not current user (#411)
15+
- Files are added to source control upon creation properly (#404)
16+
- Files show in uncommitted queue when automatically added (#407)
17+
- WebUI workspace view now works properly for filenames with spaces (#423)
18+
- Fixed error popups in interop editors in Studio on 2024.1 (#417)
19+
- Reintroduced amend (#425)
1320

1421
## [2.4.0] - 2024-07-08
1522

cls/SourceControl/Git/Settings.cls

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ Method %Save() As %Status
8888

8989
set ..namespaceTemp = ##class(%Library.File).NormalizeDirectory(..namespaceTemp)
9090
set @storage@("settings","namespaceTemp") = ..namespaceTemp
91-
if ('##class(%File).DirectoryExists(@storage@("settings","namespaceTemp"))){
92-
do ##class(%Library.File).CreateDirectoryChain(@storage@("settings","namespaceTemp"))
93-
}
91+
set workMgr = $System.WorkMgr.%New("")
92+
$$$ThrowOnError(workMgr.Queue("##class(SourceControl.Git.Settings).CreateNamespaceTempFolder"))
93+
$$$ThrowOnError(workMgr.WaitForComplete())
94+
9495
set @storage@("settings","user",$username,"gitUserName") = ..gitUserName
9596

9697
set @storage@("settings","user",$username,"gitUserEmail") = ..gitUserEmail
@@ -117,6 +118,16 @@ Method %Save() As %Status
117118
quit $$$OK
118119
}
119120

121+
ClassMethod CreateNamespaceTempFolder() As %Status
122+
{
123+
set storage = ##class(SourceControl.Git.Utils).#Storage
124+
if ('##class(%File).DirectoryExists(@storage@("settings","namespaceTemp"))){
125+
do ##class(%Library.File).CreateDirectoryChain(@storage@("settings","namespaceTemp"))
126+
}
127+
128+
return $$$OK
129+
}
130+
120131
ClassMethod Configure() As %Boolean [ CodeMode = objectgenerator ]
121132
{
122133
do %code.WriteLine(" set inst = ..%New()")
@@ -188,10 +199,18 @@ Method OnAfterConfigure() As %Boolean
188199
}
189200
}
190201
if (value = 1) {
202+
set settings = ##class(SourceControl.Git.Settings).%New()
203+
set repoRootFolder = settings.namespaceTemp
204+
if ($extract(repoRootFolder, $length(repoRootFolder)) = "\") || ($extract(repoRootFolder, $length(repoRootFolder)) = "/") {
205+
set repoRootFolder = $extract(settings.namespaceTemp, 1, $length(settings.namespaceTemp) - 1)
206+
}
207+
set repoRootFolder = $translate(repoRootFolder, "\", "/")
208+
do ##class(SourceControl.Git.Utils).RunGitCommandWithInput("config",,,,"--global", "--add", "safe.directory", repoRootFolder)
191209
// using work queue manager ensures proper OS user context/file ownership
192210
set workMgr = $System.WorkMgr.%New("")
193211
$$$ThrowOnError(workMgr.Queue("##class(SourceControl.Git.Utils).Init"))
194212
$$$ThrowOnError(workMgr.WaitForComplete())
213+
195214
do ##class(SourceControl.Git.Utils).EmptyInitialCommit()
196215
} elseif (value = 2) {
197216
set response = ##class(%Library.Prompt).GetString("Git remote URL (note: if authentication is required, use SSH, not HTTPS):",.remote,,,,defaultPromptFlag)

cls/SourceControl/Git/Utils.cls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,10 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
672672
do ..RunGitCommand("add",.errStream,.outStream,filenames(i),"--intent-to-add")
673673
write !, "Added ", FileInternalName, " to source control."
674674
do ..PrintStreams(outStream, errStream)
675+
675676
}
676677
}
678+
do ##class(SourceControl.Git.Change).RefreshUncommitted(,,,1)
677679
quit ec
678680
}
679681

csp/gitprojectsettings.csp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,8 @@ $('[id^=noFoldersSwitch]').click(toggleNoFolders);
670670
</html>
671671
<script method='OnPreHTTP' language='cache' runat='server' returntype='%Boolean'>
672672
try {
673+
set %session.UseSessionCookie = 1 // Always set back to autodetect
674+
set %session.CookiePath = "" // Always clear
673675
if (%request.UserAgent [ " Code/") {
674676
// Workaround for VSCode webview
675677
set %session.SessionScope = 0 // none; allowed because...

csp/webuidriver.csp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
set %namespace = namespace
1212

1313
try {
14+
set %session.UseSessionCookie = 1 // Always set back to autodetect
15+
set %session.CookiePath = "" // Always clear
1416
if (%request.UserAgent [ " Code/") {
1517
// Workaround for VSCode webview
1618
set %session.SessionScope = 0 // none; allowed because...

git-webui/release/share/git-webui/webui/css/git-webui.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,9 @@ body {
925925
#confirmAction li {
926926
margin-left: 20%;
927927
}
928+
#confirmAction p {
929+
margin-top: 10px;
930+
}
928931
#commit-explorer-view #commit-explorer-navigator-view .panel .panel-body {
929932
flex: 1 1 0px;
930933
-webkit-flex: 1 1 0px;

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

Lines changed: 124 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,11 +1256,7 @@ webui.StashCommitView = function(stashView) {
12561256
var self = this;
12571257

12581258
self.update = function(entry) {
1259-
if (currentCommit == entry.commit) {
1260-
// We already display the right data. No need to update.
1261-
return;
12621259

1263-
}
12641260
currentCommit = entry.commit;
12651261
self.showDiff();
12661262
diffView.update("stash show -p stash@{"+entry.stashIndex+"}");
@@ -1294,7 +1290,7 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
12941290
if (cmd) {
12951291
self.gitCmd = cmd;
12961292
self.gitDiffOpts = diffOpts;
1297-
if (file != self.gitFile) {
1293+
if (file != self.gitFile && self.gitFile != '"undefined"') {
12981294
left.scrollTop = 0;
12991295
left.scrollLeft = 0;
13001296
right.scrollTop = 0;
@@ -1304,12 +1300,15 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
13041300
right.webuiPrevScrollTop = 0;
13051301
right.webuiPrevScrollLeft = 0;
13061302
}
1307-
webui.git("ls-files "+file, function(path){
1308-
self.gitFile = file;
1303+
webui.git("ls-files \""+file+"\"", function(path){
1304+
self.gitFile = "\"" + file + "\"";
13091305
self.noIndex = ""
13101306
if(path.length == 0 && file != undefined){
13111307
self.gitFile = " /dev/null " + file;
1312-
self.noIndex = " --no-index "
1308+
self.noIndex = " --no-index ";
1309+
if (self.gitDiffOpts == "--cached") {
1310+
self.gitDiffOpts = "";
1311+
}
13131312
}
13141313
if (self.gitCmd) {
13151314
var fullCmd = self.gitCmd;
@@ -1324,7 +1323,7 @@ webui.DiffView = function(sideBySide, hunkSelectionAllowed, parent, stashedCommi
13241323
if (self.gitDiffOpts) {
13251324
fullCmd += " " + self.gitDiffOpts.join(" ")
13261325
}
1327-
if (self.gitFile) {
1326+
if (self.gitFile && self.gitFile != '"undefined"') {
13281327
fullCmd += self.noIndex + " -- " + self.gitFile;
13291328
}
13301329
webui.git(fullCmd, self.refresh, self.refresh, self.refresh);
@@ -2060,11 +2059,6 @@ webui.CommitView = function(historyView) {
20602059
var self = this;
20612060

20622061
self.update = function(entry) {
2063-
if (currentCommit == entry.commit) {
2064-
// We already display the right data. No need to update.
2065-
return;
2066-
2067-
}
20682062
currentCommit = entry.commit;
20692063
self.showDiff();
20702064
buttonBox.select(0);
@@ -2172,9 +2166,10 @@ webui.NewChangedFilesView = function(workspaceView) {
21722166
webui.git("status -u --porcelain", function(data) {
21732167
$.get("api/uncommitted", function (uncommitted) {
21742168
var uncommittedItems = JSON.parse(uncommitted)["current user's changes"];
2169+
var otherUserUncommittedItems = JSON.parse(uncommitted)["other users' changes"];
21752170
self.filesCount = 0;
21762171

2177-
function addItemToFileList(fileList, indexStatus, workingTreeStatus, model, isOtherUserChange) {
2172+
function addItemToFileList(fileList, indexStatus, workingTreeStatus, model, isOtherUserChange, otherUser) {
21782173
var formCheck;
21792174
if (isOtherUserChange) {
21802175
formCheck = $('<div class="form-check changes-check other-user"></div>');
@@ -2201,7 +2196,7 @@ webui.NewChangedFilesView = function(workspaceView) {
22012196

22022197
var checkboxLabel;
22032198
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);
22052200
} else {
22062201
checkboxLabel = $('<label class="form-check-label file-item-label"></label>').text(model);
22072202
}
@@ -2224,6 +2219,7 @@ webui.NewChangedFilesView = function(workspaceView) {
22242219
} else {
22252220
model = line;
22262221
}
2222+
model = model.replace(/^"(.*)"$/g,'$1');
22272223

22282224
++self.filesCount;
22292225
var isForCurrentUser;
@@ -2236,7 +2232,8 @@ webui.NewChangedFilesView = function(workspaceView) {
22362232
if (isForCurrentUser) {
22372233
addItemToFileList(fileList, indexStatus, workingTreeStatus, model, false);
22382234
} else {
2239-
addItemToFileList(fileList, indexStatus, workingTreeStatus, model, true);
2235+
var otherUser = otherUserUncommittedItems[model.replace(/\//g, '\\')];
2236+
addItemToFileList(fileList, indexStatus, workingTreeStatus, model, true, otherUser);
22402237
}
22412238

22422239
});
@@ -2272,6 +2269,15 @@ webui.NewChangedFilesView = function(workspaceView) {
22722269

22732270
});
22742271

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+
22752281
$("#discardBtn").off("click");
22762282
$("#discardBtn").on("click", function() {
22772283
if (selectedItemsFromOtherUser.length > 0) {
@@ -2294,6 +2300,64 @@ webui.NewChangedFilesView = function(workspaceView) {
22942300
});
22952301
}
22962302

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+
22972361
self.confirmActionOnOtherUsersChanges = function(action) {
22982362
function removeWarningModal(popup) {
22992363
$(popup).children(".modal-fade").modal("hide");
@@ -2330,6 +2394,12 @@ webui.NewChangedFilesView = function(workspaceView) {
23302394
});
23312395

23322396
$('</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+
}
23332403

23342404
var popupFooter = $(".modal-footer", popup)[0];
23352405
webui.detachChildren(popupFooter);
@@ -2345,12 +2415,15 @@ webui.NewChangedFilesView = function(workspaceView) {
23452415
$('#confirmActionBtn').on('click', function() {
23462416
removeWarningModal(popup);
23472417
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());
23502420
} else if (action == "discard") {
23512421
self.discard();
23522422
} else if (action == "stash") {
23532423
self.stash();
2424+
} else if (action == "amend") {
2425+
var commitMessage = $('#commitMsg').val();
2426+
self.amend(commitMessage, $("#commitMsgDetail").val());
23542427
}
23552428
});
23562429

@@ -2401,6 +2474,7 @@ webui.NewChangedFilesView = function(workspaceView) {
24012474
if (self.getSelectedItemsCount() > 0) {
24022475
$('#stashBtn').prop("disabled", false);
24032476
$('#discardBtn').prop("disabled", false);
2477+
$('#amendBtn').prop("disabled", false);
24042478
if (!self.commitMsgEmpty()) {
24052479
$('#commitBtn').prop("disabled", false);
24062480
} else {
@@ -2410,6 +2484,12 @@ webui.NewChangedFilesView = function(workspaceView) {
24102484
$('#stashBtn').prop("disabled", true);
24112485
$('#discardBtn').prop("disabled", true);
24122486
$('#commitBtn').prop("disabled", true);
2487+
if (!self.commitMsgEmpty()) {
2488+
$('#amendBtn').prop("disabled", false);
2489+
} else {
2490+
$('#amendBtn').prop("disabled", true);
2491+
}
2492+
24132493
}
24142494

24152495
}
@@ -2469,6 +2549,30 @@ webui.NewChangedFilesView = function(workspaceView) {
24692549
});
24702550
}
24712551

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+
24722576
self.commit = function(message, details) {
24732577
var selectedFilesAsString = selectedItems.join(" ");
24742578

@@ -2498,6 +2602,7 @@ webui.NewChangedFilesView = function(workspaceView) {
24982602
'</div>' +
24992603
'<div class="button-group">' +
25002604
'<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>' +
25012606
'<button type="button" class="btn btn-secondary file-action-button" id="stashBtn" disabled> Stash </button>' +
25022607
'<button type="button" class="btn btn-danger file-action-button" id="discardBtn" disabled> Discard </button>' +
25032608
'</div>' +

git-webui/src/share/git-webui/webui/css/git-webui.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,14 @@ body {
920920
li {
921921
margin-left: 20%;
922922
}
923+
924+
p {
925+
margin-top: 10px;
926+
}
923927
}
924928

929+
930+
925931
#commit-explorer-view {
926932
#commit-explorer-navigator-view {
927933
.panel {

0 commit comments

Comments
 (0)