From d07eb1e7dc3420e601a4071e124453f265e79d29 Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:16:29 -0500 Subject: [PATCH 1/2] fix: OS error codes no longer lead to invalid timestamp cache breaking ImportItem --- CHANGELOG.md | 1 + cls/SourceControl/Git/Utils.cls | 4 +- .../SourceControl/Git/Utils/ImportItem.cls | 38 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 test/UnitTest/SourceControl/Git/Utils/ImportItem.cls diff --git a/CHANGELOG.md b/CHANGELOG.md index 4635be26..9c28e391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Take Ownership option in source control menu allows you to take ownership of an item edited by another user (#926) ## Fixed +- Fixed `` error in GetTempFileAndRoutineTS when an OS-level error code was stored as a routine timestamp (#832) - Fixed issue where Generated Files Read-only option didn't entirely work for files not in source control (#712) - Fixed issue where a deleted file not within Embedded Git's management was causing the pull handler to crash and not fully update the Iris instance (#928) diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index 5aac8323..7e015fcc 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -1357,7 +1357,7 @@ ClassMethod RoutineTSH(InternalName As %String) As %String #dim tsh = $case(type,"csp":"",:$get(@..#Storage@("TSH", ##class(%Studio.SourceControl.Interface).normalizeName(InternalName)))) // in case an OS level error is returned - set:(($$$isUNIX & (tsh = -2)) || ($$$isWINDOWS & (tsh = -3))) tsh = 0 + set:(tsh < 0) tsh = 0 if tsh = "" { #dim ts as %String = ##class(%RoutineMgr).TS(InternalName) @@ -1499,7 +1499,7 @@ ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose A } if $$$ISOK(sc) { if imported { - set sc = ..UpdateRoutineTSH(InternalName, fileTSH) + set:fileTSH'<0 sc = ..UpdateRoutineTSH(InternalName, fileTSH) if type = "prj" { set sc = $$$ADDSC(sc, ..FixProjectCspReferences(InternalName)) } diff --git a/test/UnitTest/SourceControl/Git/Utils/ImportItem.cls b/test/UnitTest/SourceControl/Git/Utils/ImportItem.cls new file mode 100644 index 00000000..bfb9471a --- /dev/null +++ b/test/UnitTest/SourceControl/Git/Utils/ImportItem.cls @@ -0,0 +1,38 @@ +Class UnitTest.SourceControl.Git.Utils.ImportItem Extends UnitTest.SourceControl.Git.AbstractTest +{ + +/// Tests that ImportItem does not store a negative error code in the TSH global +/// and that GetTempFileAndRoutineTS does not throw when +/// a negative value is already stored. +Method TestNegativeTSHNotStored() +{ + set internalName = "TestGitImport.NegTSH.CLS" + // set normalizedName = ##class(%Studio.SourceControl.Interface).normalizeName(internalName) + + // Write a valid class file to disk so ImportItem can load it + set filename = ##class(SourceControl.Git.Utils).FullExternalName(internalName) + do ..WriteFile(filename, "Class TestGitImport.NegTSH {}") + set sc = ##class(SourceControl.Git.Utils).ImportItem(internalName, 1, 0) + do $$$AssertStatusOK(sc, "ImportItem should succeed") + + // Verify the stored TSH value is not negative + set storedTSH = $get(^SYS("SourceControl","Git","TSH",internalName)) + if (storedTSH '= "") { + do $$$AssertTrue(storedTSH '< 0, "Stored TSH should not be negative, got: "_storedTSH) + } + + // Now simulate the bug: manually store a negative value in the TSH global + // as would happen on older versions when GetFileDateModified returned an error code + set ^SYS("SourceControl","Git","TSH",internalName) = -1 + do $$$AssertStatusOK(##class(SourceControl.Git.Utils).ImportItem(internalName, 0, 0)) + + // Clean up + kill ^SYS("SourceControl","Git","TSH",internalName) + do $system.OBJ.Delete(internalName, "-d") + set filename = ##class(SourceControl.Git.Utils).FullExternalName(internalName) + if ##class(%File).Exists(filename) { + do ##class(%File).Delete(filename) + } +} + +} From 75a5f0ef4329423fbfe174a51bb9eb338e8261b4 Mon Sep 17 00:00:00 2001 From: Pravin Barton <9560941+isc-pbarton@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:32:37 -0500 Subject: [PATCH 2/2] remove commented-out line from test --- test/UnitTest/SourceControl/Git/Utils/ImportItem.cls | 1 - 1 file changed, 1 deletion(-) diff --git a/test/UnitTest/SourceControl/Git/Utils/ImportItem.cls b/test/UnitTest/SourceControl/Git/Utils/ImportItem.cls index bfb9471a..a659a192 100644 --- a/test/UnitTest/SourceControl/Git/Utils/ImportItem.cls +++ b/test/UnitTest/SourceControl/Git/Utils/ImportItem.cls @@ -7,7 +7,6 @@ Class UnitTest.SourceControl.Git.Utils.ImportItem Extends UnitTest.SourceControl Method TestNegativeTSHNotStored() { set internalName = "TestGitImport.NegTSH.CLS" - // set normalizedName = ##class(%Studio.SourceControl.Interface).normalizeName(internalName) // Write a valid class file to disk so ImportItem can load it set filename = ##class(SourceControl.Git.Utils).FullExternalName(internalName)