Skip to content

Commit fb94fd1

Browse files
committed
Fix discarding external files (not in IRIS)
1 parent 97a5233 commit fb94fd1

File tree

6 files changed

+32
-14
lines changed

6 files changed

+32
-14
lines changed

cls/SourceControl/Git/DiscardState.cls

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Class SourceControl.Git.DiscardState Extends (%Persistent, %JSON.Adaptor)
33

44
Property FullExternalName As %String(MAXLEN = "") [ Required ];
55

6-
Property InternalName As %String [ Required ];
6+
Property Name As %String [ Required ];
77

88
Property Contents As %Stream.GlobalCharacter(LOCATION = "^DiscardStateContents");
99

@@ -13,25 +13,41 @@ Property Branch As %String [ Required ];
1313

1414
Property Timestamp As %TimeStamp [ Required ];
1515

16+
Property ExternalFile As %Boolean [ Required ];
17+
1618
Method RestoreToFileTree()
1719
{
1820
set fileStream = ##class(%Stream.FileCharacter).%OpenId(..FullExternalName,,.sc)
1921
$$$ThrowOnError(sc)
2022
do fileStream.CopyFrom(..Contents)
2123
$$$ThrowOnError(fileStream.%Save())
22-
do ##class(SourceControl.Git.Utils).ImportItem(..InternalName, 1, 1)
23-
do ##class(SourceControl.Git.Utils).AddToServerSideSourceControl(..InternalName)
24+
if '..ExternalFile {
25+
do ##class(SourceControl.Git.Utils).ImportItem(..Name, 1, 1)
26+
do ##class(SourceControl.Git.Utils).AddToServerSideSourceControl(..Name)
27+
}
28+
2429
$$$ThrowOnError(..%DeleteId(..%Id()))
2530
}
2631

27-
ClassMethod SaveDiscardState(InternalName As %String) As %Status
32+
ClassMethod SaveDiscardState(InternalName As %String, name As %String) As %Status
2833
{
2934
set discardState = ..%New()
30-
set discardState.FullExternalName = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
31-
set discardState.InternalName = InternalName
35+
36+
// If not an IRIS file
37+
if (InternalName = "") {
38+
set externalName = ##class(%File).Construct($Get(^SYS("SourceControl","Git","settings","namespaceTemp")),name)
39+
set discardState.FullExternalName = externalName
40+
set discardState.Name = name
41+
set discardState.ExternalFile = 1
42+
} else {
43+
set discardState.FullExternalName = ##class(SourceControl.Git.Utils).FullExternalName(InternalName)
44+
set discardState.Name = InternalName
45+
set discardState.ExternalFile = 0
46+
}
3247

3348
set fileStream = ##class(%Stream.FileCharacter).%New()
3449
set fileStream.Filename = discardState.FullExternalName
50+
3551
do fileStream.%Open()
3652
do discardState.Contents.CopyFrom(fileStream)
3753
do fileStream.%Close()
@@ -85,6 +101,12 @@ Storage Default
85101
<Value name="7">
86102
<Value>Timestamp</Value>
87103
</Value>
104+
<Value name="8">
105+
<Value>Name</Value>
106+
</Value>
107+
<Value name="9">
108+
<Value>ExternalFile</Value>
109+
</Value>
88110
</Data>
89111
<DataLocation>^SourceControl22B9.DiscardStateD</DataLocation>
90112
<DefaultData>DiscardStateDefaultData</DefaultData>
@@ -95,4 +117,3 @@ Storage Default
95117
}
96118

97119
}
98-

cls/SourceControl/Git/Utils.cls

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,7 +1917,6 @@ ClassMethod SyncIrisWithRepoThroughDiff(ByRef files, ByRef filterToFiles, invert
19171917
set addedFiles = $extract(addedFiles, 2, *)
19181918

19191919
if (deletedFiles '= ""){
1920-
set ^mtempdeletedFiles($i(^mtempdeletedFiles)) = deletedFiles
19211920
set sc = ##class(SourceControl.Git.Utils).RemoveFromServerSideSourceControl(deletedFiles)
19221921
}
19231922
if (addedFiles '= ""){
@@ -2573,4 +2572,3 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
25732572
}
25742573

25752574
}
2576-

cls/SourceControl/Git/WebUIDriver.cls

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ ClassMethod HandleRequest(pagePath As %String, InternalName As %String = "", Out
175175
while iter.%GetNext(,.value) {
176176
if isFile {
177177
set internalName = ##class(SourceControl.Git.Utils).NameToInternalName(value)
178-
do ##class(SourceControl.Git.DiscardState).SaveDiscardState(internalName)
178+
do ##class(SourceControl.Git.DiscardState).SaveDiscardState(internalName, value)
179179
}
180180
if value = "--"{
181181
set isFile = 1
@@ -306,4 +306,3 @@ ClassMethod GetPackageVersion() As %Library.DynamicObject
306306
}
307307

308308
}
309-
Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ webui.DiscardedView = function(mainView) {
18701870
var discardedListEntry = $(
18711871
'<a class="log-entry list-group-item">' +
18721872
'<header>' +
1873-
'<h6 class="file-internalname">' + discardedState.InternalName + '</h6>' +
1873+
'<h6 class="file-internalname">' + discardedState.Name + '</h6>' +
18741874
'<span class="discard-date">' + self.formatTimestamp(discardedState.Timestamp) + '</span>' +
18751875
'</header>' +
18761876
'<span> Branch: ' + discardedState.Branch + ' </span> <br>' +

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ webui.DiscardedView = function(mainView) {
18701870
var discardedListEntry = $(
18711871
'<a class="log-entry list-group-item">' +
18721872
'<header>' +
1873-
'<h6 class="file-internalname">' + discardedState.InternalName + '</h6>' +
1873+
'<h6 class="file-internalname">' + discardedState.Name + '</h6>' +
18741874
'<span class="discard-date">' + self.formatTimestamp(discardedState.Timestamp) + '</span>' +
18751875
'</header>' +
18761876
'<span> Branch: ' + discardedState.Branch + ' </span> <br>' +

0 commit comments

Comments
 (0)