From bd2af1de8e6a6cf8f4024f2725e5ecde7b6a4efe Mon Sep 17 00:00:00 2001 From: Sven Van Caekenberghe Date: Thu, 31 Oct 2024 17:40:01 +0100 Subject: [PATCH] Added PureGitFile>>#validateIncrementalHistoryContentsReconstruction sanity check --- src/Iceberg-Git-CLI/PureGitFile.class.st | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Iceberg-Git-CLI/PureGitFile.class.st b/src/Iceberg-Git-CLI/PureGitFile.class.st index 5586d0b..a16b843 100644 --- a/src/Iceberg-Git-CLI/PureGitFile.class.st +++ b/src/Iceberg-Git-CLI/PureGitFile.class.st @@ -34,7 +34,7 @@ PureGitFile >> children [ ^ #() ] -{ #category : #'as yet unclassified' } +{ #category : #accessing } PureGitFile >> contents [ ^ self fileReference contents ] @@ -189,3 +189,18 @@ PureGitFile >> unstage [ self repository operations unstage: self path. self resetStatus ] + +{ #category : #private } +PureGitFile >> validateIncrementalHistoryContentsReconstruction [ + | commitHistory previousContents | + commitHistory := self logPatchReverse toArray wait. + previousContents := String empty. + commitHistory do: [ :extendedFileCommit | + | newContents expectedContents | + newContents := extendedFileCommit changesToParent applyTo: previousContents. + expectedContents := String streamContents: [ :out | + extendedFileCommit commit contents + linesDo: [ :line | out nextPutAll: line; cr ] ]. + self assert: newContents equals: expectedContents. + previousContents := newContents ] +]