Skip to content

Commit def4a75

Browse files
authored
Merge pull request #638 from intersystems/full-load-handler
Added pull event handler for full import
2 parents ebf933e + 09c839a commit def4a75

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Production Decomposition mode allows controlling interoperability productions as individual files for each host (#469)
1212
- Added saving settings as system default for new namespaces (#535)
1313
- Added filtering through branch names in UI (#615)
14+
- FullLoad pull event handler allows deploying changes with a full import of the repository (#619)
1415

1516
## [2.7.1] - 2024-11-13
1617

cls/SourceControl/Git/Modification.cls

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Class SourceControl.Git.Modification Extends %RegisteredObject
33
{
44

5-
/// path of the file
5+
/// path of the file relative to the Git repository
66
Property externalName As %String;
77

88
/// Name in IRIS SourceControl.Git.Modification
@@ -11,4 +11,4 @@ Property internalName As %String;
1111
/// Type of change (A|C|D|M|R|T|U|X|B). See git diff documentation.
1212
Property changeType As %String;
1313

14-
}
14+
}

cls/SourceControl/Git/PullEventHandler.cls

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ Method OnPull() As %Status [ Abstract ]
2121
}
2222

2323
/// <var>files</var> is an integer-subscripted array of <class>SourceControl.Git.Modification</class> objects.
24-
ClassMethod ForModifications(ByRef files) As %Status
24+
/// <var>pullEventClass</var>: if defined, override the configured pull event class
25+
ClassMethod ForModifications(ByRef files, pullEventClass As %String) As %Status
2526
{
26-
set event = $classmethod(##class(SourceControl.Git.Utils).PullEventClass(),"%New")
27+
set event = $classmethod(
28+
$select(
29+
$data(pullEventClass)#2: pullEventClass,
30+
1: ##class(SourceControl.Git.Utils).PullEventClass())
31+
,"%New")
2732
set event.LocalRoot = ##class(SourceControl.Git.Utils).TempFolder()
2833
merge event.ModifiedFiles = files
2934
quit event.OnPull()
@@ -44,4 +49,4 @@ ClassMethod ForInternalNames(InternalName As %String) As %Status
4449
quit ..ForModifications(.files)
4550
}
4651

47-
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Class SourceControl.Git.PullEventHandler.FullLoad Extends SourceControl.Git.PullEventHandler
2+
{
3+
4+
Parameter NAME = "Full Load";
5+
6+
Parameter DESCRIPTION = "Performs an full load and compile of all items in the repository.";
7+
8+
Method OnPull() As %Status
9+
{
10+
return ##class(SourceControl.Git.Utils).ImportAll(1,
11+
##class(SourceControl.Git.PullEventHandler.IncrementalLoad).%ClassName(1))
12+
}
13+
14+
}

cls/SourceControl/Git/Utils.cls

+8-6
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ ClassMethod ListItemsInFiles(ByRef itemList, ByRef err) As %Status
15361536
quit $$$OK
15371537
}
15381538

1539-
ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
1539+
ClassMethod ImportRoutines(force As %Boolean = 0, pullEventClass As %String) As %Status
15401540
{
15411541
set refContext = ##class(SourceControl.Git.PackageManagerContext).%Get()
15421542
set refPackage = refContext.Package
@@ -1573,7 +1573,7 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
15731573
set modification = ##class(SourceControl.Git.Modification).%New()
15741574
set modification.changeType = "M"
15751575
set modification.internalName = internalName
1576-
set modification.externalName = ..FullExternalName(internalName)
1576+
set modification.externalName = ..ExternalName(internalName)
15771577
set files($increment(files)) = modification
15781578
}
15791579
}
@@ -1588,18 +1588,19 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
15881588
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(item)
15891589
continue:context.Package'=refPackage
15901590

1591+
set externalName = ..ExternalName(item)
15911592
set fullExternalName = ..FullExternalName(item)
15921593
if '##class(%File).Exists(fullExternalName) {
15931594
write !,fullExternalName," does not exist - deleting ",item
15941595
set modification = ##class(SourceControl.Git.Modification).%New()
15951596
set modification.changeType = "D"
15961597
set modification.internalName = item
1597-
set modification.externalName = fullExternalName
1598+
set modification.externalName = externalName
15981599
set files($increment(files)) = modification
15991600
}
16001601
}
16011602

1602-
set sc = ##class(SourceControl.Git.PullEventHandler).ForModifications(.files)
1603+
set sc = ##class(SourceControl.Git.PullEventHandler).ForModifications(.files, .pullEventClass)
16031604
if $$$ISERR(sc) {
16041605
set ec = $$$ADDSC(ec,sc)
16051606
}
@@ -1732,9 +1733,10 @@ ClassMethod ExportSystemDefaults() As %Status
17321733
}
17331734

17341735
/// if <var>force</var> = 1 then we import item even if timestamp in system is newer
1735-
ClassMethod ImportAll(force As %Boolean = 0) As %Status
1736+
/// if <var>pullEventClass</var> is defined, then override the configured pull event handler class.
1737+
ClassMethod ImportAll(force As %Boolean = 0, pullEventClass As %String) As %Status
17361738
{
1737-
quit ..ImportRoutines(force)
1739+
quit ..ImportRoutines(force, .pullEventClass)
17381740
}
17391741

17401742
ClassMethod ExportRoutines(force As %Boolean = 0) As %Status

0 commit comments

Comments
 (0)