Skip to content

Commit afbf842

Browse files
authored
Merge pull request #584 from intersystems/map-all
feat: API method to add %ALL mappings
2 parents a26e2d7 + 2effce5 commit afbf842

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
- IRIS Business Intelligence items are mapped to the /dfi subdirectory by default (#428)
1919
- Intelligent merge conflict auto-resolution works for the common Business Rule case as well (#391)
2020
- All git commands run on the server, their output, and any associated sync output, are logged to a table for diagnostic purposes (#454)
21+
- Added API method to automatically add proper %ALL mappings for git-source-control (#214)
2122

2223
### Fixed
2324
- Fixed display of other users' username in workspace view on Unix (#530)

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ Embedded Git support for InterSystems platforms, supporting unified source contr
3232
}
3333
```
3434
35+
### Making available instance-wide via %ALL namespace
36+
37+
To make git-source-control available to all namespaces on an instance without manually installing it in each, you can run:
38+
39+
`do ##class(SourceControl.Git.API).MapEverywhere()`
40+
41+
This will create the appropriate mappings to have all namespaces on the system use the version in the current namespace. Note, namespaces still must be configured independently. To undo this, you can delete the mappings from the %ALL namespace.
42+
3543
## Basic Use
3644
3745
### Source Control

cls/SourceControl/Git/API.cls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,9 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
7676
quit ##class(SourceControl.Git.Utils).BaselineExport(pCommitMessage, pPushToRemote)
7777
}
7878

79+
ClassMethod MapEverywhere()
80+
{
81+
Quit ##class(SourceControl.Git.Installer).MapEverywhere()
82+
}
83+
7984
}

cls/SourceControl/Git/Installer.cls

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/// Mostly used from SourceControl.Git.API:MapEverywhere
2+
Class SourceControl.Git.Installer
3+
{
4+
5+
ClassMethod MapEverywhere()
6+
{
7+
set sc = $$$OK
8+
try {
9+
set ns = $namespace
10+
set locDBDir = ##class(%SYS.Namespace).GetGlobalDest(ns,$Name(^IRIS.Msg("Studio")))
11+
set vars("LocalizationDB") = ..DatabaseDirToName(locDBDir)
12+
set codeDBDir = ##class(%SYS.Namespace).GetPackageDest(ns,"SourceControl.Git")
13+
set vars("RoutineDB") = ..DatabaseDirToName(codeDBDir)
14+
$$$ThrowOnError(..RunMapEverywhere(.vars))
15+
} catch e {
16+
set sc = e.AsStatus()
17+
if '$quit {
18+
write !,$System.Status.GetErrorText(sc)
19+
}
20+
}
21+
quit sc
22+
}
23+
24+
ClassMethod DatabaseDirToName(dbDir As %String) As %String [ Private ]
25+
{
26+
New $Namespace
27+
Set $Namespace = "%SYS"
28+
Set tSC = ##class(Config.Databases).DatabasesByDirectory($Piece(dbDir,"^"),$Piece(dbDir,"^",2),.tDBList)
29+
$$$ThrowOnError(tSC)
30+
If ($ListLength(tDBList) '= 1) {
31+
// This is highly unexpected, but worth checking for anyway.
32+
$$$ThrowStatus($$$ERROR($$$GeneralError,$$$FormatText("Could not find database name for '%1'",tDBDir)))
33+
}
34+
$$$ThrowOnError(tSC)
35+
Quit $ListGet(tDBList)
36+
}
37+
38+
/// This is a method generator whose code is generated by XGL.
39+
ClassMethod RunMapEverywhere(ByRef pVars, pLogLevel As %Integer = 3, pInstaller As %Installer.Installer, pLogger As %Installer.AbstractLogger) As %Status [ CodeMode = objectgenerator, Internal, Private ]
40+
{
41+
quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "MapEverywhere")
42+
}
43+
44+
XData MapEverywhere [ XMLNamespace = INSTALLER ]
45+
{
46+
<Manifest>
47+
<Namespace Name="%ALL" Create="yes" Ensemble="no" Code="%DEFAULTDB" Data="%DEFAULTDB">
48+
<Configuration>
49+
<GlobalMapping Global="IRIS.Msg" From="%DEFAULTDB" />
50+
<GlobalMapping Global="IRIS.Msg(&quot;Studio&quot;)" From="${LocalizationDB}" />
51+
<ClassMapping Package="SourceControl.Git" From="${RoutineDB}" />
52+
</Configuration>
53+
</Namespace>
54+
</Manifest>
55+
}
56+
57+
}

0 commit comments

Comments
 (0)