Skip to content

Added pull event handler for full import #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2024
Merged
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
@@ -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

4 changes: 2 additions & 2 deletions cls/SourceControl/Git/Modification.cls
Original file line number Diff line number Diff line change
@@ -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;

}
}
11 changes: 8 additions & 3 deletions cls/SourceControl/Git/PullEventHandler.cls
Original file line number Diff line number Diff line change
@@ -21,9 +21,14 @@ Method OnPull() As %Status [ Abstract ]
}

/// <var>files</var> is an integer-subscripted array of <class>SourceControl.Git.Modification</class> objects.
ClassMethod ForModifications(ByRef files) As %Status
/// <var>pullEventClass</var>: 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)
}

}
}
14 changes: 14 additions & 0 deletions cls/SourceControl/Git/PullEventHandler/FullLoad.cls
Original file line number Diff line number Diff line change
@@ -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))
}

}
14 changes: 8 additions & 6 deletions cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
@@ -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 <var>force</var> = 1 then we import item even if timestamp in system is newer
ClassMethod ImportAll(force As %Boolean = 0) As %Status
/// if <var>pullEventClass</var> 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