Skip to content

Commit

Permalink
Fix discarded items still in uncommitted queue
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-etamarch committed Sep 26, 2024
1 parent 31862a8 commit 89dd12b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cls/SourceControl/Git/WebUIDriver.cls
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,18 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out

set gitCmd = command.%Get(0)

set discardedFiles = []
if gitCmd = "restore" {
set iter = command.%GetIterator()
set isFile = 0
while iter.%GetNext(,.value) {
if isFile {
set internalName = ##class(SourceControl.Git.Utils).NameToInternalName(value)
do ##class(SourceControl.Git.DiscardState).SaveDiscardState(internalName, value)
if (internalName) {
set externalName = ##class(Source.Git.Utils).FullExternalName(internalName)
if (internalName'="") {
set externalName = ##class(SourceControl.Git.Utils).FullExternalName(internalName)
$$$ThrowOnError(##class(SourceControl.Git.Change).RemoveUncommitted(externalName,0,1))
do discardedFiles.%Push(externalName)
}

}
Expand Down Expand Up @@ -284,6 +286,14 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
do %data.Write("Git-Return-Code: " _ returnCode) // No ending newline expected
do %data.Rewind()
set handled = 1

// Make sure discarded items are not in the uncommitted queue
set item = discardedFiles.%Pop()
while (item '= "") {
do ##class(SourceControl.Git.Change).RemoveUncommitted(externalName,0,1)
set item = discardedFiles.%Pop()
}

} elseif (pathStart = "restore-discarded") {
merge data = %request.Data
set fileId = data("file",1)
Expand Down

0 comments on commit 89dd12b

Please sign in to comment.