Skip to content

Commit 5925807

Browse files
committed
fix: recent bugs
GetPackageVersion supports zpm <= 0.7.1, IPM 0.9.0+ Fixed possible infinite loop in RefreshUncommitted
1 parent 860c260 commit 5925807

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

cls/SourceControl/Git/Change.cls

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,29 +126,39 @@ ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles,
126126
do ##class(Utils).GitStatus(.gitFiles)
127127

128128
// Remove entries in the uncommitted queue that don't correspond to changes as tracked by git
129-
set filename="", filename=$order(tFileList(filename),1,action)
130-
while (filename'="") {
131-
set examine=$select(action="add":1,action="edit":1,action="delete":1, IncludeRevert&&(action="revert"):1,1:0)
132-
if 'examine set filename=$order(tFileList(filename),1,action) continue
129+
set filename=""
130+
for {
131+
set filename=$order(tFileList(filename),1,action)
132+
quit:filename=""
133+
134+
set examine=$select(action="add":1,
135+
action="edit":1,
136+
action="delete":1,
137+
IncludeRevert&&(action="revert"):1,
138+
1:0)
139+
if 'examine {
140+
continue
141+
}
133142

134143
set packageRoot = ##class(SourceControl.Git.Utils).TempFolder()
135144
set InternalName = ##class(SourceControl.Git.Utils).NameToInternalName(filename,0,0)
136145

137146
// skip files belonging to other git enabled packages
138147
if ($EXTRACT(filename, 1, $LENGTH(packageRoot)) '= packageRoot) continue
139-
140148

141149
if (('##class(%File).Exists(filename)) || (InternalName = "") || ((InternalName '= "") && ('$data(gitFiles(InternalName), found)) &&
142150
(($data($$$TrackedItems(InternalName))) || ##class(SourceControl.Git.Utils).NormalizeExtension($data($$$TrackedItems(InternalName)))))) {
143151
set sc=..RemoveUncommitted(filename,Display,0,0)
144-
if $$$ISERR(sc) set filename="" continue
152+
if $$$ISERR(sc) continue
145153
}
146-
set filename=$order(tFileList(filename),1,action)
147154
}
148155

149156
// Add missing records to the uncommitted queue that correspond to changes as tracked by git
150-
set filename="", filename=$order(gitFiles(filename),1,details)
151-
while (filename'="") {
157+
set filename=""
158+
for {
159+
set filename=$order(gitFiles(filename),1,details)
160+
quit:filename=""
161+
152162
set InternalName = filename
153163
set ExternalName = ##class(%File).NormalizeFilename(##class(SourceControl.Git.Utils).TempFolder()_$list(details,2))
154164
set changeType = $list(details,1)
@@ -161,9 +171,8 @@ ClassMethod RefreshUncommitted(Display = 0, IncludeRevert = 0, Output gitFiles,
161171

162172
if ((##class(%File).Exists(ExternalName)) && ('$ISVALIDNUM(InternalName)) && ('..IsUncommitted(ExternalName)) && ($data($$$TrackedItems(InternalName)))) {
163173
set sc=..SetUncommitted(ExternalName, action, InternalName, $USERNAME, "", 1, "", "", 0)
164-
if $$$ISERR(sc) w sc set filename="" continue
174+
if $$$ISERR(sc) continue
165175
}
166-
set filename=$order(gitFiles(filename),1,details)
167176
}
168177
set ^IRIS.Temp.gitsourcecontrol("Refresh") = $zdatetime($ztimestamp,-2)
169178
merge ^IRIS.Temp.gitsourcecontrol("LastUncommitted") = gitFiles

cls/SourceControl/Git/Utils.cls

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,9 +2076,14 @@ ClassMethod CheckInitialization()
20762076

20772077
ClassMethod GetPackageVersion() As %String
20782078
{
2079-
do ##class(%ZPM.PackageManager).GetVersion("git-source-control",.out)
2080-
set scVersion = out("git-source-control")
2081-
quit $LIST(scVersion, 2)
2079+
set package = $$$NULLOREF
2080+
if $$$comClassDefined("%IPM.Storage.Module") {
2081+
set package = ##class(%IPM.Storage.Module).NameOpen("git-source-control")
2082+
} elseif $$$comClassDefined("%ZPM.PackageManager.Developer.Module") {
2083+
set package = ##class(%ZPM.PackageManager.Developer.Module).NameOpen("git-source-control")
2084+
}
2085+
quit $select($IsObject(package):package.VersionString,
2086+
1:"unknown")
20822087
}
20832088

20842089
ClassMethod GetSourceControlInclude() As %String

0 commit comments

Comments
 (0)