diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c55d2c..b6c01600 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Production Decomposition mode allows controlling interoperability productions as individual files for each host (#469) - Added saving settings as system default for new namespaces (#535) - Added filtering through branch names in UI (#615) +- FullLoad pull event handler allows deploying changes with a full import of the repository (#619) ## [2.7.1] - 2024-11-13 diff --git a/cls/SourceControl/Git/Modification.cls b/cls/SourceControl/Git/Modification.cls index 3c1798bb..f29c8537 100644 --- a/cls/SourceControl/Git/Modification.cls +++ b/cls/SourceControl/Git/Modification.cls @@ -2,7 +2,7 @@ Class SourceControl.Git.Modification Extends %RegisteredObject { -/// path of the file +/// path of the file relative to the Git repository Property externalName As %String; /// Name in IRIS SourceControl.Git.Modification @@ -11,4 +11,4 @@ Property internalName As %String; /// Type of change (A|C|D|M|R|T|U|X|B). See git diff documentation. Property changeType As %String; -} \ No newline at end of file +} diff --git a/cls/SourceControl/Git/PullEventHandler.cls b/cls/SourceControl/Git/PullEventHandler.cls index 8f1bded1..ceb86f3b 100644 --- a/cls/SourceControl/Git/PullEventHandler.cls +++ b/cls/SourceControl/Git/PullEventHandler.cls @@ -21,9 +21,14 @@ Method OnPull() As %Status [ Abstract ] } /// files is an integer-subscripted array of SourceControl.Git.Modification objects. -ClassMethod ForModifications(ByRef files) As %Status +/// pullEventClass: if defined, override the configured pull event class +ClassMethod ForModifications(ByRef files, pullEventClass As %String) As %Status { - set event = $classmethod(##class(SourceControl.Git.Utils).PullEventClass(),"%New") + set event = $classmethod( + $select( + $data(pullEventClass)#2: pullEventClass, + 1: ##class(SourceControl.Git.Utils).PullEventClass()) + ,"%New") set event.LocalRoot = ##class(SourceControl.Git.Utils).TempFolder() merge event.ModifiedFiles = files quit event.OnPull() @@ -44,4 +49,4 @@ ClassMethod ForInternalNames(InternalName As %String) As %Status quit ..ForModifications(.files) } -} \ No newline at end of file +} diff --git a/cls/SourceControl/Git/PullEventHandler/FullLoad.cls b/cls/SourceControl/Git/PullEventHandler/FullLoad.cls new file mode 100644 index 00000000..b8f706f1 --- /dev/null +++ b/cls/SourceControl/Git/PullEventHandler/FullLoad.cls @@ -0,0 +1,14 @@ +Class SourceControl.Git.PullEventHandler.FullLoad Extends SourceControl.Git.PullEventHandler +{ + +Parameter NAME = "Full Load"; + +Parameter DESCRIPTION = "Performs an full load and compile of all items in the repository."; + +Method OnPull() As %Status +{ + return ##class(SourceControl.Git.Utils).ImportAll(1, + ##class(SourceControl.Git.PullEventHandler.IncrementalLoad).%ClassName(1)) +} + +} diff --git a/cls/SourceControl/Git/Utils.cls b/cls/SourceControl/Git/Utils.cls index bb569f35..0208fb1f 100644 --- a/cls/SourceControl/Git/Utils.cls +++ b/cls/SourceControl/Git/Utils.cls @@ -1536,7 +1536,7 @@ ClassMethod ListItemsInFiles(ByRef itemList, ByRef err) As %Status quit $$$OK } -ClassMethod ImportRoutines(force As %Boolean = 0) As %Status +ClassMethod ImportRoutines(force As %Boolean = 0, pullEventClass As %String) As %Status { set refContext = ##class(SourceControl.Git.PackageManagerContext).%Get() set refPackage = refContext.Package @@ -1573,7 +1573,7 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status set modification = ##class(SourceControl.Git.Modification).%New() set modification.changeType = "M" set modification.internalName = internalName - set modification.externalName = ..FullExternalName(internalName) + set modification.externalName = ..ExternalName(internalName) set files($increment(files)) = modification } } @@ -1588,18 +1588,19 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(item) continue:context.Package'=refPackage + set externalName = ..ExternalName(item) set fullExternalName = ..FullExternalName(item) if '##class(%File).Exists(fullExternalName) { write !,fullExternalName," does not exist - deleting ",item set modification = ##class(SourceControl.Git.Modification).%New() set modification.changeType = "D" set modification.internalName = item - set modification.externalName = fullExternalName + set modification.externalName = externalName set files($increment(files)) = modification } } - set sc = ##class(SourceControl.Git.PullEventHandler).ForModifications(.files) + set sc = ##class(SourceControl.Git.PullEventHandler).ForModifications(.files, .pullEventClass) if $$$ISERR(sc) { set ec = $$$ADDSC(ec,sc) } @@ -1732,9 +1733,10 @@ ClassMethod ExportSystemDefaults() As %Status } /// if force = 1 then we import item even if timestamp in system is newer -ClassMethod ImportAll(force As %Boolean = 0) As %Status +/// if pullEventClass is defined, then override the configured pull event handler class. +ClassMethod ImportAll(force As %Boolean = 0, pullEventClass As %String) As %Status { - quit ..ImportRoutines(force) + quit ..ImportRoutines(force, .pullEventClass) } ClassMethod ExportRoutines(force As %Boolean = 0) As %Status