-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathAPI.cls
More file actions
101 lines (90 loc) · 3.92 KB
/
API.cls
File metadata and controls
101 lines (90 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Class SourceControl.Git.API
{
/// Configures settings for Git integration
ClassMethod Configure()
{
set sc = $$$OK
set initTLevel = $tlevel
try {
tstart
$$$ThrowOnError(##class(%Studio.SourceControl.Interface).SourceControlClassSet("SourceControl.Git.Extension"))
write !,"Configured SourceControl.Git.Extension as source control class for namespace ",$namespace
set mappingsNode = ##class(SourceControl.Git.Utils).MappingsNode()
if '$data(@mappingsNode) {
do ##class(SourceControl.Git.Utils).SetDefaultMappings(mappingsNode)
write !,"Configured default mappings for classes, routines, and include files. You can customize these in the global:",!?5,mappingsNode
}
set gitExists = ##class(SourceControl.Git.Utils).GitBinExists(.version)
set gitBinPath = ##class(SourceControl.Git.Utils).GitBinPath(.isDefault)
if gitExists && isDefault {
// Note: version starts with "git version"
write !,version," is available via PATH. You may enter a path to a different version if needed."
}
set good = ##class(SourceControl.Git.Settings).Configure()
if 'good {
write !,"Cancelled."
quit
}
tcommit
} catch e {
set sc = e.AsStatus()
write !,$system.Status.GetErrorText(sc)
}
while $tlevel > initTLevel {
trollback 1
}
}
/// API for git pull - just wraps Utils
/// - pTerminateOnError: if set to 1, this will terminate on error if there are any errors in the pull, otherwise will return status
ClassMethod Pull(pTerminateOnError As %Boolean = 0)
{
set st = ##class(SourceControl.Git.Utils).Pull(,pTerminateOnError)
if pTerminateOnError && $$$ISERR(st) {
Do $System.Process.Terminate($Job,1)
}
quit st
}
/// Imports all items from the Git repository into IRIS.
/// - pForce: if true, will import an item even if the last updated timestamp in IRIS is later than that of the file on disk.
ClassMethod ImportAll(pForce As %Boolean = 0) As %Status
{
return ##class(SourceControl.Git.Utils).ImportAll(pForce)
}
/// Locks the environment to prevent changes to code other than through git pull.
/// Returns 1 if the environment was already locked, 0 if it was previously unlocked.
ClassMethod Lock()
{
quit ##class(SourceControl.Git.Utils).Locked(1)
}
/// Unlocks the environment to allow changes through the IDE.
/// Returns 1 if the environment was already locked, 0 if it was previously unlocked.
ClassMethod Unlock()
{
quit ##class(SourceControl.Git.Utils).Locked(0)
}
/// Run in terminal to baseline a namespace by adding all items to source control.
/// - pCommitMessage: if defined, all changes in namespace context will be committed.
/// - pPushToRemote: if defined, will run a git push to the specified remote
/// - pVerbose: verbose output
ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "", pVerbose = 0) As %Status
{
quit ##class(SourceControl.Git.Utils).BaselineExport(pCommitMessage, pPushToRemote, pVerbose)
}
ClassMethod MapEverywhere() As %Status
{
Quit ##class(SourceControl.Git.Installer).MapEverywhere()
}
/// Run to baseline all interoperability productions in the namespace to source control.
/// This should be done after changing the value of the "decompose productions" setting.
ClassMethod BaselineProductions()
{
do ##class(SourceControl.Git.Util.Production).BaselineProductions()
}
/// Given the path to a directory that contains production items, this method will import them all
/// and delete any custom items from the production configuration that do not exist in the directory.
/// This method may be called on a namespace that is not configured with Embedded Git for source control.
ClassMethod LoadProductionsFromDirectory(pDirectoryName, Output pFailedItems) As %Status
{
return ##class(SourceControl.Git.Util.Production).LoadProductionsFromDirectory(pDirectoryName, .pFailedItems)
}
}