Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed Import All deploying changes to files in a CSP application (#828)
- Fixed an error when discarding a large number of changes through the Web UI (#845)

## [2.13.0] - 2025-08-20

Expand Down
8 changes: 7 additions & 1 deletion cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -1866,8 +1866,14 @@ ClassMethod RunGitCommand(command As %String, Output errStream, Output outStream
quit ..RunGitCommandWithInput(command,,.errStream,.outStream,args...)
}

ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", Output errStream, Output outStream, args...) As %Integer
ClassMethod RunGitCommandWithInput(command As %String, inFile As %String = "", Output errStream, Output outStream, pArgs...) As %Integer
{
// pArgs may be a variable number of arguments or a single multidimensional array
if ($get(pArgs) = 1) && ($data(pArgs(1)) >= 10) {
merge args = pArgs(1)
} else {
merge args = pArgs
}
// Special case: git --version is used internally even when the settings incorporated here may be invalid/unspecified.
set tempFolder = ..TempFolder()
if (command '= "--version") {
Expand Down
4 changes: 2 additions & 2 deletions cls/SourceControl/Git/WebUIDriver.cls
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out

set inFile = ""
if (gitCmd = "stash") {
set st = ##class(SourceControl.Git.Utils).RunGitAndHandleMerge("-c",inFile, .resolver, .succeeded, .returnCode, .errStream, .outStream, argsArr...)
set st = ##class(SourceControl.Git.Utils).RunGitAndHandleMerge("-c",inFile, .resolver, .succeeded, .returnCode, .errStream, .outStream, .argsArr)

set %data = ##class(%Stream.TmpCharacter).%New()
set changeTerminators = (%data.LineTerminator '= $char(13,10))
Expand All @@ -287,7 +287,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
do %data.Write("Git-Return-Code: " _ returnCode) // No ending newline expected
do %data.Rewind()
} else {
set returnCode = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("-c", inFile, .errStream, .outStream, argsArr...)
set returnCode = ##class(SourceControl.Git.Utils).RunGitCommandWithInput("-c", inFile, .errStream, .outStream, .argsArr)
do ..ConvertGitOutput(.outStream,.errStream,returnCode,.%data)
}
set handled = 1
Expand Down
6 changes: 5 additions & 1 deletion test/UnitTest/SourceControl/Git/AbstractTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ Property InitialExtension As %String [ InitialExpression = {##class(%Studio.Sour

Property SourceControlGlobal [ MultiDimensional ];

Property TempGitRepoPath As %String;

Method %OnNew(initvalue) As %Status
{
Merge ..SourceControlGlobal = ^SYS("SourceControl")
Kill ^SYS("SourceControl")
Set settings = ##class(SourceControl.Git.Settings).%New()
Set settings.namespaceTemp = ##class(%Library.File).TempFilename()_"dir"
set ..TempGitRepoPath = ##class(%Library.File).TempFilename()_"dir"
Set settings.namespaceTemp = ..TempGitRepoPath
Set settings.Mappings("CLS","*")="cls/"
Do settings.%Save()
Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet("SourceControl.Git.Extension")
Expand All @@ -19,6 +22,7 @@ Method %OnNew(initvalue) As %Status

Method %OnClose() As %Status [ Private, ServerOnly = 1 ]
{
Do ##class(%File).RemoveDirectoryTree(..TempGitRepoPath)
Do ##class(%Studio.SourceControl.Interface).SourceControlClassSet(..InitialExtension)
Kill ^SYS("SourceControl")
Merge ^SYS("SourceControl") = ..SourceControlGlobal
Expand Down
30 changes: 30 additions & 0 deletions test/UnitTest/SourceControl/Git/WebUIDriver.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Class UnitTest.SourceControl.Git.WebUIDriver Extends UnitTest.SourceControl.Git.AbstractTest
{

Method TestRevertManyFiles()
{
set oldSession = $get(%session), oldRequest = $get(%request), oldResponse = $get(%response)
set %session = ##class(%CSP.Session).%New(999,0)
set %request = ##class(%CSP.Request).%New()
set %response = ##class(%CSP.Response).%New()
do ##class(SourceControl.Git.Utils).Init()
set requestBody = {"command": ["clean","-f","--"]}
for i=1:1:500 {
set fileRelPath = "txt/test"_i_".txt"
do ..WriteFile(..TempGitRepoPath_"/"_fileRelPath, "automated testing")
do requestBody.command.%Push(fileRelPath)
}
do $$$AssertTrue(##class(%File).Exists(..TempGitRepoPath_"/txt/test1.txt"))
do $$$AssertTrue(##class(%File).Exists(..TempGitRepoPath_"/txt/test500.txt"))
set %request.Content = ##class(%CSP.CharacterStream).%New()
set %request.Method = "POST"
do requestBody.%ToJSON(%request.Content)
do ##class(SourceControl.Git.WebUIDriver).HandleRequest("/git-command",,.handled,.data)
do $$$LogMessage(data.Read())
do $$$AssertTrue(handled)
do $$$AssertNotTrue(##class(%File).Exists(..TempGitRepoPath_"/txt/test1.txt"))
do $$$AssertNotTrue(##class(%File).Exists(..TempGitRepoPath_"/txt/test500.txt"))
set %session = $get(oldSession), %request = $get(oldRequest), %response = $get(oldResponse)
}

}
Loading