Skip to content

feat: API method to add %ALL mappings #584

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 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
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
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- IRIS Business Intelligence items are mapped to the /dfi subdirectory by default (#428)
- Intelligent merge conflict auto-resolution works for the common Business Rule case as well (#391)
- All git commands run on the server, their output, and any associated sync output, are logged to a table for diagnostic purposes (#454)
- Added API method to automatically add proper %ALL mappings for git-source-control (#214)

### Fixed
- Fixed display of other users' username in workspace view on Unix (#530)
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Embedded Git support for InterSystems platforms, supporting unified source contr
}
```

### Making available instance-wide via %ALL namespace

To make git-source-control available to all namespaces on an instance without manually installing it in each, you can run:

`do ##class(SourceControl.Git.API).MapEverywhere()`

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.

## Basic Use

### Source Control
Expand Down
5 changes: 5 additions & 0 deletions cls/SourceControl/Git/API.cls
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@ ClassMethod BaselineExport(pCommitMessage = "", pPushToRemote = "") As %Status
quit ##class(SourceControl.Git.Utils).BaselineExport(pCommitMessage, pPushToRemote)
}

ClassMethod MapEverywhere()
{
Quit ##class(SourceControl.Git.Installer).MapEverywhere()
}

}
57 changes: 57 additions & 0 deletions cls/SourceControl/Git/Installer.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/// Mostly used from SourceControl.Git.API:MapEverywhere
Class SourceControl.Git.Installer
{

ClassMethod MapEverywhere()
{
set sc = $$$OK
try {
set ns = $namespace
set locDBDir = ##class(%SYS.Namespace).GetGlobalDest(ns,$Name(^IRIS.Msg("Studio")))
set vars("LocalizationDB") = ..DatabaseDirToName(locDBDir)
set codeDBDir = ##class(%SYS.Namespace).GetPackageDest(ns,"SourceControl.Git")
set vars("RoutineDB") = ..DatabaseDirToName(codeDBDir)
$$$ThrowOnError(..RunMapEverywhere(.vars))
} catch e {
set sc = e.AsStatus()
if '$quit {
write !,$System.Status.GetErrorText(sc)
}
}
quit sc
}

ClassMethod DatabaseDirToName(dbDir As %String) As %String [ Private ]
{
New $Namespace
Set $Namespace = "%SYS"
Set tSC = ##class(Config.Databases).DatabasesByDirectory($Piece(dbDir,"^"),$Piece(dbDir,"^",2),.tDBList)
$$$ThrowOnError(tSC)
If ($ListLength(tDBList) '= 1) {
// This is highly unexpected, but worth checking for anyway.
$$$ThrowStatus($$$ERROR($$$GeneralError,$$$FormatText("Could not find database name for '%1'",tDBDir)))
}
$$$ThrowOnError(tSC)
Quit $ListGet(tDBList)
}

/// This is a method generator whose code is generated by XGL.
ClassMethod RunMapEverywhere(ByRef pVars, pLogLevel As %Integer = 3, pInstaller As %Installer.Installer, pLogger As %Installer.AbstractLogger) As %Status [ CodeMode = objectgenerator, Internal, Private ]
{
quit ##class(%Installer.Manifest).%Generate(%compiledclass, %code, "MapEverywhere")
}

XData MapEverywhere [ XMLNamespace = INSTALLER ]
{
<Manifest>
<Namespace Name="%ALL" Create="yes" Ensemble="no" Code="%DEFAULTDB" Data="%DEFAULTDB">
<Configuration>
<GlobalMapping Global="IRIS.Msg" From="%DEFAULTDB" />
<GlobalMapping Global="IRIS.Msg(&quot;Studio&quot;)" From="${LocalizationDB}" />
<ClassMapping Package="SourceControl.Git" From="${RoutineDB}" />
</Configuration>
</Namespace>
</Manifest>
}

}
Loading