Skip to content
Merged
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 @@ -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 `<VALUE OUT OF RANGE>` 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)

Expand Down
4 changes: 2 additions & 2 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
}
Expand Down
37 changes: 37 additions & 0 deletions test/UnitTest/SourceControl/Git/Utils/ImportItem.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 <VALUE OUT OF RANGE> when
/// a negative value is already stored.
Method TestNegativeTSHNotStored()
{
set internalName = "TestGitImport.NegTSH.CLS"

// 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)
}
}

}
Loading